/
CMakeLists.txt
384 lines (355 loc) · 10.2 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# Copyright (c) 2019, Arm Limited and Contributors
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 the "License";
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.10)
project(framework LANGUAGES C CXX)
set(FRAMEWORK_FILES
# Header Files
gui.h
stats.h
glsl_compiler.h
spirv_reflection.h
gltf_loader.h
buffer_pool.h
debug_info.h
fence_pool.h
heightmap.h
semaphore_pool.h
resource_binding_state.h
resource_cache.h
resource_record.h
resource_replay.h
vulkan_sample.h
api_vulkan_sample.h
timer.h
camera.h
# Source Files
gui.cpp
stats.cpp
glsl_compiler.cpp
spirv_reflection.cpp
gltf_loader.cpp
debug_info.cpp
buffer_pool.cpp
fence_pool.cpp
heightmap.cpp
semaphore_pool.cpp
resource_binding_state.cpp
resource_cache.cpp
resource_record.cpp
resource_replay.cpp
vulkan_sample.cpp
api_vulkan_sample.cpp
timer.cpp
camera.cpp)
set(COMMON_FILES
# Header Files
common/vk_common.h
common/vk_initializers.h
common/logging.h
common/helpers.h
common/error.h
common/utils.h
# Source Files
common/error.cpp
common/vk_common.cpp
common/utils.cpp)
set(GEOMETRY_FILES
# Header Files
geometry/frustum.h
# Source Files
geometry/frustum.cpp)
set(RENDERING_FILES
# Header files
rendering/pipeline_state.h
rendering/render_context.h
rendering/render_frame.h
rendering/render_pipeline.h
rendering/render_target.h
rendering/subpass.h
# Source files
rendering/pipeline_state.cpp
rendering/render_context.cpp
rendering/render_frame.cpp
rendering/render_pipeline.cpp
rendering/render_target.cpp
rendering/subpass.cpp)
set(RENDERING_SUBPASSES_FILES
# Header files
rendering/subpasses/forward_subpass.h
rendering/subpasses/lighting_subpass.h
rendering/subpasses/geometry_subpass.h
# Source files
rendering/subpasses/forward_subpass.cpp
rendering/subpasses/lighting_subpass.cpp
rendering/subpasses/geometry_subpass.cpp)
set(SCENE_GRAPH_FILES
# Header Files
scene_graph/component.h
scene_graph/node.h
scene_graph/scene.h
scene_graph/script.h
# Source Files
scene_graph/component.cpp
scene_graph/node.cpp
scene_graph/scene.cpp
scene_graph/script.cpp)
set(SCENE_GRAPH_COMPONENT_FILES
# Header Files
scene_graph/components/aabb.h
scene_graph/components/camera.h
scene_graph/components/perspective_camera.h
scene_graph/components/image.h
scene_graph/components/light.h
scene_graph/components/material.h
scene_graph/components/mesh.h
scene_graph/components/pbr_material.h
scene_graph/components/sampler.h
scene_graph/components/sub_mesh.h
scene_graph/components/texture.h
scene_graph/components/transform.h
scene_graph/components/image/astc.h
scene_graph/components/image/ktx.h
scene_graph/components/image/stb.h
# Source Files
scene_graph/components/aabb.cpp
scene_graph/components/camera.cpp
scene_graph/components/perspective_camera.cpp
scene_graph/components/image.cpp
scene_graph/components/light.cpp
scene_graph/components/material.cpp
scene_graph/components/mesh.cpp
scene_graph/components/pbr_material.cpp
scene_graph/components/sampler.cpp
scene_graph/components/sub_mesh.cpp
scene_graph/components/texture.cpp
scene_graph/components/transform.cpp
scene_graph/components/image/astc.cpp
scene_graph/components/image/ktx.cpp
scene_graph/components/image/stb.cpp)
set(SCENE_GRAPH_SCRIPTS_FILES
# Header Files
scene_graph/scripts/free_camera.h
scene_graph/scripts/node_animation.h
# Source Files
scene_graph/scripts/free_camera.cpp
scene_graph/scripts/node_animation.cpp)
set(CORE_FILES
# Header Files
core/instance.h
core/device.h
core/shader_module.h
core/pipeline_layout.h
core/pipeline.h
core/descriptor_set_layout.h
core/descriptor_pool.h
core/descriptor_set.h
core/queue.h
core/command_pool.h
core/swapchain.h
core/command_buffer.h
core/buffer.h
core/image.h
core/image_view.h
core/instance.h
core/sampler.h
core/framebuffer.h
core/render_pass.h
# Source Files
core/instance.cpp
core/device.cpp
core/image.cpp
core/shader_module.cpp
core/pipeline_layout.cpp
core/pipeline.cpp
core/descriptor_set_layout.cpp
core/descriptor_pool.cpp
core/descriptor_set.cpp
core/queue.cpp
core/command_pool.cpp
core/swapchain.cpp
core/command_buffer.cpp
core/buffer.cpp
core/image.cpp
core/image_view.cpp
core/instance.cpp
core/sampler.cpp
core/framebuffer.cpp
core/render_pass.cpp)
set(UTIL_FILES
# Header Files
utils/graph/graph.h
utils/graph/nodes/framework.h
utils/graph/nodes/scene.h
utils/graph/node.h
utils/graphs.h
utils/strings.h
# Source Files
utils/graph/graph.cpp
utils/graph/nodes/framework.cpp
utils/graph/nodes/scene.cpp
utils/graph/node.cpp
utils/graphs.cpp
utils/strings.cpp)
set(PLATFORM_FILES
# Header Files
platform/application.h
platform/options.h
platform/platform.h
platform/window.h
platform/headless_window.h
platform/glfw_window.h
platform/filesystem.h
platform/input_events.h
platform/configuration.h
# Source Files
platform/application.cpp
platform/options.cpp
platform/platform.cpp
platform/window.cpp
platform/headless_window.cpp
platform/filesystem.cpp
platform/input_events.cpp
platform/configuration.cpp)
set(ANDROID_FILES
# Header Files
platform/android/android_platform.h
platform/android/android_window.h
# Source Files
platform/android/android_platform.cpp
platform/android/android_window.cpp)
set(WINDOWS_FILES
# Header Files
platform/windows/windows_platform.h
# Source Files
platform/windows/windows_platform.cpp)
set(UNIX_FILES
# Header Files
platform/unix/unix_platform.h
# Source Files
platform/unix/unix_platform.cpp)
set(GLFW_FILES
# Header Files
platform/glfw_window.h
# Source Files
platform/glfw_window.cpp)
set(LINUX_D2D_FILES
# Header Files
platform/unix/unix_d2d_platform.h
platform/unix/direct_window.h
# Source Files
platform/unix/unix_d2d_platform.cpp
platform/unix/direct_window.cpp)
source_group("\\" FILES ${FRAMEWORK_FILES})
source_group("common\\" FILES ${COMMON_FILES})
source_group("platform\\" FILES ${PLATFORM_FILES})
source_group("platform\\" FILES ${GLFW_FILES})
source_group("platform\\windows" FILES ${WINDOWS_FILES})
source_group("platform\\android" FILES ${ANDROID_FILES})
source_group("platform\\unix" FILES ${UNIX_FILES})
source_group("platform\\unix" FILES ${LINUX_D2D_FILES})
source_group("core\\" FILES ${CORE_FILES})
source_group("geometry\\" FILES ${GEOMETRY_FILES})
source_group("rendering\\" FILES ${RENDERING_FILES})
source_group("rendering\\subpasses" FILES ${RENDERING_SUBPASSES_FILES})
source_group("scene_graph\\" FILES ${SCENE_GRAPH_FILES})
source_group("scene_graph\\components\\" FILES ${SCENE_GRAPH_COMPONENT_FILES})
source_group("scene_graph\\scripts\\" FILES ${SCENE_GRAPH_SCRIPTS_FILES})
source_group("utils\\" FILES ${UTIL_FILES})
set(PROJECT_FILES
${PLATFORM_FILES}
${COMMON_FILES}
${FRAMEWORK_FILES}
${CORE_FILES}
${GEOMETRY_FILES}
${RENDERING_FILES}
${RENDERING_SUBPASSES_FILES}
${SCENE_GRAPH_FILES}
${SCENE_GRAPH_COMPONENT_FILES}
${SCENE_GRAPH_SCRIPTS_FILES}
${UTIL_FILES})
# Add files based on platform
if(VKB_DIRECT_2_DISPLAY)
message(STATUS "VKB_DIRECT_2_DISPLAY enabled, forcing D2D support")
list(APPEND PROJECT_FILES ${LINUX_D2D_FILES})
else()
# Add files based on platform
if(ANDROID)
list(APPEND PROJECT_FILES ${ANDROID_FILES})
message(STATUS "Android platform detected")
else()
if(DIRECT_TO_DISPLAY)
list(APPEND PROJECT_FILES ${LINUX_D2D_FILES})
message(STATUS "Unix d2d platform detected")
else()
list(APPEND PROJECT_FILES ${GLFW_FILES})
if(WIN32)
list(APPEND PROJECT_FILES ${WINDOWS_FILES})
message(STATUS "Windows platform detected")
else()
list(APPEND PROJECT_FILES ${UNIX_FILES})
message(STATUS "Unix platform detected")
endif()
endif()
endif()
endif()
# Pre compiled headers
vulkan_samples_pch(PROJECT_FILES pch.cpp)
add_library(${PROJECT_NAME} STATIC ${PROJECT_FILES})
# compiler flags based on compiler type
if(NOT MSVC)
target_compile_options(${PROJECT_NAME} PUBLIC -fexceptions)
endif()
if(${VKB_VALIDATION_LAYERS})
target_compile_definitions(${PROJECT_NAME} PUBLIC VKB_VALIDATION_LAYERS)
endif()
if(${VKB_WARNINGS_AS_ERRORS})
message(STATUS "Warnings as Errors Enabled")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(${PROJECT_NAME} PRIVATE -Werror)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /W3 /WX /MP)
endif()
endif()
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
# Link third party libraries
target_link_libraries(${PROJECT_NAME}
volk
ktx
stb
astc
imgui
tinygltf
glm
glslang
SPIRV
vma
hwcpipe
spirv-cross-glsl
glslang-default-resource-limits
spdlog
ctpl
docopt)
# Link platform specific libraries
if(ANDROID)
target_link_libraries(${PROJECT_NAME} log android native_app_glue)
else()
if (DIRECT_TO_DISPLAY)
target_link_libraries(${PROJECT_NAME} dl)
else()
target_link_libraries(${PROJECT_NAME} glfw)
endif()
endif()