aboutsummaryrefslogtreecommitdiff
path: root/cmake/toolchains
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/toolchains')
-rw-r--r--cmake/toolchains/mingw-w64-x86_64.cmake27
1 files changed, 27 insertions, 0 deletions
diff --git a/cmake/toolchains/mingw-w64-x86_64.cmake b/cmake/toolchains/mingw-w64-x86_64.cmake
new file mode 100644
index 0000000..7935b7e
--- /dev/null
+++ b/cmake/toolchains/mingw-w64-x86_64.cmake
@@ -0,0 +1,27 @@
+# MinGW-w64 x86_64 toolchain file for cross-compiling Windows binaries from Linux
+# Usage:
+# cmake -S . -B build-win-mingw \
+# -G Ninja \
+# -DCMAKE_BUILD_TYPE=Release \
+# -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64-x86_64.cmake
+
+set(CMAKE_SYSTEM_NAME Windows)
+set(CMAKE_SYSTEM_VERSION 10)
+
+# Adjust these prefixes if your distro uses different triplets
+set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
+
+find_program(CMAKE_C_COMPILER NAMES ${TOOLCHAIN_PREFIX}-gcc)
+find_program(CMAKE_CXX_COMPILER NAMES ${TOOLCHAIN_PREFIX}-g++)
+find_program(CMAKE_RC_COMPILER NAMES ${TOOLCHAIN_PREFIX}-windres)
+
+# For pkg-config in cross environment (optional)
+# set(ENV{PKG_CONFIG_LIBDIR} "")
+# set(ENV{PKG_CONFIG_PATH} "")
+
+set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} /usr/${TOOLCHAIN_PREFIX}/${TOOLCHAIN_PREFIX})
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)