diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | toolchain.cmake.in | 22 |
3 files changed, 33 insertions, 0 deletions
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() |