-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
483 lines (426 loc) · 15.2 KB
/
CMakeLists.txt
File metadata and controls
483 lines (426 loc) · 15.2 KB
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# collect all the headers in the source directory
file(GLOB HEADERS ${VSG_SOURCE_DIR}/include/vsg/*.h ${VSG_SOURCE_DIR}/include/vsg/*/*.h)
# for out of source builds collect all the auto-generated headers in the build directory
if (NOT (${VSG_SOURCE_DIR} STREQUAL ${VSG_BINARY_DIR}))
file(GLOB AUTOGENERATED_HEADERS ${VSG_BINARY_DIR}/include/vsg/*.h ${VSG_BINARY_DIR}/include/vsg/*/*.h)
set(HEADERS ${HEADERS} ${AUTOGENERATED_HEADERS})
endif()
# set up the source files explicitly.
set(SOURCES
core/MipmapLayout.cpp
core/Allocator.cpp
core/IntrusiveAllocator.cpp
core/Auxiliary.cpp
core/ConstVisitor.cpp
core/Data.cpp
core/External.cpp
core/MemorySlots.cpp
core/Object.cpp
core/Objects.cpp
core/Visitor.cpp
core/Version.cpp
maths/common.cpp
maths/maths_transform.cpp
nodes/Group.cpp
nodes/Geometry.cpp
nodes/Node.cpp
nodes/QuadGroup.cpp
nodes/CullGroup.cpp
nodes/CullNode.cpp
nodes/LOD.cpp
nodes/PagedLOD.cpp
nodes/AbsoluteTransform.cpp
nodes/MatrixTransform.cpp
nodes/CoordinateFrame.cpp
nodes/Transform.cpp
nodes/VertexDraw.cpp
nodes/VertexIndexDraw.cpp
nodes/DepthSorted.cpp
nodes/Layer.cpp
nodes/Bin.cpp
nodes/Switch.cpp
nodes/StateGroup.cpp
nodes/TileDatabase.cpp
nodes/InstrumentationNode.cpp
nodes/RegionOfInterest.cpp
nodes/InstanceNode.cpp
nodes/InstanceDraw.cpp
nodes/InstanceDrawIndexed.cpp
lighting/Light.cpp
lighting/AmbientLight.cpp
lighting/DirectionalLight.cpp
lighting/PointLight.cpp
lighting/SpotLight.cpp
lighting/ShadowSettings.cpp
lighting/HardShadows.cpp
lighting/SoftShadows.cpp
lighting/PercentageCloserSoftShadows.cpp
commands/BindIndexBuffer.cpp
commands/BindVertexBuffers.cpp
commands/Commands.cpp
commands/BlitImage.cpp
commands/CopyImage.cpp
commands/CopyImageToBuffer.cpp
commands/CopyAndReleaseBuffer.cpp
commands/CopyAndReleaseImage.cpp
commands/ClearAttachments.cpp
commands/ClearImage.cpp
commands/PipelineBarrier.cpp
commands/Event.cpp
commands/NextSubPass.cpp
commands/Dispatch.cpp
commands/Draw.cpp
commands/DrawIndirect.cpp
commands/DrawIndexed.cpp
commands/DrawIndexedIndirect.cpp
commands/SetDepthBias.cpp
commands/SetLineWidth.cpp
commands/SetScissor.cpp
commands/SetViewport.cpp
commands/SetPrimitiveTopology.cpp
commands/ResolveImage.cpp
commands/ResetQueryPool.cpp
commands/WriteTimestamp.cpp
commands/BeginQuery.cpp
commands/EndQuery.cpp
commands/CopyQueryPoolResults.cpp
commands/ExecuteCommands.cpp
commands/CopyImageViewToWindow.cpp
state/ArrayState.cpp
state/BindDescriptorSet.cpp
state/Buffer.cpp
state/BufferInfo.cpp
state/BufferView.cpp
state/ComputePipeline.cpp
state/DescriptorSet.cpp
state/GraphicsPipeline.cpp
state/Descriptor.cpp
state/DescriptorBuffer.cpp
state/DescriptorImage.cpp
state/DescriptorTexelBufferView.cpp
state/DescriptorSetLayout.cpp
state/ShaderModule.cpp
state/ShaderStage.cpp
state/PipelineLayout.cpp
state/Sampler.cpp
state/ResourceHints.cpp
state/StateCommand.cpp
state/StateSwitch.cpp
state/Image.cpp
state/ImageInfo.cpp
state/ImageView.cpp
state/VertexInputState.cpp
state/InputAssemblyState.cpp
state/TessellationState.cpp
state/ViewportState.cpp
state/RasterizationState.cpp
state/MultisampleState.cpp
state/DepthStencilState.cpp
state/ColorBlendState.cpp
state/DynamicState.cpp
state/ViewDependentState.cpp
state/QueryPool.cpp
state/PushConstants.cpp
io/convert_utf.cpp
io/FileSystem.cpp
io/AsciiInput.cpp
io/DatabasePager.cpp
io/AsciiOutput.cpp
io/BinaryInput.cpp
io/BinaryOutput.cpp
io/Input.cpp
io/Logger.cpp
io/Output.cpp
io/Options.cpp
io/ObjectFactory.cpp
io/Path.cpp
io/ReaderWriter.cpp
io/VSG.cpp
io/glsl.cpp
io/json.cpp
io/JSONParser.cpp
io/spirv.cpp
io/tile.cpp
io/txt.cpp
io/read.cpp
io/write.cpp
io/mem_stream.cpp
text/CpuLayoutTechnique.cpp
text/GpuLayoutTechnique.cpp
text/Font.cpp
text/StandardLayout.cpp
text/Text.cpp
text/TextGroup.cpp
threading/Affinity.cpp
threading/OperationThreads.cpp
threading/DeleteQueue.cpp
app/Camera.cpp
app/CompileManager.cpp
app/EllipsoidModel.cpp
app/Viewer.cpp
app/Window.cpp
app/WindowAdapter.cpp
app/WindowTraits.cpp
app/Trackball.cpp
app/CommandGraph.cpp
app/SecondaryCommandGraph.cpp
app/RenderGraph.cpp
app/Presentation.cpp
app/RecordAndSubmitTask.cpp
app/TransferTask.cpp
app/WindowResizeHandler.cpp
app/View.cpp
app/ViewMatrix.cpp
app/ProjectionMatrix.cpp
app/UpdateOperations.cpp
app/RecordTraversal.cpp
app/CompileTraversal.cpp
raytracing/AccelerationGeometry.cpp
raytracing/AccelerationStructure.cpp
raytracing/BottomLevelAccelerationStructure.cpp
raytracing/BuildAccelerationStructureTraversal.cpp
raytracing/DescriptorAccelerationStructure.cpp
raytracing/RayTracingPipeline.cpp
raytracing/RayTracingShaderGroup.cpp
raytracing/TopLevelAccelerationStructure.cpp
raytracing/TraceRays.cpp
meshshaders/DrawMeshTasks.cpp
meshshaders/DrawMeshTasksIndirect.cpp
meshshaders/DrawMeshTasksIndirectCount.cpp
animation/Animation.cpp
animation/AnimationGroup.cpp
animation/AnimationManager.cpp
animation/CameraAnimationHandler.cpp
animation/FindAnimations.cpp
animation/Joint.cpp
animation/JointSampler.cpp
animation/MorphSampler.cpp
animation/CameraSampler.cpp
animation/TransformSampler.cpp
ui/UIEvent.cpp
ui/ApplicationEvent.cpp
ui/KeyEvent.cpp
ui/TouchEvent.cpp
ui/PointerEvent.cpp
ui/ScrollWheelEvent.cpp
ui/WindowEvent.cpp
ui/RecordEvents.cpp
ui/CollectEvents.cpp
ui/ShiftEventTime.cpp
ui/PlayEvents.cpp
ui/PrintEvents.cpp
ui/Keyboard.cpp
vk/CommandBuffer.cpp
vk/CommandPool.cpp
vk/Context.cpp
vk/DescriptorPool.cpp
vk/DescriptorPools.cpp
vk/Device.cpp
vk/DeviceFeatures.cpp
vk/DeviceMemory.cpp
vk/DeviceExtensions.cpp
vk/Fence.cpp
vk/Framebuffer.cpp
vk/Instance.cpp
vk/InstanceExtensions.cpp
vk/MemoryBufferPools.cpp
vk/PhysicalDevice.cpp
vk/Queue.cpp
vk/RenderPass.cpp
vk/Semaphore.cpp
vk/Surface.cpp
vk/Swapchain.cpp
vk/ResourceRequirements.cpp
vk/State.cpp
utils/CommandLine.cpp
utils/CoordinateSpace.cpp
utils/Builder.cpp
utils/SharedObjects.cpp
utils/ShaderSet.cpp
utils/GraphicsPipelineConfigurator.cpp
utils/ShaderCompiler.cpp
utils/ComputeBounds.cpp
utils/Intersector.cpp
utils/Instrumentation.cpp
utils/GpuAnnotation.cpp
utils/LineSegmentIntersector.cpp
utils/PolytopeIntersector.cpp
utils/LoadPagedLOD.cpp
utils/FindDynamicObjects.cpp
utils/PropagateDynamicObjects.cpp
utils/Profiler.cpp
)
# set up library dependencies
set(LIBRARIES PUBLIC
Vulkan::Vulkan
Threads::Threads
)
if (${VSG_SUPPORTS_ShaderCompiler})
list(INSERT LIBRARIES 0 PRIVATE glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV)
endif()
if (VSG_SUPPORTS_ShaderOptimizer)
list(INSERT LIBRARIES 0 PRIVATE SPIRV-Tools-opt)
endif()
# Check for std::atomic
if(NOT MSVC AND NOT ANDROID AND NOT APPLE)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <atomic>
int main()
{
std::atomic_uint64_t a64(1);
auto orig_value = a64.load();
uint64_t new_value = 1;
auto r = a64.compare_exchange_weak(orig_value, new_value);
return 0;
}"
HAVE_CXX_ATOMIC_WITHOUT_LIB
)
if(NOT HAVE_CXX_ATOMIC_WITHOUT_LIB)
find_library(CXX_ATOMIC_LIBRARIES NAMES atomic atomic.so.1 libatomic.so.1 REQUIRED)
list(APPEND LIBRARIES ${CXX_ATOMIC_LIBRARIES})
endif()
endif()
if (VSG_SUPPORTS_Windowing)
if (ANDROID)
set(HEADERS ${HEADERS} ${VSG_SOURCE_DIR}/include/vsg/platform/android/Android_Window.h)
set(SOURCES ${SOURCES} platform/android/Android_Window.cpp)
if(CMAKE_SYSTEM_VERSION GREATER 24)
set(LIBRARIES ${LIBRARIES} PRIVATE ${AndroidLib} PRIVATE ${AndroidNativeWindowLib})
else()
set(LIBRARIES ${LIBRARIES} PRIVATE ${AndroidLib})
endif()
elseif (WIN32)
set(SOURCES ${SOURCES} platform/win32/Win32_Window.cpp)
elseif (IOS)
set(HEADERS ${HEADERS}
${VSG_SOURCE_DIR}/include/vsg/platform/ios/iOS_Window.h
${VSG_SOURCE_DIR}/include/vsg/platform/ios/iOS_ViewController.h
)
set(SOURCES ${SOURCES}
platform/ios/iOS_Window.mm
platform/ios/iOS_ViewController.mm
)
set(LIBRARIES ${LIBRARIES} PRIVATE ${UIKIT_LIBRARY} PRIVATE ${QUARTZCORE_LIBRARY})
elseif (APPLE)
set(SOURCES ${SOURCES} platform/macos/MacOS_Window.mm)
set(LIBRARIES ${LIBRARIES} PRIVATE ${COCOA_LIBRARY} PRIVATE ${QUARTZCORE_LIBRARY})
elseif (UNIX)
if(BUILD_WAYLAND)
set(SOURCES ${SOURCES} platform/wayland/Wayland_Window.cpp ${WAYLAND_GENERATED}/wayland-xdg-shell-protocol.c ${WAYLAND_GENERATED}/xdg-decoration-client.c)
set(LIBRARIES ${LIBRARIES} PRIVATE PkgConfig::wayland-client PkgConfig::wayland-cursor PkgConfig::xkbcommon)
else()
set(SOURCES ${SOURCES} platform/xcb/Xcb_Window.cpp)
set(LIBRARIES ${LIBRARIES} PRIVATE PkgConfig::xcb)
endif()
else()
endif()
endif()
add_library(vsg ${HEADERS} ${SOURCES})
# add definitions to enable building VulkanSceneGraph as part of submodule
add_library(vsg::vsg ALIAS vsg)
set(vsg_FOUND TRUE CACHE INTERNAL "vsg found.")
set(CMAKE_DISABLE_FIND_PACKAGE_vsg TRUE CACHE INTERNAL "Disable find_package(vsg) as it's not necessary.")
set_target_properties(vsg PROPERTIES FOLDER "VulkanSceneGraph")
if(MSVC)
# ensure the libraries are all built in the lib directory
macro(SET_OUTPUT_DIR_PROPERTY TARGET_TARGETNAME RELATIVE_OUTDIR)
# Global properties (All generators but VS & Xcode)
set_target_properties(${TARGET_TARGETNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${OUTPUT_LIBDIR}/${RELATIVE_OUTDIR}")
set_target_properties(${TARGET_TARGETNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${OUTPUT_LIBDIR}/${RELATIVE_OUTDIR}")
set_target_properties(${TARGET_TARGETNAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_LIBDIR}/${RELATIVE_OUTDIR}")
# Per-configuration property (VS, Xcode)
foreach(CONF ${CMAKE_CONFIGURATION_TYPES}) # For each configuration (Debug, Release, MinSizeRel... and/or anything the user chooses)
string(TOUPPER "${CONF}" CONF) # Go uppercase (DEBUG, RELEASE...)
# We use "FILE(TO_CMAKE_PATH", to create nice looking paths
set_target_properties(${TARGET_TARGETNAME} PROPERTIES "ARCHIVE_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}/${RELATIVE_OUTDIR}")
set_target_properties(${TARGET_TARGETNAME} PROPERTIES "RUNTIME_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}/${RELATIVE_OUTDIR}")
set_target_properties(${TARGET_TARGETNAME} PROPERTIES "LIBRARY_OUTPUT_DIRECTORY_${CONF}" "${OUTPUT_LIBDIR}/${RELATIVE_OUTDIR}")
endforeach()
endmacro()
SET_OUTPUT_DIR_PROPERTY(vsg "")
option(ENABLE_MP_FLAG "Turning on this option will add the multi-processor flag in MSVC for VSG and its included projects" ON)
if(ENABLE_MP_FLAG)
target_compile_options(vsg PRIVATE "/MP")
endif()
option(DISABLE_CHECKED_ITERATORS "Turning on this option will disable checked iterators in debug mode for visual studio. All imported projects must adhere to this requirement" OFF)
if(DISABLE_CHECKED_ITERATORS)
target_compile_definitions(vsg PUBLIC "_ITERATOR_DEBUG_LEVEL=0")
endif()
# MSVC assumes system-wide eight-bit code page (e.g. CP1252, CP1250) if there's no BOM
target_compile_options(vsg PRIVATE "/utf-8")
endif()
# place header and source files into group folders to help IDE's present the files in a logical manner
function(ASSIGN_SOURCE_GROUPS GROUP_NAME ROOT_FOLDER)
foreach(FILE IN ITEMS ${ARGN})
if (IS_ABSOLUTE "${FILE}")
file(RELATIVE_PATH RELATIVE_SOURCE "${ROOT_FOLDER}" "${FILE}")
else()
set(RELATIVE_SOURCE "${FILE}")
endif()
get_filename_component(SOURCE_PATH "${RELATIVE_SOURCE}" PATH)
string(REPLACE "/" "\\" SOURCE_PATH_MSVC "${SOURCE_PATH}")
source_group("${GROUP_NAME}\\${SOURCE_PATH_MSVC}" FILES "${FILE}")
endforeach()
endfunction(ASSIGN_SOURCE_GROUPS)
# enable folders for MSVC
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# group source files and headers
ASSIGN_SOURCE_GROUPS("Source Files" "${VSG_SOURCE_DIR}" ${SOURCES})
ASSIGN_SOURCE_GROUPS("Header Files" "${VSG_SOURCE_DIR}/include/vsg" ${HEADERS})
# set up versions and position independent code that is required for unix platforms
set_property(TARGET vsg PROPERTY VERSION ${VSG_VERSION_MAJOR}.${VSG_VERSION_MINOR}.${VSG_VERSION_PATCH})
set_property(TARGET vsg PROPERTY SOVERSION ${VSG_SOVERSION})
set_property(TARGET vsg PROPERTY POSITION_INDEPENDENT_CODE ON)
# set up the C++ Standard used
if (NOT CMAKE_CXX_STANDARD)
# no CMAKE_CXX_STANDARD explicitly defined so default to 17
target_compile_features(vsg PUBLIC cxx_std_17)
elseif (${CMAKE_CXX_STANDARD} EQUAL 17)
target_compile_features(vsg PUBLIC cxx_std_17)
elseif (${CMAKE_CXX_STANDARD} EQUAL 20)
target_compile_features(vsg PUBLIC cxx_std_20) # CMake minimum version 3.12
elseif (${CMAKE_CXX_STANDARD} EQUAL 23)
target_compile_features(vsg PUBLIC cxx_std_23) # CMake minimum version 3.20
elseif (${CMAKE_CXX_STANDARD} EQUAL 26)
target_compile_features(vsg PUBLIC cxx_std_26) # CMake minimum version 3.30
else()
message(FATAL_ERROR "Invalid CMAKE_CXX_STANDARD value of " ${CMAKE_CXX_STANDARD} ", supported values are 17, 20 or 23.")
endif()
if(WIN32)
set_property(TARGET vsg PROPERTY RUNTIME_OUTPUT_NAME vsg-${VSG_SOVERSION})
endif()
target_compile_definitions(vsg PRIVATE ${EXTRA_DEFINES})
target_include_directories(vsg
PUBLIC
$<BUILD_INTERFACE:${VSG_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${VSG_BINARY_DIR}/include>
$<BUILD_INTERFACE:${VSG_BINARY_DIR}/wayland_generated>
)
target_link_libraries(vsg ${LIBRARIES})
if (BUILD_SHARED_LIBS)
target_compile_definitions(vsg INTERFACE VSG_SHARED_LIBRARY)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT VSG_USE_DYNAMIC_CAST)
# Static build, Clang, and we are not using dynamic_cast:
# export Array/Value/etc. to stabilize typeid.
target_compile_definitions(vsg PRIVATE VSG_EXPORTS)
endif()
# install headers
install(DIRECTORY ${VSG_SOURCE_DIR}/include/vsg DESTINATION include)
if (NOT(${VSG_BINARY_DIR} STREQUAL ${VSG_SOURCE_DIR}))
install(DIRECTORY ${VSG_BINARY_DIR}/include/vsg DESTINATION include)
endif()
# install lib
install(TARGETS vsg ${VSG_INSTALL_TARGETS_DEFAULT_FLAGS})
# install cmake config files.
install(
FILES
"${VSG_SOURCE_DIR}/cmake/FindVulkan.cmake"
"${VSG_SOURCE_DIR}/cmake/uninstall.cmake"
"${VSG_SOURCE_DIR}/cmake/vsgMacros.cmake"
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/vsg
)
vsg_add_cmake_support_files(
CONFIG_TEMPLATE vsgConfig.cmake.in
)