blob: e96b3d6df381809212a128b6aa75cda0d6e7ec18 (
plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# this file only serves as toolchain file when specified so explicitly
# when building the software. from repository's root directory:
# mkdir build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=$(pwd)/../cmake/mingw-w64.cmake
# -sh 20140922
if((NOT CMAKE_BUILD_TYPE STREQUAL "DEBUG") AND (NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE"))
set(CMAKE_BUILD_TYPE "DEBUG" CACHE STRING "" FORCE)
endif()
string(TOUPPER "${CMAKE_BUILD_TYPE}" __build_type)
if(NOT __build_type STREQUAL CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "${__build_type}" CACHE STRING "" FORCE)
endif()
if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE STRING "" FORCE)
endif()
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_VERSION 5)
# specify the cross compiler
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
#set(p D:/cygwin64/opt/bin/)
#set(p "/mingw32/bin/")
set(p "")
set(e .exe)
set(c "${p}")
else()
set(p "")
set(c "${p}i686-w64-mingw32-")
set(e "")
endif()
SET(CMAKE_C_COMPILER ${c}gcc${e})
SET(CMAKE_CXX_COMPILER ${c}g++${e})
set(CMAKE_RC_COMPILER ${c}windres${e})
set(CMAKE_LINKER ${c}ld${e})
set(CMAKE_AR ${c}gcc-ar${e} CACHE STRING "" FORCE)
set(CMAKE_NM ${c}gcc-nm${e} CACHE STRING "" FORCE)
set(CMAKE_RANLIB ${c}gcc-ranlib${e} CACHE STRING "" FORCE)
set(CMAKE_OBJCOPY ${c}objcopy${e} CACHE STRING "" FORCE)
set(CMAKE_OBJDUMP ${c}objdump${e} CACHE STRING "" FORCE)
set(CMAKE_STRIP ${c}strip${e} CACHE STRING "" FORCE)
# search for programs in the host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# don't poison with system compile-time data
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# oldest CPU supported here is Northwood-based Pentium 4. -sh 20150811
set(fpu "-ffast-math -mfpmath=both -mstackrealign -falign-functions=16 -falign-loops=16")
set(cpu "-O3 -march=native -frename-registers")
#set(lto "-fno-lto -fno-use-linker-plugin -flto-compression-level=9 -flto-partition=balanced -fno-ipa-pta -fno-lto-odr-type-merging")
set(lto "")
set(sections "-ffunction-sections -fdata-sections -s")
set(cc "")
#set(cc "-fdump-statistics-details -fdump-ipa-cgraph")
set(clang-warns "")
if(CMAKE_COMPILER_IS_CLANGXX)
set(clang-warns "-Wweak-vtables")
endif()
set(noisy-warns "")
set(suggest-final "")
set(numerics "")
set(missing-override "")
if(WARNINGS_ENABLE)
if(WARNINGS_FINAL_SUGGESTIONS)
set(suggest-final "-Wsuggest-final-types -Wsuggest-final-methods")
endif()
if(WARNINGS_NUMERIC)
set(numerics "-Wdouble-promotion -Wsign-compare")
endif()
if(WARNINGS_MISSING_OVERRIDE)
set(missing-override "-Wsuggest-override")
endif()
set(noisy-warns "${suggest-final} ${numerics}")
endif()
set(_CXX_WARNS "")
set(_C_WARNS "")
if(WARNINGS_ENABLE)
set(usual-warns "-Wdelete-non-virtual-dtor -Wno-suggest-override -Wno-odr -Wno-attributes -Wcast-align")
set(_C_WARNS "-Wall -Wextra -Wpedantic -Wcast-align")
set(_CXX_WARNS "${_C_WARNS} ${usual-warns} ${clang-warns} ${noisy-warns} ${missing-override}")
endif()
set(ccflags-common "-fvisibility=hidden -pipe -g3")
set(_CXXFLAGS "${ccflags-common} ${_CXX_WARNS}")
set(_CFLAGS "${ccflags-common} -std=c11 ${_C_WARNS}")
set(_CFLAGS_RELEASE "${cpu} ${fpu} ${lto} ${sections} ${cc}")
set(_CFLAGS_DEBUG "-g -O0 -fstack-protector-strong")
set(_CXXFLAGS_RELEASE "${_CFLAGS_RELEASE} ${cc}")
set(_CXXFLAGS_DEBUG "${_CFLAGS_DEBUG}")
add_definitions(-DSTRSAFE_NO_DEPRECATE)
set(_LDFLAGS "-Wl,--dynamicbase,--nxcompat,--as-needed")
set(_LDFLAGS_RELEASE "-Wl,--gc-sections,--exclude-libs,ALL")
set(_LDFLAGS_DEBUG "")
set(enable-val FALSE)
if(CMAKE_PROJECT_NAME STREQUAL "opentrack")
set(enable-val TRUE)
endif()
set(WARNINGS_ENABLE ${enable-val} CACHE BOOL "Emit additional warnings at compile-time")
# these are very noisy, high false positive rate. only for development.
set(WARNINGS_FINAL_SUGGESTIONS FALSE CACHE BOOL "Emit very noisy warnings at compile-time")
set(WARNINGS_NUMERIC ${enable-val} CACHE BOOL "Emit very noisy warnings at compile-time")
set(WARNINGS_MISSING_OVERRIDE FALSE CACHE BOOL "Emit very noisy warnings at compile-time")
foreach(j C CXX)
foreach(i "" _DEBUG _RELEASE)
set(CMAKE_${j}_FLAGS${i} "${_${j}FLAGS${i}} ${CMAKE_${j}_FLAGS${j}}")
endforeach()
endforeach()
foreach(j "" _DEBUG _RELEASE)
foreach(i MODULE EXE SHARED)
set(CMAKE_${i}_LINKER_FLAGS${j} "${_LDFLAGS${j}} ${CMAKE_${i}_LINKER_FLAGS${j}}")
endforeach()
endforeach()
|