From 7c6e0e8065cfdf974be1824b9b38d70542a258e7 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 14 Jan 2023 22:16:16 +0100 Subject: Rewrote mingw toolchain and made CMake build script to generate it --- .gitignore | 1 + CMakeLists.txt | 10 ++++++++++ toolchain.cmake.in | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 toolchain.cmake.in diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a5309e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build*/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..eebfff4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.19) +project(mingw-cmake-toolchains NONE) +set(MINGW_TOOLCHAINS i686-w64-mingw32 x86_64-w64-mingw32) +include(GNUInstallDirs) +foreach(MINGW_TOOLCHAIN IN ITEMS ${MINGW_TOOLCHAINS}) + configure_file(toolchain.cmake.in "${MINGW_TOOLCHAIN}.cmake" @ONLY) + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${MINGW_TOOLCHAIN}.cmake" + DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/toolchains") +endforeach() diff --git a/toolchain.cmake.in b/toolchain.cmake.in new file mode 100644 index 0000000..ae4bb87 --- /dev/null +++ b/toolchain.cmake.in @@ -0,0 +1,22 @@ +set(MINGW_TOOLCHAIN @MINGW_TOOLCHAIN@) + +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_CROSSCOMPILING ON) + +set(CMAKE_AR "${MINGW_TOOLCHAIN}-ar") +set(CMAKE_C_COMPILER "${MINGW_TOOLCHAIN}-gcc") +set(CMAKE_CXX_COMPILER "${MINGW_TOOLCHAIN}-g++") +set(CMAKE_RC_COMPILER "${MINGW_TOOLCHAIN}-windres") +set(CMAKE_OBJCOPY "${MINGW_TOOLCHAIN}-objcopy") +set(CMAKE_OBJDUMP "${MINGW_TOOLCHAIN}-objdump") +set(CMAKE_READELF "${MINGW_TOOLCHAIN}-readelf") + +set(CMAKE_FIND_ROOT_PATH "/usr/${MINGW_TOOLCHAIN}") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +find_program(WINE wine) +if(WINE) + set(CMAKE_CROSSCOMPILING_EMULATOR ${WINE}) +endif() -- cgit v1.1