-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTC-clang.cmake
60 lines (46 loc) · 2.2 KB
/
TC-clang.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
# Based on: https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html
# the name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)
# which compilers to use for C and C++
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
# where is the target environment located
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
# So that tests and codegen programs can be run
set(CMAKE_CROSSCOMPILING_EMULATOR wine)
# adjust the default behavior of the FIND_XXX() commands:
# search programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
set(TC_COMMON_FLAGS "")
set(TC_COMPILE_FLAGS "")
set(TC_LINK_FLAGS "")
# We're building for 32 bit Windows using MinGW runtime
string(APPEND TC_COMMON_FLAGS "--sysroot /usr/i686-w64-mingw32 --target=i686-pc-windows-gnu")
# Common flags
string(APPEND TC_COMPILE_FLAGS "${TC_COMMON_FLAGS}")
# Use static linking so the DLL's are self-contained
string(APPEND TC_COMPILE_FLAGS " -static")
# Need __decltype(dllexport) and probably some other stuff
string(APPEND TC_COMPILE_FLAGS " -fms-extensions")
# sol2's autodetection of strerror_r existence is wrong
string(APPEND TC_COMPILE_FLAGS " -DCOMPAT53_HAVE_STRERROR_R=0")
# The runtime library already contains the typeinfo== operator, we can't have a
# duplicate symbol by defining it again.
string(APPEND TC_COMPILE_FLAGS " -D__GXX_TYPEINFO_EQUALITY_INLINE=0")
# MinGW include paths
string(APPEND TC_COMPILE_FLAGS " -I /usr/i686-w64-mingw32/include/c++/13.1.0/ -I /usr/i686-w64-mingw32/include/c++/13.1.0/i686-w64-mingw32")
string(APPEND TC_COMPILE_FLAGS " -DIMGUI_DISABLE_SSE")
set(CMAKE_C_FLAGS "${TC_COMPILE_FLAGS}")
set(CMAKE_CXX_FLAGS "${TC_COMPILE_FLAGS}")
# Common flags
string(APPEND TC_LINK_FLAGS "${TC_COMMON_FLAGS}")
# Use ldd linker
string(APPEND TC_LINK_FLAGS " -fuse-ld=lld")
# MinGW library path
string(APPEND TC_LINK_FLAGS " -L /usr/lib/gcc/i686-w64-mingw32/13.1.0")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${TC_LINK_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "${TC_LINK_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "${TC_LINK_FLAGS}")