Files
kdm-re/cmake/toolchain-mingw-i686.cmake
T

39 lines
1.9 KiB
CMake

# CMake cross-compilation toolchain file for the Windows (32-bit) build of
# gamekdm.dll, targeting i686-w64-mingw32 with the pinned no-sudo Nix toolchain
# recorded in ../toolchain.lock (GCC 16.2.0, mingw-w64 14.0.0 headers/CRT).
#
# Usage (after `source ./activate.sh` to put the cross toolchain on PATH):
# cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw-i686.cmake
# cmake --build build
#
# Pattern reused/adapted from ~/kinect/cmake/mingw-w64.cmake, fixed to the
# i686 (32-bit) target that matches the shipping gamekdm.dll's bitness
# (confirmed PE32 by `objdump -f` on the stub build; see task-2.log).
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86)
set(_gk_mingw_prefix i686-w64-mingw32)
set(CMAKE_C_COMPILER ${_gk_mingw_prefix}-gcc)
set(CMAKE_CXX_COMPILER ${_gk_mingw_prefix}-g++)
set(CMAKE_RC_COMPILER ${_gk_mingw_prefix}-windres)
set(CMAKE_RC_COMPILER_INIT ${_gk_mingw_prefix}-windres)
find_program(CMAKE_DLLTOOL NAMES ${_gk_mingw_prefix}-dlltool dlltool)
set(CMAKE_FIND_ROOT_PATH /usr/${_gk_mingw_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)
# GCC 16.2.0's i686-w64-mingw32 default link spec needs -lmcfgthread, which
# ships as its own Nix package (pkgsCross.mingw32.windows.mcfgthreads) rather
# than bundled with the gcc derivation itself; point the linker at its lib
# dir explicitly for every link (shared libs/DLLs and any executables alike).
# Store path pinned in ../toolchain.lock; keep in sync if the pin moves.
set(_gk_mcfgthread_lib "/nix/store/g72bh3mrbh6gkh59axd2199js9kccxfs-mcfgthread-i686-w64-mingw32-2.5.1/lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${_gk_mcfgthread_lib}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${_gk_mcfgthread_lib}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L${_gk_mcfgthread_lib}")