From fdf9345d5de1c951603e5da3ee8454e9efe2dc28 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 11 Feb 2026 08:19:05 +0100 Subject: refactor: Modularize CMake build system into 10 specialized modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- doc/BUILD.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'doc/BUILD.md') diff --git a/doc/BUILD.md b/doc/BUILD.md index cd2b436..d3434f4 100644 --- a/doc/BUILD.md +++ b/doc/BUILD.md @@ -34,6 +34,20 @@ cmake --build build_final -j4 **Note:** `DEMO_ALL_OPTIONS=ON` enables tests, tools, AND `STRIP_ALL`. +## CMake Module Structure + +The build system uses a modular architecture with 10+ specialized modules. See `doc/CMAKE_MODULES.md` for: +- Module hierarchy and dependencies +- Shared macro documentation +- How to add new components + +Key modules: +- `cmake/DemoOptions.cmake` - Build options +- `cmake/DemoTests.cmake` - Test infrastructure +- `cmake/DemoCommon.cmake` - Shared macros + +The top-level `CMakeLists.txt` is now just 54 lines (94% reduction from 866 lines). + ## Dependencies Install via Homebrew (macOS): -- cgit v1.2.3