blob: e7e3c329b3d9b737d1344c0a27dca583e4c9bc30 (
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# this file only serves as toolchain file when specified so explicitly
# when building the software. from repository's root directory:
# mkdir build && cmake -DCMAKE_TOOLCHAIN_FILE=$(pwd)/../cmake/msvc.cmake build/
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_VERSION 5.01)
if(opentrack-64bit)
set(CMAKE_SYSTEM_PROCESSOR AMD64)
else()
set(CMAKE_SYSTEM_PROCESSOR x86)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR CMAKE_INSTALL_PREFIX STREQUAL "")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "" FORCE)
endif()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/opentrack-policy.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/opentrack-policy.cmake" NO_POLICY_SCOPE)
endif()
set(CMAKE_C_COMPILER_INIT cl.exe)
set(CMAKE_CXX_COMPILER_INIT cl.exe)
set(CMAKE_ASM_NASM_COMPILER_INIT nasm.exe)
# 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)
set(CMAKE_GENERATOR "Ninja")
#add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
#add_compile_options(-Qvec-report:2)
#add_compile_options(-d2cgsummary)
add_definitions(-D_HAS_EXCEPTIONS=0)
if(DEFINED CMAKE_TOOLCHAIN_FILE)
# ignore cmake warning: Manually-specified variable not used by the project
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}}")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/opentrack-policy.cmake" NO_POLICY_SCOPE)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW CACHE INTERNAL "" FORCE)
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_C_EXTENSIONS FALSE)
set(CMAKE_CXX_EXTENSIONS FALSE)
set(CMAKE_CROSSCOMPILING 0)
function(sets type)
set(i 0)
list(LENGTH ARGN max)
math(EXPR foo "${max} % 2")
if(NOT foo EQUAL 0)
message(FATAL_ERROR "argument count not even")
endif()
while(i LESS max)
list(GET ARGN "${i}" name)
math(EXPR i "${i} + 1")
list(GET ARGN "${i}" value)
math(EXPR i "${i} + 1")
set(${name} "${value}" CACHE "${type}" "" FORCE)
endwhile()
endfunction()
if(CMAKE_PROJECT_NAME STREQUAL "opentrack")
#include("${CMAKE_CURRENT_LIST_DIR}/opentrack-policy.cmake" NO_POLICY_SCOPE)
add_compile_options("-W4")
# C4265: class has virtual functions, but destructor is not virtual
# C4005: macro redefinition
set(warns-error 4265 4005)
foreach(i ${warns-error})
add_compile_options(-w1${i} -we${i})
endforeach()
endif()
if(CMAKE_PROJECT_NAME STREQUAL "QtBase")
set(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING TRUE CACHE BOOL "" FORCE)
set(QT_DEBUG_OPTIMIZATION_FLAGS TRUE CACHE BOOL "" FORCE)
set(QT_USE_DEFAULT_CMAKE_OPTIMIZATION_FLAGS TRUE CACHE BOOL "" FORCE)
set(FEATURE_debug OFF)
set(FEATURE_debug_and_release OFF)
set(FEATURE_force_debug_info ON)
set(FEATURE_ltcg ON)
set(FEATURE_shared ON)
endif()
if(CMAKE_PROJECT_NAME STREQUAL "OpenCV")
set(PARALLEL_ENABLE_PLUGINS FALSE)
set(HIGHGUI_ENABLE_PLUGINS FALSE)
set(VIDEOIO_ENABLE_PLUGINS FALSE)
set(OPENCV_SKIP_MSVC_EXCEPTIONS_FLAG TRUE)
set(OPENCV_DISABLE_THREAD_SUPPORT TRUE)
set(ENABLE_FAST_MATH ON)
set(BUILD_TESTS OFF)
set(BUILD_PERF_TESTS OFF)
set(BUILD_opencv_apps OFF)
set(BUILD_opencv_gapi OFF)
endif()
set(opentrack-simd "SSE2")
if(CMAKE_PROJECT_NAME STREQUAL "onnxruntime")
set(opentrack-simd "AVX")
if(opentrack-no-static-crt)
sets(BOOL
ONNX_USE_MSVC_STATIC_RUNTIME OFF
protobuf_MSVC_STATIC_RUNTIME OFF
)
else()
sets(BOOL
ONNX_USE_MSVC_STATIC_RUNTIME ON
protobuf_MSVC_STATIC_RUNTIME ON
)
endif()
sets(BOOL
onnxruntime_USE_AVX ON
onnxruntime_USE_AVX2 OFF
onnxruntime_USE_AVX512 OFF
onnxruntime_BUILD_BENCHMARKS OFF
onnxruntime_BUILD_FOR_NATIVE_MACHINE OFF
onnxruntime_BUILD_SHARED_LIB ON
onnxruntime_BUILD_UNIT_TESTS OFF
protobuf_BUILD_EXAMPLES OFF
protobuf_BUILD_SHARED_LIBS OFF
ONNX_BUILD_BENCHMARKS OFF
ONNX_BUILD_TESTS OFF
ONNX_DISABLE_EXCEPTIONS OFF # important!
ONNX_GEN_PB_TYPE_STUBS OFF
onnxruntime_DISABLE_CONTRIB_OPS ON
BUILD_TESTING OFF
)
elseif(opentrack-64bit)
set(opentrack-simd "AVX")
endif()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_link_options(-cgthreads:1)
set(_CFLAGS "-diagnostics:caret -Zc:inline -Zc:preprocessor -wd4117 -Zi -Zf -Zo -bigobj -cgthreads1 -vd0 -permissive-")
if(NOT opentrack-no-static-crt)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE INTERNAL "" FORCE)
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL" CACHE INTERNAL "" FORCE)
endif()
set(_CXXFLAGS "${_CFLAGS} -Zc:throwingNew -Zc:lambda")
set(_CFLAGS_RELEASE "-O2 -Oit -Oy- -Ob3 -fp:fast -GS- -GF -GL -Gw -Gy")
if(NOT opentrack-simd STREQUAL "")
set(_CFLAGS_RELEASE "${_CFLAGS_RELEASE} -arch:${opentrack-simd}")
endif()
set(_CFLAGS_DEBUG "-guard:cf -MTd -Gs0 -RTCs")
set(_CXXFLAGS_RELEASE "${_CFLAGS_RELEASE}")
set(_CXXFLAGS_DEBUG "${_CFLAGS_DEBUG}")
set(_LDFLAGS "-WX")
set(_LDFLAGS_RELEASE "-OPT:REF,ICF=10 -LTCG -DEBUG:FULL")
set(_LDFLAGS_DEBUG "-DEBUG:FULL")
set(_LDFLAGS_STATIC "-WX")
set(_LDFLAGS_STATIC_RELEASE "-LTCG")
set(_LDFLAGS_STATIC_DEBUG "")
set(CMAKE_BUILD_TYPE_INIT "RELEASE" CACHE INTERNAL "")
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "" FORCE)
if (NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "DEBUG")
set(CMAKE_BUILD_TYPE "RELEASE" CACHE STRING "" FORCE)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS RELEASE DEBUG)
foreach(k "" "_${CMAKE_BUILD_TYPE}")
set("FLAGS_CXX${k}" "" CACHE STRING "More CMAKE_CXX_FLAGS${k}")
#set("FLAGS_C${k}" "" CACHE STRING "More CMAKE_C_FLAGS${k} (almost never used)")
set("FLAGS_LD${k}" "" CACHE STRING "More CMAKE_(SHARED|EXE|MODULE)_LINKER_FLAGS${k}")
set("FLAGS_ARCHIVE${k}" "" CACHE STRING "More CMAKE_STATIC_LINKER_FLAGS${k}")
endforeach()
foreach(k "" _DEBUG _RELEASE)
#set(CMAKE_STATIC_LINKER_FLAGS${k} "${CMAKE_STATIC_LINKER_FLAGS${k}} ${_LDFLAGS_STATIC${k}}")
set(CMAKE_STATIC_LINKER_FLAGS${k} "${_LDFLAGS_STATIC${k}} ${FLAGS_ARCHIVE${k}}" CACHE STRING "" FORCE)
endforeach()
foreach(j "" _DEBUG _RELEASE)
foreach(i MODULE EXE SHARED)
#set(CMAKE_${i}_LINKER_FLAGS${j} "${CMAKE_${i}_LINKER_FLAGS${j}} ${_LDFLAGS${j}}")
set(CMAKE_${i}_LINKER_FLAGS${j} "${_LDFLAGS${j}} ${FLAGS_LD${j}}" CACHE STRING "" FORCE)
endforeach()
endforeach()
foreach(j C CXX)
foreach(i "" _DEBUG _RELEASE)
#set(CMAKE_${j}_FLAGS${i} "${CMAKE_${j}_FLAGS${i}} ${_${j}FLAGS${i}}")
set(CMAKE_${j}_FLAGS${i} "${_${j}FLAGS${i}} ${FLAGS_${j}${i}}" CACHE STRING "" FORCE)
endforeach()
endforeach()
|