v0.2.0: clang + import std; isolated Windows cross-build (llvm-mingw + SDL3)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# Cross-compile for Windows x86_64 with llvm-mingw: clang + libc++ + the
|
||||
# libc++ `std` module, targeting the MSVCRT MinGW runtime (which is what the
|
||||
# official SDL3 MinGW package links against).
|
||||
|
||||
# The `import std` gate must be set before the compiler is probed; a toolchain
|
||||
# file is processed earlier than the project's own top-level settings.
|
||||
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
set(OPENRA3_LLVM_MINGW_ROOT "/opt/llvm-mingw" CACHE PATH "llvm-mingw installation root")
|
||||
if(NOT EXISTS "${OPENRA3_LLVM_MINGW_ROOT}/bin/clang++")
|
||||
message(FATAL_ERROR "llvm-mingw not found at ${OPENRA3_LLVM_MINGW_ROOT} (expected bin/clang++)")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER "${OPENRA3_LLVM_MINGW_ROOT}/bin/clang")
|
||||
set(CMAKE_CXX_COMPILER "${OPENRA3_LLVM_MINGW_ROOT}/bin/clang++")
|
||||
set(CMAKE_C_COMPILER_TARGET x86_64-w64-mingw32)
|
||||
set(CMAKE_CXX_COMPILER_TARGET x86_64-w64-mingw32)
|
||||
# CMake's standard-library detection does not pass COMPILER_TARGET, so without
|
||||
# this it probes the host standard library. Putting the target in ARG1 makes
|
||||
# the probe see libc++ (the MinGW target's library).
|
||||
set(CMAKE_C_COMPILER_ARG1 "--target=x86_64-w64-mingw32")
|
||||
set(CMAKE_CXX_COMPILER_ARG1 "--target=x86_64-w64-mingw32")
|
||||
|
||||
# libc++ standard-library module description for the MinGW target. Must be set
|
||||
# before the compiler is probed so CMake can build `import std;`.
|
||||
set(CMAKE_CXX_STDLIB_MODULES_JSON "${OPENRA3_LLVM_MINGW_ROOT}/x86_64-w64-mingw32/lib/libc++.modules.json")
|
||||
|
||||
# Select libc++ explicitly so CMake's `import std` detection recognises the
|
||||
# standard library (llvm-mingw defaults to it, but CMake keys off -stdlib=).
|
||||
set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-stdlib=libc++")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-stdlib=libc++")
|
||||
|
||||
# Official SDL3 MinGW development package (headers + import library + DLL).
|
||||
set(OPENRA3_SDL3_ROOT "/opt/sdl3-mingw" CACHE PATH "SDL3 MinGW development package root")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH "${OPENRA3_LLVM_MINGW_ROOT}/x86_64-w64-mingw32")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
Reference in New Issue
Block a user