summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-01-14 22:16:16 +0100
committerAki <please@ignore.pl>2023-01-14 22:16:16 +0100
commit7c6e0e8065cfdf974be1824b9b38d70542a258e7 (patch)
treedf21a08dc7a1009d4cb913035470f38971228fc0
downloadmingw-w64-cmake-toolchains-7c6e0e8065cfdf974be1824b9b38d70542a258e7.zip
mingw-w64-cmake-toolchains-7c6e0e8065cfdf974be1824b9b38d70542a258e7.tar.gz
mingw-w64-cmake-toolchains-7c6e0e8065cfdf974be1824b9b38d70542a258e7.tar.bz2
Rewrote mingw toolchain and made CMake build script to generate it
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt10
-rw-r--r--toolchain.cmake.in22
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()