-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
249 lines (188 loc) · 6.02 KB
/
CMakeLists.txt
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
cmake_minimum_required(VERSION 3.11)
project(Arcana)
# ===============================================
# Global settings
# require C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# folders for visual studio
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# ==============================================================================
# Set bin dir
if(MSVC)
set(BIN_DIR ${CMAKE_SOURCE_DIR}/bin)
elseif(CMAKE_BUILD_TYPE STREQUAL "")
set(BIN_DIR ${CMAKE_SOURCE_DIR}/bin/Default)
else()
set(BIN_DIR ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BIN_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${BIN_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BIN_DIR})
# ===============================================
# Dependencies
## Core
# std replacement
add_subdirectory(extern/clean-core)
# ranges and collections
add_subdirectory(extern/clean-ranges)
# math library
add_subdirectory(extern/typed-geometry)
# tracing and profiling
add_subdirectory(extern/ctracer)
# reflection and introspection
add_subdirectory(extern/reflector)
# logging
add_subdirectory(extern/rich-log)
# multithreading
add_subdirectory(extern/task-dispatcher)
# resources
add_subdirectory(extern/resource-system)
# serialization
add_subdirectory(extern/babel-serializer)
## Main
# half-edge meshes
add_subdirectory(extern/polymesh)
# SDL2
add_subdirectory(extern/sdl2-dev)
# phantasm hardware interface
add_subdirectory(extern/phantasm-hardware-interface)
# shader compiler
set(DXCW_BUILD_STANDALONE ON CACHE BOOL "")
add_subdirectory(extern/dxc-wrapper)
# texture processing
add_subdirectory(extern/texture-processor)
# phantasm renderer
add_subdirectory(extern/phantasm-renderer)
# UI
add_subdirectory(extern/structured-interface)
# TODO: other libs
# testing, benchmarking, apps
add_subdirectory(extern/nexus)
## Incubator
# provisional code
add_subdirectory(extern/arcana-incubator)
# ===============================================
# Testing options
option(ARC_ENABLE_ASAN "if true, enables clang/MSVC address sanitizer" OFF)
option(ARC_ENABLE_MSAN "if true, enables clang/MSVC memory sanitizer" OFF)
option(ARC_ENABLE_UBSAN "if true, enables clang/MSVC undefined behaviour sanitizer" OFF)
option(ARC_ENABLE_TSAN "if true, enables clang/MSVC thread sanitizer" OFF)
if (ARC_ENABLE_ASAN AND ARC_ENABLE_TSAN)
message(FATAL_ERROR "Can only enable one of TSan or ASan at a time")
endif()
if (ARC_ENABLE_ASAN AND ARC_ENABLE_MSAN)
message(FATAL_ERROR "Can only enable one of ASan or MSan at a time")
endif()
option(ARC_DISABLE_EXCEPTIONS "Set compiler flags to disable exception handling" OFF)
option(ARC_DISABLE_RTTI "Set compiler flags to disable RTTI" OFF)
option(ARC_ENABLE_AVX2 "Set compiler flags to enable AVX2 instructions (and older ones included by it)" OFF)
# ===============================================
# Compile flags
set(COMMON_COMPILER_FLAGS "")
set(COMMON_LINKER_FLAGS "")
if (MSVC)
list(APPEND COMMON_COMPILER_FLAGS
/MP
)
if (ARC_ENABLE_AVX2)
list(APPEND COMMON_COMPILER_FLAGS
/arch:AVX2
)
endif()
if (ARC_DISABLE_EXCEPTIONS)
string(REPLACE "/EHsc" "/EHs-c- /D _HAS_EXCEPTIONS=0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
if (ARC_DISABLE_RTTI)
string(REPLACE "/GR" "/GR-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
else()
list(APPEND COMMON_COMPILER_FLAGS
-Wall
-Wno-unused-variable
)
if (ARC_ENABLE_AVX2)
list(APPEND COMMON_COMPILER_FLAGS
-mavx2
)
endif()
if (ARC_DISABLE_EXCEPTIONS)
list(APPEND COMMON_COMPILER_FLAGS -fno-exceptions)
endif()
if (ARC_DISABLE_RTTI)
list(APPEND COMMON_COMPILER_FLAGS -fno-rtti)
endif()
if (ARC_ENABLE_ASAN OR ARC_ENABLE_TSAN OR ARC_ENABLE_MSAN OR ARC_ENABLE_UBSAN)
list(APPEND COMMON_COMPILER_FLAGS -fno-omit-frame-pointer -g)
list(APPEND COMMON_LINKER_FLAGS -fno-omit-frame-pointer -g)
endif()
if (ARC_ENABLE_ASAN)
list(APPEND COMMON_COMPILER_FLAGS -fsanitize=address)
list(APPEND COMMON_LINKER_FLAGS -fsanitize=address)
endif()
if (ARC_ENABLE_TSAN)
list(APPEND COMMON_COMPILER_FLAGS -fsanitize=thread)
list(APPEND COMMON_LINKER_FLAGS -fsanitize=thread)
endif()
if (ARC_ENABLE_MSAN)
list(APPEND COMMON_COMPILER_FLAGS -fsanitize=memory)
list(APPEND COMMON_LINKER_FLAGS -fsanitize=memory)
endif()
if (ARC_ENABLE_UBSAN)
list(APPEND COMMON_COMPILER_FLAGS
-fsanitize=undefined
-fno-sanitize-recover=all
-fno-sanitize=alignment,vptr
)
list(APPEND COMMON_LINKER_FLAGS
-fsanitize=undefined
-fno-sanitize-recover=all
-fno-sanitize=alignment,vptr
)
endif()
endif()
# ===============================================
# Tests and samples
function(add_arcana_test TEST_NAME SOURCES)
# create target
add_executable(${TEST_NAME} ${SOURCES})
# set compiler flags
target_compile_options(${TEST_NAME} PUBLIC ${COMMON_COMPILER_FLAGS})
# set linker flags, make nexus available
target_link_libraries(${TEST_NAME} PUBLIC nexus ${COMMON_LINKER_FLAGS})
# move into tests folder
set_property(TARGET ${TEST_NAME} PROPERTY FOLDER "Tests")
endfunction()
# register samples and tests
add_subdirectory(tests)
# TODO: samples
# ===============================================
# Folder grouping
foreach(TARGET_NAME
polymesh
typed-geometry
ctracer
clean-core
nexus
reflector
phantasm-renderer
rich-log
task-dispatcher
structured-interface
arcana-incubator
dxc-wrapper
dxc-wrap
resource-system
clean-ranges
phantasm-hardware-interface
babel-serializer
texture-processor
)
set_property(TARGET ${TARGET_NAME} PROPERTY FOLDER "Extern")
endforeach()
foreach(TARGET_NAME
dxc-wrapper-standalone
)
set_property(TARGET ${TARGET_NAME} PROPERTY FOLDER "Tools")
endforeach()