diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-11 08:19:05 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-11 08:19:05 +0100 |
| commit | fdf9345d5de1c951603e5da3ee8454e9efe2dc28 (patch) | |
| tree | ee0dcf35de7d2800b20faf861cd70cb168d773f8 /cmake/DemoTools.cmake | |
| parent | 6d64674f7e3d00a9d18ec61eaf968ed37c8e849b (diff) | |
refactor: Modularize CMake build system into 10 specialized modules
Refactor monolithic 866-line CMakeLists.txt into 54-line orchestrator + 10 modules:
- DemoOptions.cmake - Build option declarations
- DemoConfig.cmake - Option implications and platform detection
- DemoCommon.cmake - Shared macros (conditional sources, size opts, linking)
- DemoDependencies.cmake - External library discovery (WGPU, GLFW)
- DemoSourceLists.cmake - Conditional source file lists
- DemoLibraries.cmake - Subsystem library targets
- DemoTools.cmake - Build tools (asset_packer, compilers)
- DemoCodegen.cmake - Code generation (assets, timeline, music)
- DemoExecutables.cmake - Main binaries (demo64k, test_demo)
- DemoTests.cmake - Test infrastructure (36 tests)
- Validation.cmake - Uniform buffer validation
Benefits:
- 94% reduction in main file size (866 → 54 lines)
- Conditional module inclusion (tests only parsed if DEMO_BUILD_TESTS=ON)
- Shared macros eliminate 200+ lines of repetition
- Clear separation of concerns
All 36 tests passing. All build modes verified.
Documentation: Created doc/CMAKE_MODULES.md with module architecture.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'cmake/DemoTools.cmake')
| -rw-r--r-- | cmake/DemoTools.cmake | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/cmake/DemoTools.cmake b/cmake/DemoTools.cmake new file mode 100644 index 0000000..8c589f1 --- /dev/null +++ b/cmake/DemoTools.cmake @@ -0,0 +1,48 @@ +# Build Tools Setup +# Configures asset_packer, seq_compiler, and tracker_compiler + +# Asset packer tool +if(DEFINED ASSET_PACKER_PATH) + set(ASSET_PACKER_CMD ${ASSET_PACKER_PATH}) + set(ASSET_PACKER_DEPENDS ${ASSET_PACKER_PATH}) +else() + add_executable(asset_packer tools/asset_packer.cc) + target_link_libraries(asset_packer PRIVATE procedural) + target_include_directories(asset_packer PRIVATE third_party) + set(ASSET_PACKER_CMD $<TARGET_FILE:asset_packer>) + set(ASSET_PACKER_DEPENDS asset_packer) +endif() + +# Sequence compiler tool +if(DEFINED SEQ_COMPILER_PATH) + set(SEQ_COMPILER_CMD ${SEQ_COMPILER_PATH}) + set(SEQ_COMPILER_DEPENDS ${SEQ_COMPILER_PATH}) +else() + add_executable(seq_compiler tools/seq_compiler.cc) + set(SEQ_COMPILER_CMD $<TARGET_FILE:seq_compiler>) + set(SEQ_COMPILER_DEPENDS seq_compiler) +endif() + +# Tracker compiler tool +if(DEFINED TRACKER_COMPILER_PATH) + set(TRACKER_COMPILER_CMD ${TRACKER_COMPILER_PATH}) + set(TRACKER_COMPILER_DEPENDS ${TRACKER_COMPILER_PATH}) +else() + add_executable(tracker_compiler tools/tracker_compiler.cc) + set(TRACKER_COMPILER_CMD $<TARGET_FILE:tracker_compiler>) + set(TRACKER_COMPILER_DEPENDS tracker_compiler) +endif() + +# Always build a host-native tracker_compiler for code generation purposes +add_executable(tracker_compiler_host tools/tracker_compiler.cc) +set_target_properties(tracker_compiler_host PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tools_host") + +# Determine which tracker compiler to use for code generation +if(DEMO_CROSS_COMPILE_WIN32) + set(TRACKER_COMPILER_FINAL_CMD "${CMAKE_SOURCE_DIR}/build_native/tools_host/tracker_compiler_host") + set(TRACKER_COMPILER_FINAL_DEPENDS tracker_compiler_host) +else() + set(TRACKER_COMPILER_FINAL_CMD ${TRACKER_COMPILER_CMD}) + set(TRACKER_COMPILER_FINAL_DEPENDS ${TRACKER_COMPILER_DEPENDS}) +endif() |
