Files
2026-11-23 03:28:32 +02:00

32 lines
1.9 KiB
CMake

# Linux -> Windows x64 (UCRT) cross build of the GW native set.
# Uses the distro mingw-w64-gcc 16.2.0 compiler with the MSYS2 ucrt64 runtime,
# headers and libraries (the same ones the Windows MSYS2 build host links).
# MSYS2_UCRT64 defaults to the extracted package root; see docs/LINUX_CROSS_BUILD.md.
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
if(NOT DEFINED MSYS2_UCRT64)
set(MSYS2_UCRT64 "$ENV{MSYS2_UCRT64}")
endif()
if(NOT MSYS2_UCRT64)
set(MSYS2_UCRT64 "/mnt/Games/@project/tools/msys2-ucrt64/root/ucrt64")
endif()
set(_gw_gcclib "${MSYS2_UCRT64}/lib/gcc/x86_64-w64-mingw32/16.2.0")
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_ASM_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
# MSYS2 GCC defaults to nocona; the distro cross GCC defaults to x86-64.
set(_gw_common "-march=nocona -mtune=generic -nostdinc -isystem ${_gw_gcclib}/include -isystem ${_gw_gcclib}/include-fixed -isystem ${MSYS2_UCRT64}/include")
set(CMAKE_C_FLAGS_INIT "${_gw_common}")
set(CMAKE_ASM_FLAGS_INIT "${_gw_common}")
set(CMAKE_CXX_FLAGS_INIT "-march=nocona -mtune=generic -nostdinc -isystem ${MSYS2_UCRT64}/include/c++/16.2.0 -isystem ${MSYS2_UCRT64}/include/c++/16.2.0/x86_64-w64-mingw32 -isystem ${MSYS2_UCRT64}/include/c++/16.2.0/backward -isystem ${_gw_gcclib}/include -isystem ${_gw_gcclib}/include-fixed -isystem ${MSYS2_UCRT64}/include")
# Arch's crt lacks atexit in libmingw32 (Wire links -nostartfiles): search MSYS2 runtime first.
foreach(_k SHARED MODULE EXE)
set(CMAKE_${_k}_LINKER_FLAGS_INIT "-B${_gw_gcclib}/ -B${MSYS2_UCRT64}/lib/ -L${_gw_gcclib} -L${MSYS2_UCRT64}/lib")
endforeach()
set(CMAKE_FIND_ROOT_PATH "${MSYS2_UCRT64}")
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)