-
Notifications
You must be signed in to change notification settings - Fork 254
Expand file tree
/
Copy pathtoolchain-x86.cmake
More file actions
32 lines (28 loc) · 1.85 KB
/
Copy pathtoolchain-x86.cmake
File metadata and controls
32 lines (28 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# CMake toolchain file for x86 (32-bit) builds
# Cross-platform: works on Windows, Linux, and macOS
# Force 32-bit pointer size BEFORE compiler detection
set(CMAKE_SIZEOF_VOID_P 4 CACHE INTERNAL "Pointer size in bytes" FORCE)
# Platform-specific configuration
if(WIN32)
# On Windows with MSVC, rely on vcvarsall.bat environment setup
# Visual Studio and Ninja will use the environment provided by the developer command prompt
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR X86)
message(STATUS "x86 Toolchain: Configured for 32-bit Windows build")
elseif(UNIX AND NOT APPLE)
# On Linux, add -m32 flag to force 32-bit compilation
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "C compiler flags" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "C++ compiler flags" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" CACHE STRING "Linker flags" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32" CACHE STRING "Shared linker flags" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m32" CACHE STRING "Module linker flags" FORCE)
message(STATUS "x86 Toolchain: Configured for 32-bit Linux build")
elseif(APPLE)
# On macOS, add -m32 flag (note: 32-bit support removed in macOS 10.15+)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "C compiler flags" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "C++ compiler flags" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" CACHE STRING "Linker flags" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32" CACHE STRING "Shared linker flags" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -m32" CACHE STRING "Module linker flags" FORCE)
message(STATUS "x86 Toolchain: Configured for 32-bit macOS build (requires 32-bit libraries)")
endif()