-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
257 lines (212 loc) · 8.17 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
250
251
252
253
254
255
256
257
CMAKE_MINIMUM_REQUIRED(VERSION 3.7)
PROJECT(snuffbox-mantis C CXX)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET_PROPERTY(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "cmake-targets")
SET(SNUFF_ENCRYPTION_KEY "snuffbox-mantis" CACHE STRING "Specifies the encryption key used during data encryption for this instance of the engine")
SET(SNUFF_DEFAULT_PORT "8888" CACHE STRING "Specifies the default port for the logging connection to use")
SET(SNUFF_LOG_TIMEOUT "10" CACHE STRING "Specifies the default timeout in seconds for the logging connection to use")
SET(SNUFF_LOG_BUFFERSIZE "512" CACHE STRING "Specifies the maximum buffer size for the logging connection to use per socket")
SET(SNUFF_LOG_DEFAULT_MAXLINES "5000" CACHE STRING "Specifies the default for the maximum number of lines in the console")
OPTION(SNUFF_USE_OGL "Forces OpenGL or Vulkan on Windows")
SET(SNUFF_DIRECTX_VERSION "11" CACHE STRING "Specifies the DirectX version to use")
SET(SNUFF_OGL_VERSION "ogl" CACHE STRING "Specifies whether to use OpenGL or Vulkan")
SET_PROPERTY(CACHE "SNUFF_DIRECTX_VERSION" PROPERTY STRINGS "11" "12")
SET_PROPERTY(CACHE "SNUFF_OGL_VERSION" PROPERTY STRINGS "ogl" "vulkan")
SET(SNUFF_RELOAD_AFTER "100" CACHE STRING "Specifies after how many milliseconds the file watcher should reload")
OPTION(SNUFF_BUILD_TEST "Build the test environment project 'snuffbox-test'")
OPTION(SNUFF_JAVASCRIPT "Should V8 (JavaScript) be enabled for this build?")
IF (SNUFF_USE_OGL AND SNUFF_OGL_VERSION MATCHES "vulkan")
ADD_DEFINITIONS("/DSNUFF_USE_VULKAN")
SET (SNUFF_RENDERER_NAME "Vulkan")
ELSEIF (SNUFF_USE_OGL)
ADD_DEFINITIONS("/DSNUFF_USE_OGL")
SET (SNUFF_RENDERER_NAME "OpenGL")
ELSEIF (NOT SNUFF_USE_OGL AND WIN32)
IF (SNUFF_DIRECTX_VERSION MATCHES "11")
ADD_DEFINITIONS("/DSNUFF_USE_D3D11")
ELSEIF (SNUFF_DIRECTX_VERSION MATCHES "12")
ADD_DEFINITIONS("/DSNUFF_USE_D3D12")
ENDIF ()
SET (SNUFF_RENDERER_NAME "Direct3D ${SNUFF_DIRECTX_VERSION}")
ENDIF ()
SET (SNUFF_WINDOW_TITLE "Snuffbox (${SNUFF_RENDERER_NAME})")
ADD_DEFINITIONS("/DSNUFF_WINDOW_TITLE=\"${SNUFF_WINDOW_TITLE}\"")
IF (WIN32)
FOREACH(FLAG CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL)
IF (${FLAG} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${FLAG} "${${FLAG}}")
ENDIF ()
IF (${FLAG} MATCHES "/MDd")
STRING(REGEX REPLACE "/MDd" "/MTd" ${FLAG} "${${FLAG}}")
ENDIF ()
ENDFOREACH()
ENDIF ()
SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
$<$<CONFIG:Debug>:SNUFF_DEBUG>
$<$<CONFIG:Release>:SNUFF_RELEASE>
$<$<CONFIG:RelWithDebInfo>:SNUFF_RELEASE>
$<$<CONFIG:MinSizeRel>:SNUFF_RELEASE>
)
IF (WIN32)
ADD_DEFINITIONS("/DSNUFF_WIN32")
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
ADD_DEFINITIONS("/DSNUFF_LINUX")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -fno-rtti")
ENDIF ()
ADD_DEFINITIONS("/DSNUFF_ENCRYPTION_KEY=\"${SNUFF_ENCRYPTION_KEY}\"")
ADD_DEFINITIONS("/DSNUFF_DEFAULT_PORT=${SNUFF_DEFAULT_PORT}")
ADD_DEFINITIONS("/DSNUFF_LOG_TIMEOUT=${SNUFF_LOG_TIMEOUT}")
ADD_DEFINITIONS("/DSNUFF_LOG_BUFFERSIZE=${SNUFF_LOG_BUFFERSIZE}")
ADD_DEFINITIONS("/DSNUFF_LOG_DEFAULT_MAXLINES=${SNUFF_LOG_DEFAULT_MAXLINES}")
ADD_DEFINITIONS("/DSNUFF_RELOAD_AFTER=${SNUFF_RELOAD_AFTER}")
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}")
FIND_PACKAGE(EASTL REQUIRED)
ADD_SUBDIRECTORY("${EASTL_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/deps/eastl")
INCLUDE_DIRECTORIES("${EASTL_DIR}/include")
SET(GLFW_BUILD_DOCS OFF CACHE BOOL "Build GLFW docs")
SET(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "Build GLFW examples")
SET(GLFW_BUILD_TESTS OFF CACHE BOOL "Build GLFW tests")
SET(GLFW_INSTALL OFF CACHE BOOL "Install GLFW")
FIND_PACKAGE(GLFWSource REQUIRED)
ADD_SUBDIRECTORY("${GLFW_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/deps/glfw")
FIND_PACKAGE(GLM REQUIRED)
SET (GLM_INSTALL_ENABLE OFF CACHE BOOL "Enable GLM install target")
ADD_SUBDIRECTORY("${GLM_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/deps/glm")
INCLUDE_DIRECTORIES(${GLM_ROOT_DIR})
IF (WIN32)
SET(wxWidgets_ROOT_DIR "deps/wxWidgets" CACHE PATH "The root directory of wxWidgets")
ENDIF ()
SET(wxWidgets_USE_STATIC ON)
FIND_PACKAGE(wxWidgets REQUIRED COMPONENTS core base richtext html qa xrc propgrid aui adv xml)
IF (WIN32)
INCLUDE_DIRECTORIES("${wxWidgets_ROOT_DIR}/include")
ELSE ()
INCLUDE_DIRECTORIES("${wxWidgets_INCLUDE_DIRS}")
ENDIF ()
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
EXECUTE_PROCESS(COMMAND wx-config --cxxflags OUTPUT_VARIABLE WX_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WX_FLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WX_FLAGS}")
ENDIF ()
IF (WIN32)
INCLUDE_DIRECTORIES(
$<$<CONFIG:Debug>:${wxWidgets_LIB_DIR}/mswud>
$<$<CONFIG:Release>:${wxWidgets_LIB_DIR}/mswu>
$<$<CONFIG:RelWithDebInfo>:${wxWidgets_LIB_DIR}/mswu>
$<$<CONFIG:MinSizeRel>:${wxWidgets_LIB_DIR}/mswu>
)
ENDIF ()
SET(BUILD_TESTING OFF CACHE BOOL "Build SpirVCross/GLSLang tests")
FIND_PACKAGE(SpirVCross REQUIRED)
ADD_SUBDIRECTORY("${SpirVCross_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/deps/spirv-cross")
INCLUDE_DIRECTORIES(${SpirVCross_INCLUDE_DIRECTORIES})
FIND_PACKAGE(GLSLang REQUIRED)
ADD_SUBDIRECTORY("${GLSLang_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/deps/glslang")
INCLUDE_DIRECTORIES(${GLSLang_INCLUDE_DIRECTORIES})
IF (SNUFF_JAVASCRIPT)
ADD_DEFINITIONS("/DSNUFF_JAVASCRIPT")
ADD_DEFINITIONS("/DV8_IMMINENT_DEPRECATION_WARNINGS")
FIND_PACKAGE(V8 REQUIRED)
INCLUDE_DIRECTORIES(${V8_INCLUDE_DIR})
ENDIF ()
ADD_SUBDIRECTORY("snuffbox-logging")
ADD_SUBDIRECTORY("snuffbox-console")
ADD_SUBDIRECTORY("snuffbox-compilers")
ADD_SUBDIRECTORY("snuffbox-builder")
ADD_SUBDIRECTORY("snuffbox-graphics")
ADD_SUBDIRECTORY("snuffbox-engine")
IF (SNUFF_BUILD_TEST)
ADD_SUBDIRECTORY("snuffbox-test")
SET_TARGET_PROPERTIES(snuffbox-test PROPERTIES FOLDER "snuffbox-mantis")
ENDIF ()
IF (SNUFF_JAVASCRIPT)
ADD_SUBDIRECTORY("snuffbox-javascript")
SET_TARGET_PROPERTIES(snuffbox-javascript PROPERTIES FOLDER "snuffbox-mantis")
ENDIF ()
SET (GLFWTests
"clipboard"
"cursor"
"empty"
"events"
"gamma"
"glfwinfo"
"icon"
"iconify"
"joysticks"
"monitors"
"msaa"
"reopen"
"sharing"
"tearing"
"threads"
"timeout"
"title"
"windows"
)
SET (GLFWExamples
"boing"
"gears"
"heightmap"
"particles"
"simple"
"splitview"
"wave"
)
SET_TARGET_PROPERTIES(glfw PROPERTIES FOLDER "deps/glfw3")
IF (GLFW_INSTALL)
SET_TARGET_PROPERTIES(uninstall PROPERTIES FOLDER "deps/glfw3")
ENDIF ()
IF (GLFW_BUILD_EXAMPLES)
FOREACH (GLFWName ${GLFWExamples})
SET_TARGET_PROPERTIES(${GLFWName} PROPERTIES FOLDER "deps/glfw3/examples")
ENDFOREACH ()
ENDIF ()
IF (GLFW_BUILD_TESTS)
FOREACH (GLFWName ${GLFWTests})
SET_TARGET_PROPERTIES(${GLFWName} PROPERTIES FOLDER "deps/glfw3/tests")
ENDFOREACH ()
ENDIF ()
SET (SpirVCrossProjects
"spirv-cross"
"spirv-cross-core"
"spirv-cross-cpp"
"spirv-cross-glsl"
"spirv-cross-hlsl"
"spirv-cross-msl"
)
FOREACH (SpirVCrossName ${SpirVCrossProjects})
SET_TARGET_PROPERTIES(${SpirVCrossName} PROPERTIES FOLDER "deps/spirv-cross")
ENDFOREACH ()
SET (GLSLangProjects
"glslang"
"glslang-default-resource-limits"
"OGLCompiler"
"OSDependent"
"SPIRV"
"SPVRemapper"
"HLSL"
"glslangValidator"
"spirv-remap"
)
FOREACH (GLSLangName ${GLSLangProjects})
SET_TARGET_PROPERTIES(${GLSLangName} PROPERTIES FOLDER "deps/glslang")
ENDFOREACH ()
SET_TARGET_PROPERTIES(EASTL PROPERTIES FOLDER "deps/eastl")
SET_TARGET_PROPERTIES(EABase_ide PROPERTIES FOLDER "deps/eastl")
SET_TARGET_PROPERTIES(glm_dummy PROPERTIES FOLDER "deps/glm")
SET_TARGET_PROPERTIES(snuffbox-logging PROPERTIES FOLDER "snuffbox-mantis")
SET_TARGET_PROPERTIES(snuffbox-console PROPERTIES FOLDER "snuffbox-mantis")
SET_TARGET_PROPERTIES(snuffbox-compilers PROPERTIES FOLDER "snuffbox-mantis")
SET_TARGET_PROPERTIES(snuffbox-builder PROPERTIES FOLDER "snuffbox-mantis")
SET_TARGET_PROPERTIES(snuffbox-graphics PROPERTIES FOLDER "snuffbox-mantis")
SET_TARGET_PROPERTIES(snuffbox-engine PROPERTIES FOLDER "snuffbox-mantis")