-
Notifications
You must be signed in to change notification settings - Fork 4
/
MinGW.toolchain
29 lines (25 loc) · 1.12 KB
/
MinGW.toolchain
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
# CMake toolchain file for cross-compilation on Windows
#---- could not get this to work yet, but included here for future attempts
set(CMAKE_SYSTEM_NAME Windows)
set(TARGET_ARCH "64" CACHE STRING "Which architecture to target (32|64)")
# Choosing the compiler (assuming MinGW)
if(TARGET_ARCH STREQUAL "32")
message(STATUS "Targeting 32-bit Windows using MinGW")
set(COMPILER_PREFIX i686-w64-mingw32)
elseif(TARGET_ARCH STREQUAL "64")
message(STATUS "Targeting 64-bit Windows using MinGW")
set(COMPILER_PREFIX x86_64-w64-mingw32)
else()
message(FATAL_ERROR "Target architecture ${TARGET_ARCH} not recognized!")
endif()
set(CMAKE_C_COMPILER "${COMPILER_PREFIX}-gcc")
set(CMAKE_CXX_COMPILER "${COMPILER_PREFIX}-g++")
set(CMAKE_RC_COMPILER "${COMPILER_PREFIX}-windres")
# Target environment
# (has to contain all the required dependencies)
set(CMAKE_FIND_ROOT_PATH "/usr/${COMPILER_PREFIX}")
# Search headers & libraries in the target environment,
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)