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 --- cmake/DemoOptions.cmake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cmake/DemoOptions.cmake (limited to 'cmake/DemoOptions.cmake') diff --git a/cmake/DemoOptions.cmake b/cmake/DemoOptions.cmake new file mode 100644 index 0000000..9215119 --- /dev/null +++ b/cmake/DemoOptions.cmake @@ -0,0 +1,19 @@ +# Build Option Declarations +# All build configuration options for demo64k + +# Size optimization flags +option(DEMO_SIZE_OPT "Enable size optimization flags" OFF) +option(DEMO_STRIP_ALL "Strip all unnecessary code for final build" OFF) +option(DEMO_FINAL_STRIP "Strip ALL error checking for final-final build" OFF) +option(DEMO_STRIP_EXTERNAL_LIBS "Stub external libs for size measurement (binary won't run)" OFF) + +# Feature toggles +option(DEMO_BUILD_TESTS "Build tests" OFF) +option(DEMO_BUILD_TOOLS "Build tools" OFF) +option(DEMO_ENABLE_COVERAGE "Enable code coverage generation (macOS only)" OFF) +option(DEMO_ENABLE_DEBUG_LOGS "Enable all debug logging (for pre-commit checks)" OFF) +option(DEMO_HEADLESS "Build headless mode (functional stubs for testing)" OFF) +option(DEMO_ALL_OPTIONS "Activate all options at once" OFF) + +# Workspace selection +set(DEMO_WORKSPACE "main" CACHE STRING "Active workspace (main, test, etc.)") -- cgit v1.2.3