-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmingw.toolchain.cmake
executable file
·69 lines (57 loc) · 2.15 KB
/
mingw.toolchain.cmake
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# original: https://gist.github.com/take-cheeze/2850831#file-toolchain-mingw-cmake
cmake_minimum_required(VERSION 3.6.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -pipe -fno-plt -fexceptions --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fcf-protection")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
set(BUILD_SHARED_LIBS ON)
# the name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR ${MINGW_ARCH})
set(CMAKE_SYSROOT ${MINGW_DIR})
set(C_COMPILERS
/usr/bin/${MINGW_ARCH}-w64-mingw32-gcc
/usr/local/bin/${MINGW_ARCH}-w64-mingw32-gcc
${MINGW_DIR}/bin/${MINGW_ARCH}-w64-mingw32-gcc.exe
)
set(CXX_COMPILERS
/usr/bin/${MINGW_ARCH}-w64-mingw32-g++
/usr/local/bin/${MINGW_ARCH}-w64-mingw32-g++
${MINGW_DIR}/bin/${MINGW_ARCH}-w64-mingw32-g++.exe
)
set(RC_COMPILERS
/usr/bin/${MINGW_ARCH}-w64-mingw32-windres
/usr/local/bin/${MINGW_ARCH}-w64-mingw32-windres
${MINGW_DIR}/bin/${MINGW_ARCH}-w64-mingw32-windres.exe
)
set(CMAKE_MAKE_PROGRAM ${MINGW_DIR}/bin/mingw32-make)
foreach(C_COMPILER IN LISTS C_COMPILERS)
if(EXISTS ${C_COMPILER})
message(">>> Found C Compiler : " ${C_COMPILER})
set(CMAKE_C_COMPILER ${C_COMPILER})
break()
endif()
endforeach()
foreach(CXX_COMPILER IN LISTS CXX_COMPILERS)
if(EXISTS ${CXX_COMPILER})
message(">>> Found CXX Compiler : " ${CXX_COMPILER})
set(CMAKE_CXX_COMPILER ${CXX_COMPILER})
break()
endif()
endforeach()
foreach(RC_COMPILER IN LISTS RC_COMPILERS)
if(EXISTS ${RC_COMPILER})
message(">>> Found RC Compiler : " ${RC_COMPILER})
set(CMAKE_RC_COMPILER ${RC_COMPILER})
break()
endif()
endforeach()
# here is the target environment located
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT} ${MINGW_DIR}/${MINGW_ARCH}-w64-mingw32)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and 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)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".lib" ".a")