forked from ZQuestClassic/ZQuestClassic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
990 lines (852 loc) · 35.9 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
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
cmake_minimum_required(VERSION 3.24)
set(CMAKE_CONFIGURATION_TYPES Asan Debug Release RelWithDebInfo Coverage CACHE STRING INTERNAL FORCE)
project (ZeldaClassic)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(FetchContent)
include(CodeCoverage)
option(COPY_RESOURCES "Copy runtime resources to build folder, but only if they do not exist yet" ON)
set(USE_PCH FALSE CACHE BOOL "Use precompiled headers")
set(UNITY_BUILD FALSE CACHE BOOL "Unity build")
set(WANT_SENTRY FALSE CACHE BOOL "Include Sentry for crash dump handling")
set(WANT_MAC_DEBUG_FILES FALSE CACHE BOOL "Generate .dSYM debug files on Mac")
set(WANT_FUZZ FALSE CACHE BOOL "Set FUZZ CXX definition")
set(WANT_GIT_HOOKS TRUE CACHE BOOL "Install git hooks")
set(RELEASE_TAG "" CACHE STRING "Release tag")
set(RELEASE_CHANNEL "" CACHE STRING "Release channel")
set(REPO "" CACHE STRING "Repo URL")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MSVC)
set(CMAKE_CXX_FLAGS_ASAN "${CMAKE_CXX_FLAGS_DEBUG} /fsanitize=address" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_ASAN "${CMAKE_C_FLAGS_DEBUG} /fsanitize=address" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_ASAN "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /fsanitize=address" CACHE STRING "" FORCE)
else()
set(CMAKE_CXX_FLAGS_ASAN "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_ASAN "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_ASAN "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address" CACHE STRING "" FORCE)
endif()
if(WANT_GIT_HOOKS)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
if(UNIX)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/commit-msg.in" "${CMAKE_SOURCE_DIR}/.git/commit-msg")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/prepare-commit-msg.in" "${CMAKE_SOURCE_DIR}/.git/prepare-commit-msg")
file(
COPY "${CMAKE_SOURCE_DIR}/.git/commit-msg"
DESTINATION "${CMAKE_SOURCE_DIR}/.git/hooks"
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
file(
COPY "${CMAKE_SOURCE_DIR}/.git/prepare-commit-msg"
DESTINATION "${CMAKE_SOURCE_DIR}/.git/hooks"
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
else()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/commit-msg.in" "${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/prepare-commit-msg.in" "${CMAKE_SOURCE_DIR}/.git/hooks/prepare-commit-msg")
endif()
endif()
endif()
# This allows outputs to be run where they are by putting their libaries in
# the same folder.
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Hide various test-related targets created by GME cmake so they
# don't clutter up the Solution file. https://gitlab.kitware.com/cmake/cmake/-/issues/21730
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
set(BUILD_TESTING OFF CACHE BOOL "")
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
if(APPLE)
# Makes binaries look in their directory for shared libraries.
list(APPEND CMAKE_BUILD_RPATH "@loader_path")
elseif(LINUX)
# https://stackoverflow.com/a/71321163/2788187
SET(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)
endif()
if(APPLE AND WANT_MAC_DEBUG_FILES)
find_program(DSYMUTIL_PROGRAM dsymutil)
if (DSYMUTIL_PROGRAM)
foreach(lang C CXX)
foreach(var LINK_EXECUTABLE CREATE_SHARED_LIBRARY)
set(CMAKE_${lang}_${var} "${CMAKE_${lang}_${var}}" "${DSYMUTIL_PROGRAM} <TARGET>")
endforeach()
endforeach()
endif()
endif()
if(LINUX)
find_program(EU_STRIP_PROGRAM eu-strip)
if (EU_STRIP_PROGRAM)
foreach(lang C CXX)
foreach(var LINK_EXECUTABLE CREATE_SHARED_LIBRARY)
set(CMAKE_${lang}_${var} "${CMAKE_${lang}_${var}}" "${EU_STRIP_PROGRAM} --strip-debug -f <TARGET>.debug <TARGET>")
endforeach()
endforeach()
endif()
endif()
function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME)
set(files ${${SOURCE_VARIABLE_NAME}})
# Generate a unique filename for the unity build translation unit
set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/UB_${UB_SUFFIX}.cpp)
# Exclude all translation units from compilation
set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true)
# Open the ub file
FILE(WRITE ${unit_build_file} "// Unity Build generated by CMake\n")
# Add include statement for each translation unit
foreach(source_file ${files} )
FILE( APPEND ${unit_build_file} "#include <${CMAKE_CURRENT_SOURCE_DIR}/${source_file}>\n")
endforeach(source_file)
# Complement list of translation units with the name of ub
set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE)
endfunction(enable_unity_build)
#############################################################
# zlib/libpng
#############################################################
if(NOT EMSCRIPTEN)
# TODO: can't use prebuilt zlib on Ubuntu, else get linker errors.
# Error from building gme:
# /usr/bin/ld: _deps/zlib-build/Release/libz.a(trees.c.o): relocation R_X86_64_PC32 against
# symbol `_length_code' can not be used when making a shared object; recompile with -fPIC
if(LINUX)
set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE NEVER)
endif()
FetchContent_Declare(
zlib
GIT_REPOSITORY
https://github.com/Mizux/zlib.git
GIT_TAG
19d7d6b32ee3af4ed4bdec415f42f518c93b5025
FIND_PACKAGE_ARGS NAMES ZLIB
)
FetchContent_MakeAvailable(zlib)
if(LINUX)
set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE OPT_IN)
endif()
if(NOT ZLIB_LIBRARIES)
set(ZLIB_INCLUDE_DIR ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR})
set(ZLIB_LIBRARY ZLIB::ZLIB)
set(ZLIB_LIBRARIES ZLIB::ZLIB)
endif()
set(PNG_BUILD_ZLIB ON CACHE BOOL "")
set(PNG_STATIC OFF CACHE BOOL "")
set(PNG_TESTS OFF CACHE BOOL "")
set(WANT_IMAGE_PNG OFF)
FetchContent_Declare(
png
GIT_REPOSITORY
https://github.com/glennrp/libpng.git
GIT_TAG
v1.6.38
FIND_PACKAGE_ARGS NAMES PNG
)
FetchContent_MakeAvailable(png)
if(NOT PNG_LIBRARIES)
set(PNG_LIBRARIES png)
set(PNG_INCLUDE_DIRS "${png_SOURCE_DIR}" "${png_BINARY_DIR}")
set(PNG_INCLUDE_DIR "${png_SOURCE_DIR}" "${png_BINARY_DIR}")
endif()
endif()
#############################################################
# Allegro
#############################################################
# SDL WIP:
# cmake .. -DALLEGRO_SDL=on -DWANT_NATIVE_DIALOG=off
# https://github.com/liballeg/allegro5/issues/1335
if(NOT APPLE)
add_definitions(-DALLEGRO_NO_MAGIC_MAIN)
endif()
add_definitions(-DALLEGRO_KCM_AUDIO_SRC)
# Needed to build on Mac, otherwise get this error:
# aintern_bitmap.h:154:33: error: unknown type name 'ALLEGRO_BITMAP_WRAP'
add_definitions(-DALLEGRO_UNSTABLE)
option(SHARED "" ON)
set(MINIMP3_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include/minimp3)
FetchContent_Declare(
allegro5
GIT_REPOSITORY https://github.com/connorjclark/allegro5.git
GIT_TAG 4288ce93362fb9461a23f8431c37f908f8462d5a
)
FetchContent_GetProperties(allegro5)
if(NOT allegro5_POPULATED)
FetchContent_Populate(allegro5)
option(WANT_TESTS "" OFF)
option(WANT_EXAMPLES "" OFF)
option(WANT_DEMO "" OFF)
option(WANT_DOCS "" OFF)
option(WANT_IMAGE_WEBP "" OFF)
option(WANT_OPUS "" OFF)
add_subdirectory(${allegro5_SOURCE_DIR} ${allegro5_BINARY_DIR} EXCLUDE_FROM_ALL)
# Allegro 5 CMakeLists sets CMAKE_CONFIGURATION_TYPES in a way that doesn't work for us,
# so set it back to our value.
set(CMAKE_CONFIGURATION_TYPES Asan Debug Release RelWithDebInfo Coverage CACHE STRING INTERNAL FORCE)
endif()
# These include files are typically copied into the correct places via allegro's install
# target, but we do it manually because we are compiling from source.
file(COPY ${allegro5_SOURCE_DIR}/addons/font/allegro5/allegro_font.h
DESTINATION ${allegro5_SOURCE_DIR}/include/allegro5
)
file(COPY ${allegro5_SOURCE_DIR}/addons/primitives/allegro5/allegro_primitives.h
DESTINATION ${allegro5_SOURCE_DIR}/include/allegro5
)
file(COPY ${allegro5_SOURCE_DIR}/addons/audio/allegro5/allegro_audio.h
DESTINATION ${allegro5_SOURCE_DIR}/include/allegro5
)
file(COPY ${allegro5_SOURCE_DIR}/addons/audio/allegro5/internal/aintern_audio.h
DESTINATION ${allegro5_SOURCE_DIR}/include/allegro5/internal
)
file(COPY ${allegro5_SOURCE_DIR}/addons/image/allegro5/allegro_image.h
DESTINATION ${allegro5_SOURCE_DIR}/include/allegro5
)
file(COPY ${allegro5_SOURCE_DIR}/addons/acodec/allegro5/allegro_acodec.h
DESTINATION ${allegro5_SOURCE_DIR}/include/allegro5
)
file(COPY ${allegro5_SOURCE_DIR}/addons/native_dialog/allegro5/allegro_native_dialog.h
DESTINATION ${allegro5_SOURCE_DIR}/include/allegro5
)
# TODO: figure out how to not use global includes for this
include_directories(${allegro5_SOURCE_DIR}/include)
include_directories(${allegro5_BINARY_DIR}/include)
# Some performance problems with allegro legacy threaded event queues encouraged
# NOT closing them on shutdown. This seemed to work ok on Windows and Mac, but on
# Linux it totally prevents the program from closing.
# TODO: investigate this further - can performance problems with threaded event queues
# be fixed?
if(LINUX AND NOT EMSCRIPTEN)
set(ALLEGRO_LEGACY_CLOSE_THREADS 1)
endif()
add_subdirectory(allegro-legacy EXCLUDE_FROM_ALL)
add_library(allegro_with_legacy INTERFACE)
target_include_directories(allegro_with_legacy INTERFACE ${allegro5_SOURCE_DIR}/include ${allegro5_BINARY_DIR}/include)
target_include_directories(allegro_with_legacy INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/allegro-legacy/include ${CMAKE_CURRENT_BINARY_DIR}/allegro-legacy/include)
target_link_libraries(allegro_with_legacy INTERFACE allegro-legacy allegro_primitives allegro_font allegro_image allegro_main)
if (NOT EMSCRIPTEN)
target_link_libraries(allegro_with_legacy INTERFACE allegro_dialog)
endif()
#############################################################
# Header and source file lists
#############################################################
if (EMSCRIPTEN)
set(ZCSOUNDSOURCES
src/zcmusic_sdl.cpp
src/zcmusicd.cpp
)
else()
set(ZCSOUNDSOURCES
src/zcmusic.cpp
src/zcmusicd.cpp
)
endif()
set(ZELDA_MODULES
${CMAKE_SOURCE_DIR}/modules/zelda/ZeldaCore.txt
${CMAKE_SOURCE_DIR}/modules/zelda/ZeldaGUI.txt
${CMAKE_SOURCE_DIR}/modules/zelda/ZeldaSprite.txt
${CMAKE_SOURCE_DIR}/modules/zelda/ZeldaSubscreen.txt
)
set(ZQUEST_MODULES
${CMAKE_SOURCE_DIR}/modules/zquest/ZQuestCore.txt
${CMAKE_SOURCE_DIR}/modules/zquest/ZQuestGUI.txt
${CMAKE_SOURCE_DIR}/modules/zquest/ZQuestMisc.txt
)
set(ZSCRIPT_MODULES
${CMAKE_SOURCE_DIR}/modules/zscript/ParserCore.txt
${CMAKE_SOURCE_DIR}/modules/zscript/ParserSrc.txt
)
set(LAUNCHER_MODULES
${CMAKE_SOURCE_DIR}/modules/launcher/LauncherCore.txt
${CMAKE_SOURCE_DIR}/modules/launcher/LauncherGUI.txt
)
foreach(module ${ZELDA_MODULES} ${ZQUEST_MODULES} ${LAUNCHER_MODULES} ${ZSCRIPT_MODULES})
include(${module})
set_source_files_properties(${module} PROPERTIES HEADER_FILE_ONLY true)
endforeach()
#############################################################
# Build the ZScript parser
#############################################################
find_package(BISON QUIET)
find_package(FLEX QUIET)
if(${BISON_FOUND} AND ${FLEX_FOUND})
if(MSVC)
set(FLEXFLAGS "--wincompat")
endif()
FLEX_TARGET(ZScriptLexer ${CMAKE_SOURCE_DIR}/src/parser/ffscript.lpp ${CMAKE_SOURCE_DIR}/src/parser/lex.yy.cpp COMPILE_FLAGS ${FLEXFLAGS})
BISON_TARGET(ZScriptParser ${CMAKE_SOURCE_DIR}/src/parser/ffscript.ypp ${CMAKE_SOURCE_DIR}/src/parser/y.tab.cpp COMPILE_FLAGS -v)
add_flex_bison_dependency(ZScriptLexer ZScriptParser)
else()
message(FATAL_ERROR "Flex and Bison not found. ZQuest cannot be compiled without these.")
endif()
#############################################################
# Global settings for the different platforms
#############################################################
# Windows
if(WIN32)
# Prevents definition of min and max macros, which conflict with std::min and std::max
add_definitions(-DNOMINMAX)
string(REGEX MATCH "MSVC" CMAKE_COMPILER_IS_MSVC "${CMAKE_C_COMPILER_ID}")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.20.2750.8)
message(FATAL_ERROR "MSVC version ${CMAKE_CXX_COMPILER_VERSION} is too old. Must use at least 2019 version 16.0.0")
endif()
endif()
if(MSVC)
# Turn off warnings for all targets that aren't ours (set later in Misc. section)
add_compile_options(/W0)
# Build in parallel - speeds up the build on multicore machines.
add_compile_options(/MP)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCD /SUBSYSTEM:WINDOWS /LARGEADDRESSAWARE /OPT:NOICF")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
elseif(EMSCRIPTEN)
add_definitions(-DALLEGRO_LINUX) # Mistakenly used in the source.
add_compile_options("-m32")
# TODO: remove?
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32 -static-libgcc -export-dynamic")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32 -static-libgcc")
elseif(LINUX)
add_definitions(-DALLEGRO_LINUX) # Mistakenly used in the source.
add_definitions(-DALLEGRO_LEGACY_NO_FIX_ALIASES)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -export-dynamic")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
endif()
endif()
if(MSVC)
# REQUIRED or else MSVC throws internal compiler error(!)
add_compile_options("/fp:fast")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# TODO: GCC w/ these flags don't quite match the behavior of MSVC or clang, as seen in a replay report:
# https://zc-replay-compare-3700187020.surge.sh/
# The difference is trivial (and isolated to just stuff re: Patras, or maybe Sin/Cos, unclear), and actually GCC
# looks more "correct". Should re-assess fp-rounding to guarentee same playback for any compiler; should either:
# 1) ignore some frames for purposes of replay assert
# 2) investigate more how to get exact same behavior from gcc
# 3) investigate removing the fp flags from all compilers and seeing if results can be made to be consistent;
# would require a workaround for the MSVC internal compiler error mentioned above.
#
# In the meantime, we just use clang or msvc (never gcc) for replay tests (and for building release), which seems fine long term.
# https://stackoverflow.com/a/36502370/2788187
add_compile_options(-funsafe-math-optimizations -ffinite-math-only -fno-math-errno -fno-signaling-nans -fno-rounding-math -fcx-limited-range)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options("-ffp-model=fast")
endif()
# Optimize the math functions always, even for debug mode. This reduces many inconsistencies with replays
# in non-Release builds.
if(MSVC)
# error D8016: '/O2' and '/RTC1' command-line options are incompatible
# set_source_files_properties(src/base/zc_math.cpp PROPERTIES COMPILE_FLAGS /O2)
else()
set_source_files_properties(src/base/zc_math.cpp PROPERTIES COMPILE_FLAGS -O3)
endif()
#############################################################
# Allegro Graphics Addons
#############################################################
add_library(alpng STATIC
allegro-addons/loadpng/loadpng.c
allegro-addons/loadpng/regpng.c
allegro-addons/loadpng/savepng.c
)
target_link_libraries(alpng PUBLIC
allegro_with_legacy
${PNG_LIBRARIES}
)
target_include_directories(alpng PUBLIC
allegro-addons/loadpng
)
target_include_directories(alpng PRIVATE
${PNG_INCLUDE_DIRS}
)
list(APPEND IMAGELIBS alpng)
add_library(algif STATIC
allegro-addons/algif/src/save_gif.cpp
allegro-addons/algif/src/load_gif.cpp
)
target_include_directories(algif PUBLIC
allegro-addons/algif/include
)
target_link_libraries(algif PUBLIC allegro_with_legacy)
list(APPEND IMAGELIBS algif)
add_library(al5img STATIC
allegro-addons/al5img/src/al5img.c
)
target_include_directories(al5img PUBLIC
allegro-addons/al5img/include
)
target_link_libraries(al5img PUBLIC allegro_with_legacy algif)
list(APPEND IMAGELIBS al5img)
#############################################################
# Common libraries
#############################################################
# Remove once generally available in all compilers for c++ 20.
add_library(fmt STATIC
src/fmt/format.cc
)
target_include_directories(fmt PUBLIC include/fmt)
set(zcbase_sources
src/base/about.cpp
src/base/colors.cpp
src/base/combo.cpp
src/base/cpos_info.cpp
src/base/cpool.cpp
src/base/dmap.cpp
src/base/fonts.cpp
src/base/general.cpp
src/base/gui.cpp
src/base/hotkey.cpp
src/base/jwinfsel.cpp
src/base/mapscr.cpp
src/base/misctypes.cpp
src/base/module.cpp
src/base/msgstr.cpp
src/base/process_management.cpp
src/base/qrs.cpp
src/base/random.cpp
src/base/render.cpp
src/base/sin1.cpp
src/base/util.cpp
src/base/win32.cpp
src/base/zapp.cpp
src/base/zc_alleg.cpp
src/base/zc_math.cpp
src/base/zdefs.cpp
src/base/zsys.cpp
)
if (EMSCRIPTEN)
list(APPEND zcbase_sources src/base/emscripten_utils.cpp)
endif()
add_library(zcbase STATIC ${zcbase_sources})
target_link_libraries(zcbase PUBLIC allegro_with_legacy fmt)
target_include_directories(zcbase PUBLIC src)
if(NOT WIN32)
target_include_directories(zcbase PUBLIC include/pstream)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_link_options(zcbase PRIVATE "/WHOLEARCHIVE")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_link_options(zcbase PRIVATE "-force_load")
endif()
add_library(zcgui STATIC
src/gui/button.cpp
src/gui/checkbox_qr.cpp
src/gui/checkbox.cpp
src/gui/colorsel.cpp
src/gui/common.cpp
src/gui/ddpanel.cpp
src/gui/dialog_ref.cpp
src/gui/dialog_runner.cpp
src/gui/drop_down_list.cpp
src/gui/frame.cpp
src/gui/grid.cpp
src/gui/label.cpp
src/gui/list_data.cpp
src/gui/list.cpp
src/gui/qrpanel.cpp
src/gui/radio.cpp
src/gui/radioset.cpp
src/gui/scrolling_pane.cpp
src/gui/size.cpp
src/gui/switcher.cpp
src/gui/tabpanel.cpp
src/gui/tabref.cpp
src/gui/text_field.cpp
src/gui/top_level.cpp
src/gui/widget.cpp
src/gui/window.cpp
src/gui/slider.cpp
)
target_link_libraries(zcgui PUBLIC allegro_with_legacy)
target_include_directories(zcgui PRIVATE src)
#############################################################
# ZConsole
#############################################################
if(WIN32)
add_executable(zconsole src/zconsole/ConsoleLoggerHelper.cpp)
target_link_options(zconsole PRIVATE "/SUBSYSTEM:CONSOLE")
endif()
add_library(zconsolelogger STATIC src/zconsole/ConsoleLogger.cpp)
target_link_libraries(zconsolelogger PUBLIC allegro_with_legacy zcbase)
#############################################################
# Sound Library
#############################################################
if(EMSCRIPTEN)
set(BUILD_SOUND_LIBS_FROM_SOURCE OFF)
else()
set(BUILD_SOUND_LIBS_FROM_SOURCE ON)
endif()
if(BUILD_SOUND_LIBS_FROM_SOURCE)
if(WIN32)
set(SOUND_LIB_SHARED STATIC)
else()
set(SOUND_LIB_SHARED SHARED)
endif()
FetchContent_Declare(
gme_external
GIT_REPOSITORY https://bitbucket.org/mpyne/game-music-emu.git
GIT_TAG 6cd4bdb69be304f58c9253fb08b8362f541b3b4b
)
set(GME_YM2612_EMU "Nuked" CACHE STRING "Which YM2612 emulator to use: \"Nuked\" (LGPLv2.1+), \"MAME\" (GPLv2+), or \"GENS\" (LGPLv2.1+)")
option(ENABLE_UBSAN "" OFF)
FetchContent_MakeAvailable(gme_external)
add_library(gme_headers INTERFACE)
target_include_directories(gme_headers INTERFACE ${gme_external_SOURCE_DIR}/gme)
target_link_libraries(gme_headers INTERFACE ${ZLIB_LIBRARIES})
target_compile_definitions(gme_headers INTERFACE -DVGM_YM2612_NUKED)
option(BUILD_EXAMPLES "" OFF)
set(ALLEGRO_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/allegro-legacy/include)
set(ALLEGRO_LIBRARY allegro_with_legacy)
FetchContent_Declare(
dumb_external
GIT_REPOSITORY https://github.com/kode54/dumb.git
GIT_TAG 396caa4d31859045ccb5ef943fd430ca4026cce8
PATCH_COMMAND git restore . && git apply ${CMAKE_SOURCE_DIR}/allegro-addons/aldumb.patch
)
FetchContent_MakeAvailable(dumb_external)
add_library(dumb_headers INTERFACE)
target_include_directories(dumb_headers INTERFACE ${dumb_external_SOURCE_DIR}/include)
set(SOUNDLIBS alpng gme gme_headers aldmb dumb dumb_headers)
endif()
if(MSVC AND (MSVC_VERSION GREATER 1600))
set(ZCSOUNDLIBSEXTRA legacy_stdio_definitions)
endif()
add_library(zcsound SHARED ${ZCSOUNDSOURCES})
target_link_libraries(zcsound PUBLIC allegro_with_legacy zcbase ${SOUNDLIBS} ${ZCSOUNDLIBSEXTRA} allegro_audio allegro_acodec)
if(BUILD_SOUND_LIBS_FROM_SOURCE)
target_compile_definitions(zcsound PRIVATE SOUND_LIBS_BUILT_FROM_SOURCE)
else()
target_include_directories(zcsound PRIVATE include/dumb include/gme)
endif()
#############################################################
# Zelda
#############################################################
if(MSVC)
list(APPEND ZELDAEXTRASOURCES zc_icon.rc)
elseif(LINUX)
list(APPEND ZELDAEXTRASOURCES zc_icon.c src/single_instance_unix.cpp)
endif()
if(UNITY_BUILD)
enable_unity_build(ZeldaCore ZELDA_CORE_SOURCES)
enable_unity_build(ZeldaGUI ZELDA_GUI_SOURCES)
enable_unity_build(ZeldaSprite ZELDA_SPRITE_SOURCES)
enable_unity_build(ZeldaSubscreen ZELDA_SUBSCREEN_SOURCES)
endif()
add_executable(zplayer ${ZELDA_CORE_SOURCES} ${ZELDA_GUI_SOURCES} ${ZELDA_SPRITE_SOURCES} ${ZELDA_SUBSCREEN_SOURCES} ${ZELDA_SCRIPTING_SOURCES} ${ZELDAEXTRASOURCES} ${ZELDA_MODULES})
target_compile_definitions(zplayer PRIVATE IS_PLAYER)
set_property(TARGET zplayer PROPERTY VS_DPI_AWARE "PerMonitor")
target_include_directories(zplayer PRIVATE include/xxhash)
target_link_libraries(zplayer PRIVATE allegro_with_legacy)
if(WIN32)
target_link_libraries(zplayer PRIVATE zconsolelogger zcbase zcgui zcsound winmm ${IMAGELIBS} ${ZELDALIBSEXTRA})
elseif(LINUX)
target_link_libraries(zplayer PRIVATE zconsolelogger zcbase zcgui zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA})
elseif(APPLE)
target_link_libraries(zplayer PRIVATE zconsolelogger zcbase zcgui zcsound ${IMAGELIBS} ${ZELDALIBSEXTRA})
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
FetchContent_Declare(
asmjit
GIT_REPOSITORY
https://github.com/asmjit/asmjit.git
GIT_TAG
e13642567393a4bfc8c5607b33337b2ed3b0d01e
)
FetchContent_MakeAvailable(asmjit)
target_link_libraries(zplayer PRIVATE asmjit)
target_compile_definitions(zplayer PRIVATE ZC_JIT)
get_target_property(asm_compile_options asmjit COMPILE_OPTIONS)
string(REPLACE "$<NOT:$<CONFIG:Debug>>" "$<NOT:$<CONFIG:Debug,Asan>>" asm_compile_options "${asm_compile_options}")
set_target_properties(asmjit PROPERTIES COMPILE_OPTIONS "${asm_compile_options}")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND WIN32)
target_compile_definitions(zplayer PRIVATE ZC_WIN_32)
endif()
#############################################################
# ZQuest
#############################################################
if(MSVC)
list(APPEND ZQUESTEXTRASOURCES zq_icon.rc)
elseif(LINUX)
list(APPEND ZQUESTEXTRASOURCES zq_icon.c src/single_instance_unix.cpp)
endif()
if(UNITY_BUILD)
enable_unity_build(ZQuestCore ZQUEST_CORE_SOURCES)
enable_unity_build(ZQuestGUI ZQUEST_GUI_SOURCES)
enable_unity_build(ZQuestMisc ZQUEST_MISC_SOURCES)
enable_unity_build(ZQuestZScript PARSER_SOURCES)
endif()
add_executable(zquest ${ZQUEST_CORE_SOURCES} ${ZQUEST_GUI_SOURCES} ${ZQUEST_MISC_SOURCES} ${ZQUESTEXTRASOURCES} ${ZQUEST_MODULES})
set_property(TARGET zquest PROPERTY VS_DPI_AWARE "PerMonitor")
target_link_libraries(zquest PUBLIC allegro_with_legacy zconsolelogger zcbase zcgui zcsound ${IMAGELIBS} ${ZQUESTLIBSEXTRA})
target_include_directories(zquest PRIVATE src)
if(MSVC)
target_compile_definitions(zcsound PRIVATE ZCM_DLL)
target_compile_definitions(zplayer PRIVATE ZCM_DLL_IMPORT)
target_compile_definitions(zquest PRIVATE ZCM_DLL_IMPORT)
endif()
target_compile_definitions(zquest PRIVATE IS_ZQUEST)
if(WIN32)
set_source_files_properties(
src/dialog/itemeditor.cpp
src/dialog/init_data.cpp
src/dialog/comboeditor.cpp
src/dialog/combowizard.cpp
src/parser/GlobalSymbols.cpp
PROPERTIES COMPILE_FLAGS "/bigobj"
)
endif()
#############################################################
# ZScript parser
#############################################################
if(${BISON_FOUND} AND ${FLEX_FOUND})
add_executable(zscript ${ZSCRIPT_CORE_SOURCES} ${PARSER_SOURCES} ${BISON_ZScriptParser_OUTPUTS} ${FLEX_ZScriptLexer_OUTPUTS} ${ZSCRIPT_MODULES})
target_include_directories(zscript PRIVATE src)
target_link_libraries(zscript PRIVATE allegro_with_legacy zcbase zconsolelogger ${ZSCRIPTLIBSEXTRA})
target_compile_definitions(zscript PRIVATE IS_PARSER)
endif()
#############################################################
# Launcher
#############################################################
if(MSVC)
list(APPEND LAUNCHEREXTRASOURCES zl_icon.rc)
elseif(LINUX)
list(APPEND LAUNCHEREXTRASOURCES zl_icon.c src/single_instance_unix.cpp)
endif()
add_executable(zlauncher ${LAUNCHER_SOURCES} ${LAUNCHER_GUI_SOURCES} ${LAUNCHEREXTRASOURCES})
target_compile_definitions(zlauncher PRIVATE IS_LAUNCHER)
set_property(TARGET zlauncher PROPERTY VS_DPI_AWARE "PerMonitor")
target_link_libraries(zlauncher PRIVATE allegro_with_legacy zcbase zcgui zconsolelogger ${LAUNCHERLIBSEXTRA})
#############################################################
# Standalone
#############################################################
if(WIN32)
add_executable(zstandalone src/standalone/standalone.cpp)
target_link_options(zstandalone PRIVATE "/SUBSYSTEM:WINDOWS")
add_dependencies(zquest zstandalone)
endif()
#############################################################
# ZUpdater
#############################################################
# TODO give zupdater its own icon.
if(MSVC)
list(APPEND UPDATEREXTRASOURCES zl_icon.rc)
elseif(LINUX)
list(APPEND UPDATEREXTRASOURCES zl_icon.c)
endif()
add_executable(zupdater src/zupdater/zupdater.cpp src/zconfig.cpp ${UPDATEREXTRASOURCES})
target_compile_definitions(zupdater PRIVATE ZUPDATER)
target_link_libraries(zupdater PRIVATE allegro_with_legacy fmt zcbase)
target_include_directories(zupdater PRIVATE src)
if(WIN32)
target_link_options(zupdater PRIVATE "/SUBSYSTEM:WINDOWS")
endif()
#############################################################
# Emscripten
#############################################################
if (EMSCRIPTEN)
target_link_options(zplayer PRIVATE "SHELL:-s EXPORTED_FUNCTIONS=_main,_get_shareable_url,_create_synthetic_key_event")
target_link_options(zquest PRIVATE "SHELL:-s EXPORTED_FUNCTIONS=_main,_get_shareable_url,_create_synthetic_key_event,_open_test_mode")
target_link_options(zscript PRIVATE "SHELL:-s PTHREAD_POOL_SIZE=1" "SHELL:-s EXTRA_EXPORTED_RUNTIME_METHODS=['FS','PROXYFS']")
set_target_properties(zscript PROPERTIES SUFFIX ".mjs")
endif()
#############################################################
# Misc.
#############################################################
set(zc_targets zquest zplayer zlauncher zcbase zcgui zcsound zscript zconsolelogger zupdater)
set(zc_clang_errors
-Werror=array-bounds
-Werror=format
-Werror=inconsistent-missing-override
-Werror=return-type
-Werror=unreachable-code
# -Werror=unused
-Wno-write-strings
-Wno-switch
)
set(zc_gcc_errors
-Werror=array-bounds
-Werror=format
-Werror=format-overflow
-Werror=return-type
-Werror=unreachable-code
# -Werror=unused
-Wno-write-strings
-Wno-switch
# TODO
# -Wunused-result
)
if(WANT_SENTRY)
set(SENTRY_VERSION 0.6.3)
set(SENTRY_BACKEND crashpad)
set(SENTRY_BUILD_SHARED_LIBS OFF)
FetchContent_Declare(sentry URL https://github.com/getsentry/sentry-native/releases/download/${SENTRY_VERSION}/sentry-native.zip)
FetchContent_MakeAvailable(sentry)
foreach(target IN LISTS zc_targets)
target_link_libraries(${target} PRIVATE sentry)
target_compile_definitions(${target} PRIVATE HAS_SENTRY)
endforeach()
endif()
if(RELEASE_TAG)
foreach(target IN LISTS zc_targets)
target_compile_definitions(${target} PRIVATE RELEASE_TAG="${RELEASE_TAG}")
endforeach()
endif()
if(RELEASE_CHANNEL)
foreach(target IN LISTS zc_targets)
target_compile_definitions(${target} PRIVATE RELEASE_CHANNEL="${RELEASE_CHANNEL}")
endforeach()
endif()
if(REPO)
foreach(target IN LISTS zc_targets)
target_compile_definitions(${target} PRIVATE REPO="${REPO}")
endforeach()
endif()
if(WANT_FUZZ)
foreach(target IN LISTS zc_targets)
target_compile_definitions(${target} PRIVATE ZC_FUZZ)
endforeach()
endif()
if (WIN32)
list(APPEND zc_targets zconsole zstandalone)
add_dependencies(zplayer zconsole)
endif()
if(USE_PCH)
foreach(target IN LISTS zc_targets)
target_precompile_headers(${target}
PRIVATE
[["base/zc_alleg.h"]]
<cassert>
<cctype>
<cmath>
<cstdarg>
<cstdint>
<cstdio>
<cstdlib>
<cstring>
<map>
<set>
<string>
<vector>
)
endforeach()
endif()
foreach(target IN LISTS zc_targets)
if(WIN32)
target_compile_definitions(${target} PRIVATE __STDC_LIMIT_MACROS)
# TODO: set /W2 higher.
target_compile_options(${target} PRIVATE /W2 /WX)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT EMSCRIPTEN)
target_compile_options(${target} PRIVATE -Wall)
# Uncomment to autofix. Only works for clang. When done, comment this line out again.
# target_compile_options(${target} PRIVATE -ferror-limit=10000 -Wno-everything ${zc_clang_errors} "SHELL:-Xclang -fix-what-you-can" "SHELL:-Xclang -fixit-recompile")
target_compile_options(${target} PRIVATE ${zc_clang_errors})
endif()
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
target_compile_options(${target} PRIVATE -Wall ${zc_gcc_errors})
endif()
endforeach()
# Disable warnings for generated file.
if(WIN32)
set_source_files_properties(src/parser/lex.yy.cpp PROPERTIES COMPILE_FLAGS /W0)
else()
set_source_files_properties(src/parser/lex.yy.cpp PROPERTIES COMPILE_FLAGS -Wno-everything)
endif()
find_program(PYTHON python3 python REQUIRED)
add_custom_command(
COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/package.py --skip_binaries --copy_to_build_folder --build_folder "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>" --keep_existing_files
OUTPUT copy_resources_if_not_exist.stamp
)
add_custom_target(copy_resources_if_not_exist DEPENDS copy_resources_if_not_exist.stamp)
set_source_files_properties(copy_resources_if_not_exist.stamp PROPERTIES SYMBOLIC 1)
add_custom_command(
COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/package.py --skip_binaries --copy_to_build_folder --build_folder "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>"
OUTPUT copy_resources.stamp
)
add_custom_target(copy_resources DEPENDS copy_resources.stamp)
set_source_files_properties(copy_resources.stamp PROPERTIES SYMBOLIC 1)
add_custom_command(
COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/package.py --build_folder "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>" --clean_first
OUTPUT package.stamp
DEPENDS ${zc_targets}
)
add_custom_target(package DEPENDS package.stamp)
set_source_files_properties(package.stamp PROPERTIES SYMBOLIC 1)
add_custom_command(
COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/package.py --build_folder "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>" --clean_first --skip_archive
OUTPUT package_no_archive.stamp
DEPENDS ${zc_targets}
)
add_custom_target(package_no_archive DEPENDS package_no_archive.stamp)
set_source_files_properties(package_no_archive.stamp PROPERTIES SYMBOLIC 1)
if(COPY_RESOURCES)
foreach(target IN LISTS zc_targets)
add_dependencies(${target} copy_resources_if_not_exist)
endforeach()
endif()
# Add some targets for running replay tests.
# TODO: Visual Studio can't cancel custom commands from CMake
# https://gitlab.kitware.com/cmake/cmake/-/issues/25183
# https://stackoverflow.com/q/43364914
function (create_replay_tests_target target_name)
list(SUBLIST ARGV 1 -1 command_args)
add_custom_command(
USES_TERMINAL
COMMAND ${PYTHON} -Xutf8 ${CMAKE_CURRENT_SOURCE_DIR}/tests/run_replay_tests.py --no-emoji --build_folder "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>" ${command_args}
OUTPUT ${target_name}.stamp
DEPENDS zelda
)
add_custom_target(${target_name} DEPENDS ${target_name}.stamp)
set_source_files_properties(${target_name}.stamp PROPERTIES SYMBOLIC 1)
endfunction()
# Run everything.
create_replay_tests_target(run_replay_tests_all --assert)
# Run just the short ones.
create_replay_tests_target(run_replay_tests_basic --assert --filter playground --filter classic_1st.zplay --filter dark)
# Don't use jit, just because there is lots of overhead to compilation that will make it a waste when
# running just a few seconds.
create_replay_tests_target(run_replay_tests_all_1s --assert --no-jit --max_duration 1)
create_replay_tests_target(run_replay_tests_all_10s --assert --no-jit --max_duration 10)
create_replay_tests_target(run_replay_tests_all_100s --assert --no-jit --max_duration 100)
#############################################################
# Visual Studio
#############################################################
if(CMAKE_GENERATOR MATCHES "Visual Studio")
# "Edit and Continue" functionality
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT zquest)
# Configure "Debug" option in VS to use the correct working directory, otherwise it fails to load zc configuration files
set_property(TARGET ${zc_targets} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "$(ProjectDir)$(Configuration)")
# Organize into folders
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_target_properties(zplayer zquest zscript zlauncher zupdater package package_no_archive PROPERTIES FOLDER "")
set_target_properties(run_replay_tests_all run_replay_tests_basic run_replay_tests_all_1s run_replay_tests_all_10s run_replay_tests_all_100s PROPERTIES FOLDER "Replay Tests")
set_target_properties(zcbase zcgui zcsound PROPERTIES FOLDER "Our Libraries")
set_target_properties(gme dumb aldmb PROPERTIES FOLDER Sound)
set_target_properties(allegro allegro_audio allegro_acodec allegro_image allegro_font allegro_main allegro_primitives allegro_dialog allegro-legacy al5img algif alpng PROPERTIES FOLDER Allegro)
set_target_properties(zconsole zconsolelogger PROPERTIES FOLDER ZConsole)
if(WANT_SENTRY)
set_target_properties(crashpad_client crashpad_compat crashpad_getopt crashpad_handler crashpad_handler_lib crashpad_minidump crashpad_snapshot crashpad_tools crashpad_util crashpad_zlib mini_chromium sentry PROPERTIES FOLDER Sentry)
endif()
# Put everything else in "Other" folder
function(get_all_targets var)
set(targets)
get_all_targets_recursive(targets ${CMAKE_CURRENT_SOURCE_DIR})
set(${var} ${targets} PARENT_SCOPE)
endfunction()
macro(get_all_targets_recursive targets dir)
get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
foreach(subdir ${subdirectories})
get_all_targets_recursive(${targets} ${subdir})
endforeach()
get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS)
list(APPEND ${targets} ${current_targets})
endmacro()
get_all_targets(all_targets)
foreach(target IN LISTS all_targets)
get_property(folder_set TARGET ${target} PROPERTY FOLDER SET)
if(NOT folder_set)
set_target_properties(${target} PROPERTIES FOLDER Other)
endif()
endforeach()
# The sound system has a known memory issue, so for now set the default debugging args to disable sound.
set_property(TARGET ${zc_targets} PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "$<$<CONFIG:ASAN>:-s>")
endif()