-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
166 lines (148 loc) · 3.82 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
cmake_minimum_required(VERSION 3.20)
project(prosper)
option(PROSPER_USE_PCH "Use pre-compiled headers" ON)
option(PROSPER_SETUP_DEPENDENCIES "Pull the in-tree dependencies and correct submodule commits" ON)
option(PROSPER_ALWAYS_O2_DEPENDENCIES "Always build dependencies as optimized" ON)
option(PROSPER_MSVC_CRT_LEAK_CHECK "Leak checks on the MSVC CRT" OFF)
option(PROSPER_ALLOCATOR_DEBUG "Debug allocations" OFF)
if(MSVC)
add_compile_options(/MP)
if(PROSPER_ALWAYS_O2_DEPENDENCIES)
# RTC1 (both /RTCs and /RTCu) is incompatible with /O2
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
endif()
if(PROSPER_MSVC_CRT_LEAK_CHECK)
# note that glslang has a leaky glslang_mutex_
add_compile_definitions(_CRTDBG_MAP_ALLOC)
endif() # PROSPER_MSVC_CRT_LEAK_CHECK
endif() # MSVC
if(PROSPER_ALLOCATOR_DEBUG)
add_compile_definitions(WHEELS_ALLOCATION_DEBUG)
endif() # PROSPER_ALLOCATOR_DEBUG
# Set up sub-builds and sources
add_subdirectory(ext)
add_subdirectory(src)
add_subdirectory(res)
if(PROSPER_ALWAYS_O2_DEPENDENCIES)
# Only optimize the dependencies that have a noticeable impact
if(MSVC)
target_compile_options(meshoptimizer PRIVATE "/O2")
target_compile_options(mikktspace PRIVATE "/O2")
else()
target_compile_options(meshoptimizer PRIVATE "-O2")
target_compile_options(mikktspace PRIVATE "-O2")
endif()
endif()
if(LIVEPP_PATH)
set(LIVEPP_DEFINE "LIVEPP_PATH=L\"${LIVEPP_PATH}\"")
endif()
# Set up project targets
add_executable(prosper ${PROSPER_SOURCES} ${PROSPER_INCLUDES})
target_compile_features(prosper
PRIVATE
cxx_std_20
)
if(MSVC)
# From cppbestpractices
target_compile_options(prosper
PRIVATE
/permissive-
/Zc:preprocessor
/W4
/w14242
/w14254
/w14263
/w14265
/w14287
/we4289
/w14296
/w14311
/w14545
/w14546
/w14547
/w14549
/w14555
/w14619
/w14640
/w14826
/w14905
/w14906
/w14928
/wd4201 # GLM in PCH bleeds warnings into prosper sources
)
if(LIVEPP_PATH)
target_link_options(prosper PRIVATE
/FUNCTIONPADMIN
)
endif()
else()
target_compile_options(prosper
PRIVATE
-pedantic
-Wall
-Wextra
-Wunused
-Wno-missing-field-initializers
)
endif() # NOT MSVC
target_include_directories(prosper
PRIVATE
${PROSPER_INCLUDE_DIR}
${LIVEPP_PATH}
)
target_link_libraries(prosper
PRIVATE
cxxopts
cgltf
glfw
glm
imgui
ispc_texcomp
meshoptimizer
mikktspace
shaderc
shared_shader_structs
spirv_headers
stb
tomlcpp
vma
vulkan
wheels
)
if(WIN32)
target_link_libraries(prosper
PRIVATE
Dwmapi
)
endif() # WIN32
target_compile_definitions(prosper
PRIVATE
VULKAN_HPP_DISPATCH_LOADER_DYNAMIC
VULKAN_HPP_NO_STRUCT_CONSTRUCTORS
VULKAN_HPP_NO_SETTERS
VULKAN_HPP_NO_SMART_HANDLE
VULKAN_HPP_NO_SPACESHIP_OPERATOR
VULKAN_HPP_NO_STRING
GLM_FORCE_XYZW_ONLY
GLM_ENABLE_EXPERIMENTAL
${LIVEPP_DEFINE}
# Set up absolute path to resources and binaries
RES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/res/"
BIN_PATH="${CMAKE_CURRENT_BINARY_DIR}/")
if(PROSPER_USE_PCH)
target_precompile_headers(prosper
PRIVATE
[["glm/glm.hpp"]]
[["glm/gtc/type_ptr.hpp"]]
[["glm/gtc/quaternion.hpp"]]
[["chrono"]]
[["filesystem"]]
[["fstream"]]
[["variant"]]
[["functional"]]
[["vulkan/vulkan.hpp"]]
[["vulkan/vulkan_hash.hpp"]]
[["wyhash.h"]]
)
endif() # PROSPER_USE_PCH