From f8e183b7ab53c3437f293da4b28f596435b32db5 Mon Sep 17 00:00:00 2001 From: Aleksey Selihov <1+faumaray@noreply@void.com> Date: Thu, 3 Dec 2026 08:09:54 +0000 Subject: [PATCH] chore(build): containers, toolchains and portability fixes --- cmake/toolchains/mingw-w64.cmake | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cmake/toolchains/mingw-w64.cmake diff --git a/cmake/toolchains/mingw-w64.cmake b/cmake/toolchains/mingw-w64.cmake new file mode 100644 index 0000000..3d7b2e5 --- /dev/null +++ b/cmake/toolchains/mingw-w64.cmake @@ -0,0 +1,33 @@ +# CMake toolchain for cross-compiling to Windows x64 with MinGW-w64. +# +# Works with the GCC-based mingw-w64 package and with the LLVM-MinGW +# toolchain (Dockerfile.mingw). Override the compiler paths for your install. +# +# Usage: +# cmake -B build-mingw -S . -G Ninja \ +# -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/mingw-w64.cmake \ +# -DCMAKE_BUILD_TYPE=Debug + +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +if(NOT DEFINED VOID_MINGW_PREFIX) + set(VOID_MINGW_PREFIX x86_64-w64-mingw32) +endif() + +find_program(VOID_MINGW_CXX NAMES "${VOID_MINGW_PREFIX}-clang++" + "${VOID_MINGW_PREFIX}-g++" REQUIRED) +find_program(VOID_MINGW_C NAMES "${VOID_MINGW_PREFIX}-clang" + "${VOID_MINGW_PREFIX}-gcc" REQUIRED) +find_program(VOID_MINGW_RC NAMES "${VOID_MINGW_PREFIX}-windres") + +set(CMAKE_CXX_COMPILER "${VOID_MINGW_CXX}") +set(CMAKE_C_COMPILER "${VOID_MINGW_C}") +if(VOID_MINGW_RC) + set(CMAKE_RC_COMPILER "${VOID_MINGW_RC}") +endif() + +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)