forked from liblava/liblava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
852 lines (675 loc) · 23.8 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
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
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
cmake_minimum_required(VERSION 3.27)
project(liblava VERSION 0.8.1 LANGUAGES C CXX)
message(STATUS "========================================================================")
message(STATUS " Copyright (c) 2018-present, Lava Block OÜ and contributors")
message(STATUS "========================================================================")
message(STATUS " ")
message(STATUS " _| _| _| _| ")
message(STATUS " _| _|_|_| _| _|_|_| _| _| _|_|_| ")
message(STATUS " _| _| _| _| _| _| _| _| _| _| _| ")
message(STATUS " _| _| _| _| _| _| _| _| _| _| _| ")
message(STATUS " _| _| _|_|_| _| _|_|_| _| _|_|_| ")
message(STATUS " ")
message(STATUS "========================================================================")
message(STATUS " https://liblava.dev 2024 rolling / 0.8.1 MIT licensed ")
option(LIBLAVA_TEST "Enable Test" TRUE)
option(LIBLAVA_DEMO "Enable Demo" TRUE)
option(LIBLAVA_PACK "Enable Pack" TRUE)
option(LIBLAVA_TEMPLATE "Enable Template" TRUE)
set(LIBLAVA_TEMPLATE_NAME "template" CACHE STRING "Name of template project")
option(LIBLAVA_WARNING_AS_ERROR "Enable build warnings as errors" FALSE)
option(IMGUI_DOCKING "Dear ImGui with docking" FALSE)
option(LIBLAVA_EXTERNALS "Enable Third-Party modules" TRUE)
set(LIBLAVA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/liblava)
set(LIBLAVA_EXT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext)
set(LIBLAVA_RES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/res)
if(NOT ${LIBLAVA_RES_DIR} MATCHES ${CMAKE_CURRENT_BINARY_DIR}/res)
file(CREATE_LINK "${LIBLAVA_RES_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/res"
RESULT 0 COPY_ON_ERROR SYMBOLIC)
endif()
if(NOT DEFINED CMAKE_SUPPRESS_DEVELOPER_WARNINGS)
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "No dev warnings")
endif()
include(GNUInstallDirs)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "> ccache found")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
if(CMAKE_HOST_WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/MP>)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
endif()
if(LIBLAVA_EXTERNALS)
message(STATUS "========================================================================")
message(STATUS "> CPM.cmake")
include(cmake/CPM.cmake)
include(cmake/ext.cmake)
set(EXT_FOLDER "ext")
set_target_properties(spdlog PROPERTIES FOLDER ${EXT_FOLDER})
if(LIBLAVA_TEST)
set_target_properties(Catch2 PROPERTIES FOLDER ${EXT_FOLDER})
set_target_properties(Catch2WithMain PROPERTIES FOLDER ${EXT_FOLDER})
endif()
set_target_properties(physfs-static PROPERTIES FOLDER ${EXT_FOLDER})
set(LIBSHADERC_FOLDER "libshaderc")
set_target_properties(shaderc PROPERTIES FOLDER ${LIBSHADERC_FOLDER})
set_target_properties(shaderc_combined PROPERTIES FOLDER ${LIBSHADERC_FOLDER})
set_target_properties(shaderc_shared PROPERTIES FOLDER ${LIBSHADERC_FOLDER})
set_target_properties(shaderc_util PROPERTIES FOLDER ${LIBSHADERC_FOLDER})
set_target_properties(testdata PROPERTIES FOLDER ${LIBSHADERC_FOLDER})
set(SHADERC_FOLDER "Shaderc")
set_target_properties(add-copyright PROPERTIES FOLDER ${SHADERC_FOLDER})
set_target_properties(build-version PROPERTIES FOLDER ${SHADERC_FOLDER})
set_target_properties(glslc PROPERTIES FOLDER ${SHADERC_FOLDER})
set_target_properties(glslc_exe PROPERTIES FOLDER ${SHADERC_FOLDER})
set_target_properties(shaderc_combined-pkg-config PROPERTIES FOLDER ${SHADERC_FOLDER})
set_target_properties(shaderc_static-pkg-config PROPERTIES FOLDER ${SHADERC_FOLDER})
set_target_properties(shaderc-pkg-config PROPERTIES FOLDER ${SHADERC_FOLDER})
set(SPIRV_TOOLS_FOLDER "SPIRV-Tools")
set_target_properties(core_tables PROPERTIES FOLDER ${SPIRV_TOOLS_FOLDER})
set_target_properties(enum_string_mapping PROPERTIES FOLDER ${SPIRV_TOOLS_FOLDER})
set_target_properties(extinst_tables PROPERTIES FOLDER ${SPIRV_TOOLS_FOLDER})
set_target_properties(spirv-tools-pkg-config PROPERTIES FOLDER ${SPIRV_TOOLS_FOLDER})
endif()
message(STATUS "========================================================================")
message(STATUS "> modules")
message(STATUS ">> lava::core")
find_package(Threads REQUIRED)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/empty.cpp "")
add_library(lava.core
${CMAKE_CURRENT_BINARY_DIR}/empty.cpp
${LIBLAVA_DIR}/core/data.hpp
${LIBLAVA_DIR}/core/def.hpp
${LIBLAVA_DIR}/core/id.hpp
${LIBLAVA_DIR}/core/misc.hpp
${LIBLAVA_DIR}/core/time.hpp
${LIBLAVA_DIR}/core/types.hpp
${LIBLAVA_DIR}/core/version.hpp
)
target_include_directories(lava.core INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
target_compile_features(lava.core INTERFACE cxx_std_23)
target_link_libraries(lava.core INTERFACE
Threads::Threads
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(lava.core INTERFACE "-Wno-psabi")
target_link_options(lava.core INTERFACE "-latomic")
endif()
if(LIBLAVA_WARNING_AS_ERROR)
target_compile_options(lava.core INTERFACE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
)
endif()
set_target_properties(lava.core PROPERTIES FOLDER "liblava")
set_property(TARGET lava.core PROPERTY EXPORT_NAME core)
add_library(lava::core ALIAS lava.core)
message(STATUS ">> lava::util")
add_library(lava.util
${CMAKE_CURRENT_BINARY_DIR}/empty.cpp
${LIBLAVA_DIR}/util/hex.hpp
${LIBLAVA_DIR}/util/layer.hpp
${LIBLAVA_DIR}/util/log.hpp
${LIBLAVA_DIR}/util/math.hpp
${LIBLAVA_DIR}/util/random.hpp
${LIBLAVA_DIR}/util/telegram.hpp
${LIBLAVA_DIR}/util/thread.hpp
)
target_include_directories(lava.util PUBLIC
$<BUILD_INTERFACE:${PicoSHA2_SOURCE_DIR}>
$<BUILD_INTERFACE:${glm_SOURCE_DIR}>
)
target_link_libraries(lava.util INTERFACE
lava::core
spdlog
)
set_target_properties(lava.util PROPERTIES FOLDER "liblava")
set_property(TARGET lava.util PROPERTY EXPORT_NAME util)
add_library(lava::util ALIAS lava.util)
message(STATUS ">> lava::file")
add_library(lava.file
${LIBLAVA_DIR}/file/file_system.cpp
${LIBLAVA_DIR}/file/file_system.hpp
${LIBLAVA_DIR}/file/file_utils.cpp
${LIBLAVA_DIR}/file/file_utils.hpp
${LIBLAVA_DIR}/file/file.cpp
${LIBLAVA_DIR}/file/file.hpp
${LIBLAVA_DIR}/file/json_file.cpp
${LIBLAVA_DIR}/file/json_file.hpp
${LIBLAVA_DIR}/file/json.hpp
)
target_include_directories(lava.file
PUBLIC
$<BUILD_INTERFACE:${json_SOURCE_DIR}/single_include>
PRIVATE
$<BUILD_INTERFACE:${physfs_SOURCE_DIR}/src>
)
target_link_libraries(lava.file PUBLIC
lava::core
physfs-static
)
set_target_properties(lava.file PROPERTIES FOLDER "liblava")
set_property(TARGET lava.file PROPERTY EXPORT_NAME file)
add_library(lava::file ALIAS lava.file)
message(STATUS ">> lava::base")
add_library(lava.base
${LIBLAVA_DIR}/base/base.cpp
${LIBLAVA_DIR}/base/base.hpp
${LIBLAVA_DIR}/base/debug_utils.cpp
${LIBLAVA_DIR}/base/debug_utils.hpp
${LIBLAVA_DIR}/base/device_table.hpp
${LIBLAVA_DIR}/base/device.cpp
${LIBLAVA_DIR}/base/device.hpp
${LIBLAVA_DIR}/base/instance.cpp
${LIBLAVA_DIR}/base/instance.hpp
${LIBLAVA_DIR}/base/memory.cpp
${LIBLAVA_DIR}/base/memory.hpp
${LIBLAVA_DIR}/base/physical_device.cpp
${LIBLAVA_DIR}/base/physical_device.hpp
${LIBLAVA_DIR}/base/platform.cpp
${LIBLAVA_DIR}/base/platform.hpp
${LIBLAVA_DIR}/base/queue.cpp
${LIBLAVA_DIR}/base/queue.hpp
${volk_SOURCE_DIR}/volk.c
)
target_include_directories(lava.base PUBLIC
$<BUILD_INTERFACE:${Vulkan-Headers_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${VulkanMemoryAllocator_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${volk_SOURCE_DIR}>
)
target_link_libraries(lava.base PUBLIC
lava::util
${CMAKE_DL_LIBS}
)
set_target_properties(lava.base PROPERTIES FOLDER "liblava")
set_property(TARGET lava.base PROPERTY EXPORT_NAME base)
add_library(lava::base ALIAS lava.base)
message(STATUS ">> lava::resource")
add_library(lava.resource
${LIBLAVA_DIR}/resource/buffer.cpp
${LIBLAVA_DIR}/resource/buffer.hpp
${LIBLAVA_DIR}/resource/format.cpp
${LIBLAVA_DIR}/resource/format.hpp
${LIBLAVA_DIR}/resource/image.cpp
${LIBLAVA_DIR}/resource/image.hpp
${LIBLAVA_DIR}/resource/primitive.hpp
${LIBLAVA_DIR}/resource/mesh.hpp
${LIBLAVA_DIR}/resource/texture.cpp
${LIBLAVA_DIR}/resource/texture.hpp
)
target_link_libraries(lava.resource PUBLIC
lava::base
)
set_target_properties(lava.resource PROPERTIES FOLDER "liblava")
set_property(TARGET lava.resource PROPERTY EXPORT_NAME resource)
add_library(lava::resource ALIAS lava.resource)
message(STATUS ">> lava::asset")
add_library(lava.asset
${LIBLAVA_DIR}/asset/load_image.cpp
${LIBLAVA_DIR}/asset/load_image.hpp
${LIBLAVA_DIR}/asset/load_mesh.cpp
${LIBLAVA_DIR}/asset/load_mesh.hpp
${LIBLAVA_DIR}/asset/load_texture.cpp
${LIBLAVA_DIR}/asset/load_texture.hpp
${LIBLAVA_DIR}/asset/write_image.cpp
${LIBLAVA_DIR}/asset/write_image.hpp
)
target_include_directories(lava.asset PRIVATE
$<BUILD_INTERFACE:${stb_SOURCE_DIR}>
$<BUILD_INTERFACE:${gli_SOURCE_DIR}>
$<BUILD_INTERFACE:${tinyobjloader_SOURCE_DIR}>
)
target_link_libraries(lava.asset PUBLIC
lava::resource
lava::file
)
set_target_properties(lava.asset PROPERTIES FOLDER "liblava")
set_property(TARGET lava.asset PROPERTY EXPORT_NAME asset)
add_library(lava::asset ALIAS lava.asset)
message(STATUS ">> lava::block")
add_library(lava.block
${LIBLAVA_DIR}/block/attachment.hpp
${LIBLAVA_DIR}/block/block.cpp
${LIBLAVA_DIR}/block/block.hpp
${LIBLAVA_DIR}/block/compute_pipeline.cpp
${LIBLAVA_DIR}/block/compute_pipeline.hpp
${LIBLAVA_DIR}/block/def.hpp
${LIBLAVA_DIR}/block/descriptor.cpp
${LIBLAVA_DIR}/block/descriptor.hpp
${LIBLAVA_DIR}/block/pipeline.cpp
${LIBLAVA_DIR}/block/pipeline.hpp
${LIBLAVA_DIR}/block/pipeline_layout.cpp
${LIBLAVA_DIR}/block/pipeline_layout.hpp
${LIBLAVA_DIR}/block/render_pass.cpp
${LIBLAVA_DIR}/block/render_pass.hpp
${LIBLAVA_DIR}/block/render_pipeline.cpp
${LIBLAVA_DIR}/block/render_pipeline.hpp
${LIBLAVA_DIR}/block/subpass.cpp
${LIBLAVA_DIR}/block/subpass.hpp
)
target_link_libraries(lava.block PUBLIC
lava::base
)
set_target_properties(lava.block PROPERTIES FOLDER "liblava")
set_property(TARGET lava.block PROPERTY EXPORT_NAME block)
add_library(lava::block ALIAS lava.block)
message(STATUS ">> lava::frame")
add_library(lava.frame
${LIBLAVA_DIR}/frame/argh.cpp
${LIBLAVA_DIR}/frame/argh.hpp
${LIBLAVA_DIR}/frame/driver.cpp
${LIBLAVA_DIR}/frame/driver.hpp
${LIBLAVA_DIR}/frame/frame.cpp
${LIBLAVA_DIR}/frame/frame.hpp
${LIBLAVA_DIR}/frame/gamepad.cpp
${LIBLAVA_DIR}/frame/gamepad.hpp
${LIBLAVA_DIR}/frame/input.cpp
${LIBLAVA_DIR}/frame/input.hpp
${LIBLAVA_DIR}/frame/render_target.cpp
${LIBLAVA_DIR}/frame/render_target.hpp
${LIBLAVA_DIR}/frame/renderer.cpp
${LIBLAVA_DIR}/frame/renderer.hpp
${LIBLAVA_DIR}/frame/swapchain.cpp
${LIBLAVA_DIR}/frame/swapchain.hpp
${LIBLAVA_DIR}/frame/window.cpp
${LIBLAVA_DIR}/frame/window.hpp
)
target_include_directories(lava.frame
PUBLIC
$<BUILD_INTERFACE:${argh_SOURCE_DIR}>
PRIVATE
$<BUILD_INTERFACE:${glfw_SOURCE_DIR}/include>
)
target_link_libraries(lava.frame PUBLIC
lava::resource
glfw
${GLFW_LIBRARIES}
)
set_target_properties(lava.frame PROPERTIES FOLDER "liblava")
set_property(TARGET lava.frame PROPERTY EXPORT_NAME frame)
add_library(lava::frame ALIAS lava.frame)
message(STATUS ">> lava::app")
set(IMGUI_FILES
${imgui_SOURCE_DIR}/imgui.cpp
${imgui_SOURCE_DIR}/imgui.h
${imgui_SOURCE_DIR}/imgui_draw.cpp
${imgui_SOURCE_DIR}/imgui_tables.cpp
${imgui_SOURCE_DIR}/imgui_widgets.cpp
${imgui_SOURCE_DIR}/imgui_demo.cpp
)
source_group("imgui Files" FILES ${IMGUI_FILES})
set(APP_SHADERS
res/imgui/imgui.frag
res/imgui/imgui.vert
)
source_group("Shader Files" FILES ${APP_SHADERS})
add_library(lava.app
${LIBLAVA_DIR}/app/app.cpp
${LIBLAVA_DIR}/app/app.hpp
${LIBLAVA_DIR}/app/benchmark.cpp
${LIBLAVA_DIR}/app/benchmark.hpp
${LIBLAVA_DIR}/app/camera.cpp
${LIBLAVA_DIR}/app/camera.hpp
${LIBLAVA_DIR}/app/config.cpp
${LIBLAVA_DIR}/app/config.hpp
${LIBLAVA_DIR}/app/def.hpp
${LIBLAVA_DIR}/app/forward_shading.cpp
${LIBLAVA_DIR}/app/forward_shading.hpp
${LIBLAVA_DIR}/app/icon.hpp
${LIBLAVA_DIR}/app/imgui.cpp
${LIBLAVA_DIR}/app/imgui.hpp
${IMGUI_FILES}
${APP_SHADERS}
)
target_include_directories(lava.app
PUBLIC
$<BUILD_INTERFACE:${imgui_SOURCE_DIR}>
$<BUILD_INTERFACE:${IconFontCppHeaders_SOURCE_DIR}>
PRIVATE
$<BUILD_INTERFACE:${glfw_SOURCE_DIR}/include>
)
target_link_libraries(lava.app PUBLIC
lava::block
lava::frame
lava::asset
)
# target_compile_definitions(lava.app PRIVATE IMGUI_DISABLE_OBSOLETE_FUNCTIONS)
set_target_properties(lava.app PROPERTIES FOLDER "liblava")
set_property(TARGET lava.app PROPERTY EXPORT_NAME app)
add_library(lava::app ALIAS lava.app)
message(STATUS ">> lava::engine")
add_library(lava.engine
${LIBLAVA_DIR}/engine/engine.cpp
${LIBLAVA_DIR}/engine/engine.hpp
${LIBLAVA_DIR}/engine/producer.cpp
${LIBLAVA_DIR}/engine/producer.hpp
${LIBLAVA_DIR}/engine/props.cpp
${LIBLAVA_DIR}/engine/props.hpp
)
target_include_directories(lava.engine PRIVATE
$<BUILD_INTERFACE:${shaderc_SOURCE_DIR}/libshaderc/include>
)
target_link_libraries(lava.engine PUBLIC
lava::app
)
set(LIBLAVA_ENGINE_LIBRARIES "shaderc")
set(LIBLAVA_ENGINE_LIBRARIES ${LIBLAVA_ENGINE_LIBRARIES} PARENT_SCOPE)
set_target_properties(lava.engine PROPERTIES FOLDER "liblava")
set_property(TARGET lava.engine PROPERTY EXPORT_NAME engine)
add_library(lava::engine ALIAS lava.engine)
message(STATUS "========================================================================")
message(STATUS "> lava")
set(LIBLAVA_STAGE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/liblava-stage)
add_executable(lava
${LIBLAVA_STAGE_DIR}/examples.cpp
${LIBLAVA_STAGE_DIR}/main.cpp
${LIBLAVA_STAGE_DIR}/tutorial.cpp
)
target_link_libraries(lava PRIVATE
lava::engine
${LIBLAVA_ENGINE_LIBRARIES}
)
set_target_properties(lava PROPERTIES FOLDER "lava")
set_property(TARGET lava PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
install(TARGETS lava
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT "liblava_Runtime"
)
if(LIBLAVA_TEST)
message(STATUS "========================================================================")
message(STATUS "> lava-test")
enable_testing()
set(UNIT_TESTS
${LIBLAVA_DIR}/base/test/queue.cpp
)
add_executable(lava-test
${LIBLAVA_DIR}/test.hpp
${UNIT_TESTS}
)
target_link_libraries(lava-test PRIVATE
lava::engine
${LIBLAVA_ENGINE_LIBRARIES}
Catch2::Catch2
Catch2::Catch2WithMain
)
set_target_properties(lava-test PROPERTIES FOLDER "lava")
set_property(TARGET lava-test PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
add_test(NAME lava-test COMMAND lava-test)
install(TARGETS lava-test
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT "liblava_Runtime"
)
endif()
install(TARGETS
lava.core
lava.util
lava.file
lava.base
lava.resource
lava.asset
lava.block
lava.frame
lava.app
lava.engine
spdlog
physfs-static
glfw
# shaderc
# shaderc_util
# shaderc_combined
EXPORT LavaTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT "liblava_Development"
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT "liblava_Development"
INCLUDES DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}
${CMAKE_INSTALL_INCLUDEDIR}/liblava/ext
COMPONENT "liblava_Development"
)
install(
DIRECTORY ${LIBLAVA_DIR}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT "liblava_Development"
FILES_MATCHING PATTERN "*.hpp"
)
set(EXT_INCLUDE_DIRS
${glm_SOURCE_DIR}
# ${physfs_SOURCE_DIR}/src
${json_SOURCE_DIR}/single_include
${spdlog_SOURCE_DIR}/include
${PicoSHA2_SOURCE_DIR}
${Vulkan-Headers_SOURCE_DIR}/include
${VulkanMemoryAllocator_SOURCE_DIR}/include
${volk_SOURCE_DIR}
# ${stb_SOURCE_DIR}
# ${gli_SOURCE_DIR}
# ${tinyobjloader_SOURCE_DIR}
# ${glfw_SOURCE_DIR}/include
# ${Catch2_SOURCE_DIR}
${argh_SOURCE_DIR}
${imgui_SOURCE_DIR}
${IconFontCppHeaders_SOURCE_DIR}
# ${shaderc_SOURCE_DIR}/libshaderc/include
)
foreach(DIR ${EXT_INCLUDE_DIRS})
file(GLOB_RECURSE HEADER_FILES "${DIR}/*.h" "${DIR}/*.hpp" "${DIR}/*.inl")
foreach(HEADER_FILE ${HEADER_FILES})
cmake_path(SET PATH ${HEADER_FILE})
cmake_path(RELATIVE_PATH PATH BASE_DIRECTORY ${DIR})
cmake_path(GET PATH PARENT_PATH OUT_DIR)
install(
FILES ${HEADER_FILE}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/liblava/ext/${OUT_DIR}"
COMPONENT "liblava_Development"
)
endforeach()
endforeach()
set(CONFIG_PATH ${CMAKE_INSTALL_LIBDIR}/cmake/lava)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/lava-config-version.cmake"
COMPATIBILITY AnyNewerVersion)
configure_package_config_file(
cmake/LavaConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/lava-config.cmake"
INSTALL_DESTINATION ${CONFIG_PATH})
install(
EXPORT LavaTargets
DESTINATION ${CONFIG_PATH}
COMPONENT "liblava_Development"
NAMESPACE lava::
FILE LavaTargets.cmake
EXPORT_LINK_INTERFACE_LIBRARIES
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/lava-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/lava-config.cmake"
DESTINATION ${CONFIG_PATH}
COMPONENT "liblava_Development"
)
if(LIBLAVA_DEMO)
message(STATUS "========================================================================")
message(STATUS "> lava-demo")
set(LIBLAVA_DEMO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/liblava-demo)
add_executable(lava-demo
${LIBLAVA_DEMO_DIR}/main.cpp
${LIBLAVA_DEMO_DIR}/generics.cpp
${LIBLAVA_DEMO_DIR}/lamp.cpp
${LIBLAVA_DEMO_DIR}/light.cpp
${LIBLAVA_DEMO_DIR}/shapes.cpp
${LIBLAVA_DEMO_DIR}/spawn.cpp
${LIBLAVA_DEMO_DIR}/triangle.cpp
)
target_compile_definitions(lava-demo PRIVATE LAVA_DEMO)
target_link_libraries(lava-demo PRIVATE
lava::engine
${LIBLAVA_ENGINE_LIBRARIES}
)
set_target_properties(lava-demo PROPERTIES FOLDER "lava-demo")
set_property(TARGET lava-demo PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
message(STATUS ">> lava-triangle")
set(TRIANGLE_SHADERS
res/triangle/triangle.frag
res/triangle/triangle.vert
)
add_executable(lava-triangle
${LIBLAVA_DEMO_DIR}/triangle.cpp
${TRIANGLE_SHADERS}
)
source_group("Shader Files" FILES ${TRIANGLE_SHADERS})
target_link_libraries(lava-triangle PRIVATE
lava::app
)
set_target_properties(lava-triangle PROPERTIES FOLDER "lava-demo")
set_property(TARGET lava-triangle PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
message(STATUS ">> lava-generics")
set(GENERICS_SHADERS
res/generics/triangle.frag
res/generics/float_triangle.vert
res/generics/int_triangle.vert
res/generics/double_triangle.vert
)
add_executable(lava-generics
${LIBLAVA_DEMO_DIR}/generics.cpp
${GENERICS_SHADERS}
)
source_group("Shader Files" FILES ${GENERICS_SHADERS})
target_link_libraries(lava-generics PRIVATE
lava::engine
${LIBLAVA_ENGINE_LIBRARIES}
)
set_target_properties(lava-generics PROPERTIES FOLDER "lava-demo")
set_property(TARGET lava-generics PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
message(STATUS ">> lava-shapes")
set(SHAPES_SHADERS
res/shapes/shapes.frag
res/shapes/shapes.vert
)
add_executable(lava-shapes
${LIBLAVA_DEMO_DIR}/shapes.cpp
${SHAPES_SHADERS}
)
source_group("Shader Files" FILES ${SHAPES_SHADERS})
target_link_libraries(lava-shapes PRIVATE
lava::engine
${LIBLAVA_ENGINE_LIBRARIES}
)
set_target_properties(lava-shapes PROPERTIES FOLDER "lava-demo")
set_property(TARGET lava-shapes PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
message(STATUS ">> lava-lamp")
set(LAMP_SHADERS
res/lamp/lamp.frag
res/lamp/lamp.vert
)
add_executable(lava-lamp
${LIBLAVA_DEMO_DIR}/lamp.cpp
${LAMP_SHADERS}
)
source_group("Shader Files" FILES ${LAMP_SHADERS})
target_link_libraries(lava-lamp PRIVATE
lava::engine
${LIBLAVA_ENGINE_LIBRARIES}
)
set_target_properties(lava-lamp PROPERTIES FOLDER "lava-demo")
set_property(TARGET lava-lamp PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
message(STATUS ">> lava-spawn")
set(SPAWN_SHADERS
res/spawn/spawn.frag
res/spawn/spawn.vert
)
add_executable(lava-spawn
${LIBLAVA_DEMO_DIR}/spawn.cpp
${SPAWN_SHADERS}
)
source_group("Shader Files" FILES ${SPAWN_SHADERS})
target_link_libraries(lava-spawn PRIVATE
lava::engine
${LIBLAVA_ENGINE_LIBRARIES}
)
set_target_properties(lava-spawn PROPERTIES FOLDER "lava-demo")
set_property(TARGET lava-spawn PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
message(STATUS ">> lava-light")
set(LIGHT_SHADERS
res/light/gbuffer.frag
res/light/gbuffer.vert
res/light/lighting.frag
res/light/lighting.vert
res/light/data.inc
)
add_executable(lava-light
${LIBLAVA_DEMO_DIR}/light.cpp
${LIGHT_SHADERS}
)
source_group("Shader Files" FILES ${LIGHT_SHADERS})
target_link_libraries(lava-light PRIVATE
lava::engine
${LIBLAVA_ENGINE_LIBRARIES}
)
set_target_properties(lava-light PROPERTIES FOLDER "lava-demo")
set_property(TARGET lava-light PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
# install demo targets
install(TARGETS
lava-demo
lava-triangle
lava-generics
lava-shapes
lava-lamp
lava-spawn
lava-light
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT "liblava_Runtime"
)
install(
DIRECTORY ${LIBLAVA_RES_DIR}
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT "liblava_Runtime"
)
endif()
if(LIBLAVA_TEMPLATE)
message(STATUS "========================================================================")
message(STATUS "> ${LIBLAVA_TEMPLATE_NAME}")
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_executable(${LIBLAVA_TEMPLATE_NAME}
${SRC_DIR}/main.cpp
)
target_include_directories(${LIBLAVA_TEMPLATE_NAME} PUBLIC
${SRC_DIR}
)
target_link_libraries(${LIBLAVA_TEMPLATE_NAME} PRIVATE
lava::engine
${LIBLAVA_ENGINE_LIBRARIES}
)
set_target_properties(${LIBLAVA_TEMPLATE_NAME} PROPERTIES FOLDER "lava")
set_property(TARGET ${LIBLAVA_TEMPLATE_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_BINARY_DIR}")
endif()
message(STATUS "========================================================================")
if(LIBLAVA_PACK)
set(CPACK_PACKAGE_NAME "liblava")
set(CPACK_PACKAGE_VENDOR "Lava Block OÜ and contributors")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://liblava.dev")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Modern C++ and easy-to-use library for the Vulkan® API")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
include(InstallRequiredSystemLibraries)
set(CPACK_GENERATOR "ZIP")
set(CPACK_SOURCE_GENERATOR "SOURCE_ZIP")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "SOURCE_TGZ")
endif()
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_OUTPUT_FILE_PREFIX packages)
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
include(CPack)
endif()