-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
840 lines (786 loc) · 33.3 KB
/
Copy pathCMakeLists.txt
File metadata and controls
840 lines (786 loc) · 33.3 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
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
# Copyright (C) 2016-2023,2025,2026 Rodrigo Jose Hernandez Cordoba
#
# 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.12.0)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0072 NEW)
if(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif(POLICY CMP0020)
if(POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif(POLICY CMP0053)
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif(POLICY CMP0074)
endif(COMMAND cmake_policy)
# VCPKG_MANIFEST_FEATURES must be set before project() so vcpkg installs the
# required ports during the configure step.
# Note: MSVC is not set until project(), so check the generator instead.
if(CMAKE_GENERATOR MATCHES "Visual Studio" AND USE_AEONGUI)
list(APPEND VCPKG_MANIFEST_FEATURES "aeongui")
endif()
project(AeonEngine)
enable_testing()
enable_language(CXX)
enable_language(C)
if(NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
list(APPEND CMAKE_PREFIX_PATH "$ENV{MSYSTEM_PREFIX}")
endif()
define_property(GLOBAL PROPERTY PLUGINS INHERITED
BRIEF_DOCS "Built Plugin List"
FULL_DOCS "Plugin Targets should add an entry to this list in order to be included into the configuration file.")
define_property(GLOBAL PROPERTY SHARED_LIBRARIES INHERITED
BRIEF_DOCS "List of shared library targets"
FULL_DOCS "List of shared library targets")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
include(compiler_settings)
set(PROXY "" CACHE STRING "Proxy server string for downloads.")
if(PROXY)
set(ENV{http_proxy} "${PROXY}")
set(ENV{https_proxy} "${PROXY}")
set(ENV{ftp_proxy} "${PROXY}")
endif()
set(Portaudio_FIND_QUIETLY ON)
find_program(XXD_EXECUTABLE xxd
HINTS ENV
MSYSTEM_PREFIX
ChocolateyInstall)
find_program(BASH_EXECUTABLE bash HINTS ENV MSYSTEM_PREFIX)
find_program(ZSH_EXECUTABLE zsh HINTS ENV MSYSTEM_PREFIX)
find_program(GLOBAL_EXECUTABLE
NAMES global global.exe
HINTS ENV MSYSTEM_PREFIX)
find_program(CLANG_EXECUTABLE
NAMES clang clang.exe
HINTS ENV MSYSTEM_PREFIX)
find_program(CLANG_TIDY_EXECUTABLE
NAMES clang-tidy clang-tidy.exe
HINTS ENV MSYSTEM_PREFIX)
find_package(PkgConfig)
find_package(Git)
find_package(ZLIB)
find_package(Threads)
find_package(Portaudio)
find_package(OggVorbis)
include(FindPythonModule)
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
include(CheckIncludeFiles)
find_package (Python3 COMPONENTS Interpreter)
find_package(ImageMagick OPTIONAL_COMPONENTS convert)
find_package(Protobuf CONFIG)
if(NOT Protobuf_FOUND)
find_package(Protobuf REQUIRED)
if(Protobuf_FOUND AND PKG_CONFIG_FOUND AND NOT Protobuf_LIBRARIES MATCHES "absl")
pkg_search_module(Protobuf REQUIRED protobuf)
endif()
else()
set(Protobuf_LIBRARIES protobuf::libprotobuf)
set(Protobuf_PROTOC_EXECUTABLE protobuf::protoc)
endif()
get_filename_component(PYTHON_PATH "${Python3_EXECUTABLE}" DIRECTORY)
find_program(AUTOPEP8_EXECUTABLE autopep8
HINTS ENV
MSYSTEM_PREFIX
"${PYTHON_PATH}/Scripts")
find_program(CMAKE_FORMAT_EXECUTABLE cmake-format
HINTS ENV MSYSTEM_PREFIX)
if(NOT APPLE)
option(BUILD_OPENGL_RENDERER "Build the OpenGL renderer" ON)
else()
set(BUILD_OPENGL_RENDERER OFF CACHE BOOL "OpenGL Renderer is disabled on Apple, 4.5 is not supported" FORCE)
endif()
option(BUILD_VULKAN_RENDERER "Build the Vulkan renderer" ON)
set(BUILD_METAL_RENDERER_DEFAULT OFF)
if(APPLE AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$")
set(BUILD_METAL_RENDERER_DEFAULT ON)
endif()
option(BUILD_METAL_RENDERER "Build the native Metal renderer (Apple Silicon, macOS 13+)" ${BUILD_METAL_RENDERER_DEFAULT})
if(BUILD_METAL_RENDERER)
if(NOT APPLE)
message(FATAL_ERROR "BUILD_METAL_RENDERER is only supported on macOS")
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$")
message(FATAL_ERROR "BUILD_METAL_RENDERER requires Apple Silicon (arm64)")
endif()
if(CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 13.0)
message(FATAL_ERROR "BUILD_METAL_RENDERER requires CMAKE_OSX_DEPLOYMENT_TARGET >= 13.0")
endif()
endif()
option(USE_AEONGUI "Use the AeonGUI library for the user interface" OFF)
# libc++ only exposes floating point std::to_chars, which std::format needs, from macOS 13.3 on.
if(APPLE AND USE_AEONGUI AND CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 13.3)
message(FATAL_ERROR "USE_AEONGUI requires CMAKE_OSX_DEPLOYMENT_TARGET >= 13.3")
endif()
if(USE_AEONGUI)
if(MSVC)
find_package(aeongui CONFIG REQUIRED)
else()
include(FetchContent)
set(BUILD_UNIT_TESTS OFF CACHE BOOL "" FORCE)
set(DISABLE_DEMOS ON CACHE BOOL "" FORCE)
set(BACKEND "Cairo" CACHE STRING "" FORCE)
FetchContent_Declare(AeonGUI
GIT_REPOSITORY https://github.com/AeonGames/AeonGUI.git
GIT_TAG 1fc793a7f4fe71b7743b2d51a723bb70244c80dd
GIT_SHALLOW OFF
)
FetchContent_MakeAvailable(AeonGUI)
endif()
endif()
if(CLANG_TIDY_EXECUTABLE)
option(USE_CLANG_TIDY "Use of clang-tidy (Requires CMake 3.6.0 or Higher)"
OFF)
set(CLANG_TIDY_CHECKS
"-warnings-as-errors=performance-*,modernize-*,-modernize-pass-by-value"
"-checks=performance-*,modernize-*,-modernize-pass-by-value")
endif()
if(CMAKE_HOST_UNIX)
set(PATH_SEPARATOR :)
elseif(CMAKE_HOST_WIN32)
set(PATH_SEPARATOR $<SEMICOLON>)
endif()
function(gnu_sed_check validator_result_var item)
execute_process(COMMAND ${item} --version
RESULT_VARIABLE sed_result
OUTPUT_VARIABLE sed_output
ERROR_VARIABLE sed_error
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if(sed_output MATCHES "GNU sed")
message(STATUS "Found GNU sed: ${item}")
set(${validator_result_var} TRUE PARENT_SCOPE)
else()
set(${validator_result_var} FALSE PARENT_SCOPE)
endif()
endfunction()
find_program(SED_EXECUTABLE NAMES gsed sed
PATHS ENV MSYSTEM_PREFIX ENV ProgramFiles
PATH_SUFFIXES
bin
usr/bin
Git/usr/bin
VALIDATOR gnu_sed_check
)
if(NOT SED_EXECUTABLE)
message(FATAL_ERROR "Unable to find sed executable.")
endif()
find_program(GREP_EXECUTABLE grep
PATHS ENV
MSYSTEM_PREFIX
ProgramFiles
PATH_SUFFIXES
usr/bin
Git/usr/bin
)
if(NOT GREP_EXECUTABLE)
message(FATAL_ERROR "Unable to find grep executable.")
endif()
find_package(Doxygen)
if(DOXYGEN_FOUND)
if(DOXYGEN_DOT_FOUND)
set(HAVE_DOT "YES")
else()
set(HAVE_DOT "NO")
endif()
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_HASH)
else()
set(GIT_HASH "Unknown Build")
endif()
set(DOXYGEN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/docs")
configure_file("${CMAKE_SOURCE_DIR}/cmake/Doxyfile.in" "${CMAKE_BINARY_DIR}/Doxyfile" @ONLY)
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
endif()
add_subdirectory(proto)
add_subdirectory(tools/aeontool)
if(BUILD_METAL_RENDERER)
find_program(GLSLANG_VALIDATOR_EXECUTABLE glslangValidator REQUIRED)
find_program(SPIRV_CROSS_EXECUTABLE spirv-cross REQUIRED)
find_program(XCRUN_EXECUTABLE xcrun REQUIRED)
execute_process(COMMAND ${XCRUN_EXECUTABLE} --sdk macosx --show-sdk-path
OUTPUT_VARIABLE METAL_SDK_ROOT
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND ${XCRUN_EXECUTABLE} --sdk macosx --find metal
OUTPUT_VARIABLE METAL_COMPILER_EXECUTABLE
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE METAL_COMPILER_RESULT
ERROR_QUIET)
if(NOT METAL_COMPILER_RESULT EQUAL 0 OR NOT EXISTS "${METAL_COMPILER_EXECUTABLE}")
message(FATAL_ERROR
"The downloaded Metal compiler is unavailable. Run: xcodebuild -downloadComponent MetalToolchain")
endif()
add_subdirectory(tools/metalshader)
endif()
add_subdirectory(tools/blender)
add_subdirectory(engine)
option(BUILD_STANDALONE_APPLICATION "Build the standalone application" ON)
if(BUILD_STANDALONE_APPLICATION)
add_subdirectory(application)
endif()
find_package(Qt6
COMPONENTS LinguistTools
Core
Gui
Widgets)
if(Qt6_FOUND)
add_subdirectory(tools/worldeditor)
endif()
find_package(GTest)
if(GTest_FOUND)
find_library(GMOCK_LIBRARY
NAMES gmock libgmock libgmock.a
PATHS "${GTEST_DIR}"
PATH_SUFFIXES lib)
find_library(GMOCK_LIBRARY_DEBUG
NAMES gmockd libgmockd libgmockd.a
PATHS "${GTEST_DIR}"
PATH_SUFFIXES lib)
add_subdirectory(tests)
endif()
#
# Code Formating on pre-commit hook
#
if(WIN32)
find_program(ASTYLE_EXECUTABLE astyle
HINTS ENV ProgramData
PATH_SUFFIXES /usr/bin chocolatey/bin)
find_program(FIND_EXECUTABLE find
HINTS ENV ProgramFiles
PATH_SUFFIXES /usr/bin Git/usr/bin)
else()
find_program(FIND_EXECUTABLE find)
find_program(ASTYLE_EXECUTABLE astyle)
endif()
set(ASTYLE_OPTIONS "--options=${CMAKE_SOURCE_DIR}/astylerc")
configure_file("${CMAKE_SOURCE_DIR}/cmake/pre-commit.in"
"${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit")
configure_file("${CMAKE_SOURCE_DIR}/cmake/commit-msg.in"
"${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg")
#
# Protobuf Python source generation target
#
add_custom_target(
generate-python-protobuf-source
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/mesh.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/skeleton.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/animation.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/model.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/pipeline.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/material.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/property.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/sampler.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/vector2.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/vector3.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/vector4.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/quaternion.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/transform.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/scene.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/reference.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/framebuffer.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/matrix4x4.proto
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
--python_out ${CMAKE_SOURCE_DIR}/tools/blender/modules
--proto_path ${CMAKE_SOURCE_DIR}/proto
${CMAKE_SOURCE_DIR}/proto/collision.proto
SOURCES ${CMAKE_SOURCE_DIR}/proto/mesh.proto
${CMAKE_SOURCE_DIR}/proto/skeleton.proto
${CMAKE_SOURCE_DIR}/proto/animation.proto
${CMAKE_SOURCE_DIR}/proto/model.proto
${CMAKE_SOURCE_DIR}/proto/pipeline.proto
${CMAKE_SOURCE_DIR}/proto/material.proto
${CMAKE_SOURCE_DIR}/proto/property.proto
${CMAKE_SOURCE_DIR}/proto/sampler.proto
${CMAKE_SOURCE_DIR}/proto/vector2.proto
${CMAKE_SOURCE_DIR}/proto/vector3.proto
${CMAKE_SOURCE_DIR}/proto/vector4.proto
${CMAKE_SOURCE_DIR}/proto/quaternion.proto
${CMAKE_SOURCE_DIR}/proto/transform.proto
${CMAKE_SOURCE_DIR}/proto/scene.proto
${CMAKE_SOURCE_DIR}/proto/reference.proto
${CMAKE_SOURCE_DIR}/proto/framebuffer.proto
${CMAKE_SOURCE_DIR}/proto/matrix4x4.proto
${CMAKE_SOURCE_DIR}/proto/collision.proto
COMMENT "Generating Protocol Buffers Python Code")
include(blender)
# Cooking assets out of .blend files needs both the module above and the
# generated Python protobuf modules, so the asset directory comes after them.
add_subdirectory(assets)
#
# Game asset generation (incremental).
#
# Each entry is "<input>=<output>"; aeontool converts one into the other. Only
# the committed meshes (.txt -> .msh/.cln) live here: their inputs exist in the
# source tree, so a custom command in this directory can depend on them. The
# generated pipelines' binary (.pln) conversions live beside the rules that
# produce their .txt (assets/shadercode/CMakeLists.txt, shader-pipelines target)
# because a consuming custom command in this directory cannot resolve a .txt
# produced by a custom command in another one on a clean build -- before CMake
# 3.20 / CMP0118 the GENERATED source-file property is directory-scoped, so make
# fails with "No rule to make target .../<name>.txt". Each output gets its own
# rule below so a build only reconverts the inputs that actually changed.
set(GAME_ASSET_CONVERSIONS
"game/meshes/suzanne.txt=game/meshes/suzanne.msh"
"game/meshes/cube.txt=game/meshes/cube.msh"
"game/meshes/cube_collision.txt=game/meshes/cube_collision.cln"
"game/meshes/aabb_wire.txt=game/meshes/aabb_wire.msh"
"game/meshes/fullscreen_triangle.txt=game/meshes/fullscreen_triangle.msh")
set(GAME_ASSET_OUTPUTS)
foreach(conversion IN LISTS GAME_ASSET_CONVERSIONS)
string(REPLACE "=" ";" conversion_parts "${conversion}")
list(GET conversion_parts 0 conversion_input)
list(GET conversion_parts 1 conversion_output)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/${conversion_output}
COMMAND $<TARGET_FILE:aeontool> convert
-i ${CMAKE_SOURCE_DIR}/${conversion_input}
-o ${CMAKE_SOURCE_DIR}/${conversion_output}
DEPENDS ${CMAKE_SOURCE_DIR}/${conversion_input} aeontool ProtoBufClasses
COMMENT "Converting ${conversion_input}"
VERBATIM)
list(APPEND GAME_ASSET_OUTPUTS ${CMAKE_SOURCE_DIR}/${conversion_output})
endforeach()
# Development textures: a -P script expands game/colors.txt into per-color
# SVG/PNG files. Its outputs are dynamic (one set per palette entry), so gate it
# on a stamp that depends on the palette and the template; it only re-runs when
# one of those changes instead of on every build.
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/development-textures.stamp
COMMAND ${CMAKE_COMMAND} -DCMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-P ${CMAKE_SOURCE_DIR}/cmake/GenerateDevelopmentTextures.cmake
COMMAND ${CMAKE_COMMAND} -E touch
${CMAKE_CURRENT_BINARY_DIR}/development-textures.stamp
DEPENDS ${CMAKE_SOURCE_DIR}/game/colors.txt
${CMAKE_SOURCE_DIR}/game/images/development.svg.in
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating development textures"
VERBATIM)
list(APPEND GAME_ASSET_OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/development-textures.stamp)
# Aggregator: building game-assets brings every converted asset up to date.
add_custom_target(game-assets DEPENDS ${GAME_ASSET_OUTPUTS})
# Build the generated pipeline .txt and their .pln binaries as part of the game
# assets. shader-pipelines owns both the .txt (including the runtime-only ones
# the engine loads at runtime) and the .pln binaries, so depending on it alone
# covers a fresh checkout.
add_dependencies(game-assets shader-pipelines)
# Tie the generated game assets to the runtime deliverables so a clean build
# always (re)generates them. After efcfff9a the generated pipeline .txt are no
# longer committed, so without this a fresh checkout would build the binaries
# but ship no pipelines and break at runtime. game-assets chains to
# shader-pipelines, so depending on it alone covers both the text pipelines and
# their binary forms. Gated on TARGET because the application and tests are
# optional subprojects.
if(TARGET game)
add_dependencies(game game-assets)
endif()
if(TARGET unit-tests)
add_dependencies(unit-tests game-assets)
endif()
#
# Clean Build Directory Target
#
if(FIND_EXECUTABLE)
add_custom_target(
clean-build
COMMAND ${FIND_EXECUTABLE} '${CMAKE_BINARY_DIR}' ! -name 'CMakeCache.txt' !
-wholename '${CMAKE_BINARY_DIR}' -exec rm -rf {} +
COMMENT "Cleaning Build you will need to rerun cmake configure and generate"
)
endif()
#
# Generate VS Code Environment
#
if("$ENV{MSYSTEM}" STREQUAL "MINGW64")
set(VSCODE_DEFAULT_PROFILE_WINDOWS "MinGW GCC Bash")
elseif("$ENV{MSYSTEM}" STREQUAL "UCRT64")
set(VSCODE_DEFAULT_PROFILE_WINDOWS "MinGW UCRT64 Bash")
elseif("$ENV{MSYSTEM}" STREQUAL "CLANG64")
set(VSCODE_DEFAULT_PROFILE_WINDOWS "MinGW Clang Bash")
else()
set(VSCODE_DEFAULT_PROFILE_WINDOWS "PowerShell")
endif()
if(CMAKE_GENERATOR MATCHES "(MSYS|Unix|MinGW) Makefiles")
set(CODE_ZOOMLEVEL "0" CACHE STRING "window.zoomLevel for VS Code.")
# TODO SOURCE_DIRECTORIES could be set and used to call add_subdirectory
# directly from this top level
set(SOURCE_DIRECTORIES ${CMAKE_SOURCE_DIR} application
# application/windows
proto
engine
engine/images
engine/images/png
engine/renderers/opengl
engine/renderers/vulkan
engine/sound/oggvorbis
engine/sound/portaudio
tools/aeontool
tools/worldeditor)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
execute_process(COMMAND ${BASH_EXECUTABLE} --login -c "echo | ${CMAKE_CXX_COMPILER} -Wp,-v -x c++ - -fsyntax-only 2>&1 | ${SED_EXECUTABLE} -n '/#include <...> search starts here:$/,/End of search list.$/p' | ${SED_EXECUTABLE} '/\\(#include <...> search starts here:$\\|End of search list.$\\)/d'"
OUTPUT_VARIABLE CXX_INCLUDE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "[ \\t]*\n[ \\t]*" ";" CXX_INCLUDE_PATH "${CXX_INCLUDE_PATH}")
string(REGEX REPLACE "[ \\t]*\\(.*\\)" "" CXX_INCLUDE_PATH "${CXX_INCLUDE_PATH}")
string(STRIP "${CXX_INCLUDE_PATH}" CXX_INCLUDE_PATH)
endif()
set(INCLIST "")
if(Qt6_FOUND)
list(APPEND INCLIST ${Qt6Core_INCLUDE_DIRS})
list(APPEND INCLIST ${Qt6Gui_INCLUDE_DIRS})
list(APPEND INCLIST ${Qt6Widgets_INCLUDE_DIRS})
endif(Qt6_FOUND)
if(BUILD_OPENGL_RENDERER)
list(APPEND INCLIST ${CMAKE_BINARY_DIR}/engine/renderers/opengl)
endif(BUILD_OPENGL_RENDERER)
if(BUILD_VULKAN_RENDERER)
list(APPEND INCLIST ${CMAKE_BINARY_DIR}/engine/renderers/vulkan)
list(APPEND INCLIST ${CMAKE_BINARY_DIR}/engine/renderers/vulkan/spirv-reflect)
endif(BUILD_VULKAN_RENDERER)
list(APPEND INCLIST ${GLSlang_INCLUDE_DIR})
list(APPEND INCLIST ${Vulkan_INCLUDE_DIR})
list(APPEND INCLIST ${Protobuf_INCLUDE_DIR})
list(APPEND INCLIST ${CXX_INCLUDE_PATH})
list(REMOVE_DUPLICATES INCLIST)
set(INCLIST "\"${INCLIST}\"")
string(REPLACE ";"
"\",\n\""
INCLIST
"${INCLIST}")
# Detect appropriate debugger based on compiler
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
find_program(LLDB_DAP_EXECUTABLE lldb-dap lldb-vscode
PATHS ENV MSYSTEM_PREFIX ENV ProgramFiles
/usr/bin /usr/local/bin
/Library/Developer/CommandLineTools/usr/bin
/Applications/Xcode.app/Contents/Developer/usr/bin
PATH_SUFFIXES
bin
usr/bin
)
if(LLDB_DAP_EXECUTABLE)
set(DEBUGGER_TYPE "lldb-dap")
set(DEBUGGER_PATH "${LLDB_DAP_EXECUTABLE}")
set(DEBUGGER_CONFIG "")
endif()
endif()
# Fall back to gdb if lldb-dap not found
if(NOT DEBUGGER_TYPE)
find_program(GDB_EXECUTABLE gdb
PATHS ENV MSYSTEM_PREFIX ENV ProgramFiles
PATH_SUFFIXES
bin
usr/bin
)
if(GDB_EXECUTABLE)
set(DEBUGGER_TYPE "cppdbg")
set(DEBUGGER_PATH "${GDB_EXECUTABLE}")
set(DEBUGGER_CONFIG ",
\"miDebuggerPath\": \"${GDB_EXECUTABLE}\",
\"MIMode\": \"gdb\",
\"additionalSOLibSearchPath\": \"C:/msys64/mingw64/bin\",
\"setupCommands\": [
{
\"description\": \"Enable pretty-printing for gdb\",
\"text\": \"-enable-pretty-printing\",
\"ignoreFailures\": true
}
]")
endif()
endif()
set(DEBUG_PATH "${CMAKE_BINARY_DIR}/bin")
if(CMAKE_GENERATOR MATCHES "(MSYS|MinGW) Makefiles")
set(DEBUG_PATH "${DEBUG_PATH};$ENV{MSYSTEM_PREFIX}/bin")
set(USE_EXTERNAL_CONSOLE "true")
else()
set(DEBUG_PATH "$ENV{PATH}:${DEBUG_PATH}")
set(USE_EXTERNAL_CONSOLE "false")
set(QT_QPA_PLATFORM "{\"name\":\"QT_QPA_PLATFORM\",\"value\":\"xcb\"},")
#set(QT_QPA_PLATFORM "{\"name\":\"QT_QPA_PLATFORM\",\"value\":\"wayland\"},")
endif()
if(Protobuf_ROOT)
set(LD_LIBRARY_PATH "{\"name\":\"LD_LIBRARY_PATH\",\"value\":\"${Protobuf_ROOT}/lib\"},")
endif()
# Build conditional launch.json configuration blocks
set(LAUNCH_CONFIGS "")
if(Qt6_FOUND)
string(APPEND LAUNCH_CONFIGS "
{
\"name\": \"World Editor\",
\"type\": \"${DEBUGGER_TYPE}\",
\"request\": \"launch\",
\"args\": [],
\"stopAtEntry\": false,
\"cwd\": \"${CMAKE_SOURCE_DIR}\",
\"environment\": [
${QT_QPA_PLATFORM}
${LD_LIBRARY_PATH}
{
\"name\":\"PATH\",
\"value\":\"${DEBUG_PATH}\"
},
{
\"name\":\"ASAN_OPTIONS\",
\"value\":\"abort_on_error=1\"
},
{
\"name\":\"OBJC_DISABLE_INITIALIZE_FORK_SAFETY\",
\"value\":\"YES\"
}
],
\"externalConsole\": ${USE_EXTERNAL_CONSOLE},
\"program\": \"${CMAKE_BINARY_DIR}/bin/worldeditor${CMAKE_EXECUTABLE_SUFFIX}\"${DEBUGGER_CONFIG}
},")
endif()
if(BUILD_STANDALONE_APPLICATION)
string(APPEND LAUNCH_CONFIGS "
{
\"name\": \"Game Window OpenGL\",
\"type\": \"${DEBUGGER_TYPE}\",
\"request\": \"launch\",
\"args\": [\"-r\",\"OpenGL\",\"-s\",\"scenes/main.txt\"],
\"stopAtEntry\": false,
\"cwd\": \"${CMAKE_SOURCE_DIR}\",
\"environment\": [
{
\"name\":\"PATH\",
\"value\":\"${DEBUG_PATH}\"
},
{
\"name\":\"_Xdebug\",
\"value\": \"1\"
}
],
\"externalConsole\": ${USE_EXTERNAL_CONSOLE},
\"program\": \"${CMAKE_BINARY_DIR}/bin/game${CMAKE_EXECUTABLE_SUFFIX}\"${DEBUGGER_CONFIG}
},
{
\"name\": \"Game FullScreen OpenGL\",
\"type\": \"${DEBUGGER_TYPE}\",
\"request\": \"launch\",
\"args\": [\"-f\",\"-r\",\"OpenGL\",\"-s\",\"scenes/main.txt\"],
\"stopAtEntry\": false,
\"cwd\": \"${CMAKE_SOURCE_DIR}\",
\"environment\": [
{
\"name\":\"PATH\",
\"value\":\"${DEBUG_PATH}\"
}
],
\"externalConsole\": ${USE_EXTERNAL_CONSOLE},
\"program\": \"${CMAKE_BINARY_DIR}/bin/game${CMAKE_EXECUTABLE_SUFFIX}\"${DEBUGGER_CONFIG}
},
{
\"name\": \"Game Window Vulkan\",
\"type\": \"${DEBUGGER_TYPE}\",
\"request\": \"launch\",
\"args\": [\"-r\",\"Vulkan\",\"-s\",\"scenes/main.txt\"],
\"stopAtEntry\": false,
\"cwd\": \"${CMAKE_SOURCE_DIR}\",
\"environment\": [
{
\"name\":\"PATH\",
\"value\":\"${DEBUG_PATH}\"
}
],
\"externalConsole\": ${USE_EXTERNAL_CONSOLE},
\"program\": \"${CMAKE_BINARY_DIR}/bin/game${CMAKE_EXECUTABLE_SUFFIX}\"${DEBUGGER_CONFIG}
},
{
\"name\": \"Game FullScreen Vulkan\",
\"type\": \"${DEBUGGER_TYPE}\",
\"request\": \"launch\",
\"args\": [\"-f\",\"-r\",\"Vulkan\",\"-s\",\"scenes/main.txt\"],
\"stopAtEntry\": false,
\"cwd\": \"${CMAKE_SOURCE_DIR}\",
\"environment\": [
{
\"name\":\"PATH\",
\"value\":\"${DEBUG_PATH}\"
}
],
\"externalConsole\": ${USE_EXTERNAL_CONSOLE},
\"program\": \"${CMAKE_BINARY_DIR}/bin/game${CMAKE_EXECUTABLE_SUFFIX}\"${DEBUGGER_CONFIG}
},")
endif()
if(GTest_FOUND)
string(APPEND LAUNCH_CONFIGS "
{
\"name\": \"Unit Tests\",
\"type\": \"${DEBUGGER_TYPE}\",
\"request\": \"launch\",
\"args\": [],
\"stopAtEntry\": false,
\"cwd\": \"${CMAKE_SOURCE_DIR}\",
\"environment\": [
{
\"name\":\"PATH\",
\"value\":\"${DEBUG_PATH}\"
}
],
\"externalConsole\": ${USE_EXTERNAL_CONSOLE},
\"program\": \"${CMAKE_BINARY_DIR}/bin/unit-tests${CMAKE_EXECUTABLE_SUFFIX}\"${DEBUGGER_CONFIG}
},")
endif()
string(APPEND LAUNCH_CONFIGS "
{
\"name\": \"Aeon Tool Convert\",
\"type\": \"${DEBUGGER_TYPE}\",
\"request\": \"launch\",
\"args\": [
\"convert\",\"-i\",\"game/meshes/cube.txt\",\"-o\",\"game/meshes/cube.msh\"
],
\"stopAtEntry\": false,
\"cwd\": \"${CMAKE_SOURCE_DIR}\",
\"environment\": [
{
\"name\":\"PATH\",
\"value\":\"${DEBUG_PATH}\"
}
],
\"externalConsole\": ${USE_EXTERNAL_CONSOLE},
\"program\": \"${CMAKE_BINARY_DIR}/bin/aeontool${CMAKE_EXECUTABLE_SUFFIX}\"${DEBUGGER_CONFIG}
},
{
\"name\": \"Aeon Tool Base64 Decode\",
\"type\": \"${DEBUGGER_TYPE}\",
\"request\": \"launch\",
\"args\": [
\"base64\",\"decode\",\"-i\",\"game/aerin/textures/Aerin_Body_Diffuse.png.base64\",\"-o\",\"game/aerin/textures/Aerin_Body_Diffuse_TEST.png\"
],
\"stopAtEntry\": false,
\"cwd\": \"${CMAKE_SOURCE_DIR}\",
\"environment\": [
{
\"name\":\"PATH\",
\"value\":\"${DEBUG_PATH}\"
}
],
\"externalConsole\": ${USE_EXTERNAL_CONSOLE},
\"program\": \"${CMAKE_BINARY_DIR}/bin/aeontool${CMAKE_EXECUTABLE_SUFFIX}\"${DEBUGGER_CONFIG}
},
{
\"name\": \"Aeon Tool Base64 Encode\",
\"type\": \"${DEBUGGER_TYPE}\",
\"request\": \"launch\",
\"args\": [
\"base64\",\"encode\",\"-i\",\"assets/sponza/sponza.blend\",\"-o\",\"assets/sponza/sponza.blend.base64\"
],
\"stopAtEntry\": false,
\"cwd\": \"${CMAKE_SOURCE_DIR}\",
\"environment\": [
{
\"name\":\"PATH\",
\"value\":\"${DEBUG_PATH}\"
}
],
\"externalConsole\": ${USE_EXTERNAL_CONSOLE},
\"program\": \"${CMAKE_BINARY_DIR}/bin/aeontool${CMAKE_EXECUTABLE_SUFFIX}\"${DEBUGGER_CONFIG}
}")
configure_file("${CMAKE_SOURCE_DIR}/cmake/tasks.json.in"
"${CMAKE_SOURCE_DIR}/.vscode/tasks.json")
configure_file("${CMAKE_SOURCE_DIR}/cmake/settings.json.in"
"${CMAKE_SOURCE_DIR}/.vscode/settings.json")
configure_file("${CMAKE_SOURCE_DIR}/cmake/launch.json.in"
"${CMAKE_SOURCE_DIR}/.vscode/launch.json" @ONLY)
configure_file("${CMAKE_SOURCE_DIR}/cmake/c_cpp_properties.json.in"
"${CMAKE_SOURCE_DIR}/.vscode/c_cpp_properties.json" @ONLY)
endif()
set(COVER_BACKGROUND "${CMAKE_BINARY_DIR}/wallpaper.png"
CACHE FILEPATH "Background for the create-cover target")
set(COVER_POINTSIZE "250"
CACHE STRING "Font pointsize for the create-cover target")
add_custom_target(create-cover
COMMAND "${ImageMagick_convert_EXECUTABLE}" -size 1920x1080
xc:none -background transparent -font Ego.ttf -gravity
center -pointsize ${COVER_POINTSIZE} -fill none
-stroke SteelBlue4 -strokewidth 10 -draw \"text 0,0
\'`date \+\"%B %d %Y\"`\'\" -blur 0x10 -pointsize
${COVER_POINTSIZE} -fill white -stroke none
-strokewidth 0 -draw \"text 0,0 \'`date \+\"%B %d
%Y\"`\'\" PNG32:overlay.png
COMMAND "${ImageMagick_convert_EXECUTABLE}"
"${COVER_BACKGROUND}" -draw
'image over 0,0 1920,1080 overlay.png' cover.png
DEPENDS "${COVER_BACKGROUND}"
COMMENT "Creating Cover")
get_property(PLUGIN_LIST GLOBAL PROPERTY PLUGINS)
foreach(PLUGIN ${PLUGIN_LIST})
string(APPEND PLUGINS "Plugin: \"${PLUGIN}\"\n")
endforeach()
string(REGEX REPLACE "\n$" "" PLUGINS "${PLUGINS}")
configure_file("${CMAKE_SOURCE_DIR}/cmake/config.in" "${CMAKE_SOURCE_DIR}/game/config" @ONLY)
configure_file("${CMAKE_SOURCE_DIR}/cmake/renderdoc.cap.in" "${CMAKE_BINARY_DIR}/worldeditor.cap" @ONLY)