summaryrefslogtreecommitdiff
path: root/cmake/DemoConfig.cmake
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-11 08:19:05 +0100
committerskal <pascal.massimino@gmail.com>2026-02-11 08:19:05 +0100
commitfdf9345d5de1c951603e5da3ee8454e9efe2dc28 (patch)
treeee0dcf35de7d2800b20faf861cd70cb168d773f8 /cmake/DemoConfig.cmake
parent6d64674f7e3d00a9d18ec61eaf968ed37c8e849b (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/DemoConfig.cmake')
-rw-r--r--cmake/DemoConfig.cmake77
1 files changed, 77 insertions, 0 deletions
diff --git a/cmake/DemoConfig.cmake b/cmake/DemoConfig.cmake
new file mode 100644
index 0000000..b3167c4
--- /dev/null
+++ b/cmake/DemoConfig.cmake
@@ -0,0 +1,77 @@
+# Configuration Implications and Platform Detection
+# Processes build options and sets up platform-specific definitions
+
+# Option hierarchy: ALL_OPTIONS → FINAL_STRIP → STRIP_ALL → SIZE_OPT
+if(DEMO_ALL_OPTIONS)
+ set(DEMO_SIZE_OPT ON)
+ set(DEMO_STRIP_ALL ON)
+ set(DEMO_BUILD_TESTS ON)
+ set(DEMO_BUILD_TOOLS ON)
+ # NOTE: DEMO_FINAL_STRIP is NOT included here (too dangerous for testing)
+endif()
+
+# FINAL_STRIP: Most aggressive stripping (removes ALL error checking)
+# Implies STRIP_ALL (stricter superset)
+if(DEMO_FINAL_STRIP)
+ add_definitions(-DFINAL_STRIP)
+ set(DEMO_STRIP_ALL ON)
+ message(STATUS "FINAL_STRIP enabled - all error checking will be removed")
+endif()
+
+if(DEMO_STRIP_ALL)
+ add_definitions(-DSTRIP_ALL)
+ set(DEMO_SIZE_OPT ON)
+endif()
+
+if(DEMO_STRIP_EXTERNAL_LIBS)
+ add_definitions(-DSTRIP_EXTERNAL_LIBS)
+ # Audio: Use miniaudio null backend
+ add_definitions(-DMA_ENABLE_ONLY_SPECIFIC_BACKENDS -DMA_ENABLE_NULL)
+ message(STATUS "STRIP_EXTERNAL_LIBS enabled - binary will compile but NOT run (size measurement only)")
+endif()
+
+if(DEMO_ENABLE_COVERAGE AND APPLE)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
+ # Coverage requires debug info
+ set(CMAKE_BUILD_TYPE Debug)
+endif()
+
+if(DEMO_ENABLE_DEBUG_LOGS)
+ add_definitions(-DDEBUG_LOG_ALL)
+endif()
+
+if(DEMO_HEADLESS)
+ add_definitions(-DDEMO_HEADLESS)
+ add_definitions(-DMA_ENABLE_ONLY_SPECIFIC_BACKENDS -DMA_ENABLE_NULL)
+ message(STATUS "DEMO_HEADLESS enabled - functional stubs (audio works, no GPU)")
+endif()
+
+# Platform-specific definitions
+if(APPLE)
+ add_definitions(-DGLFW_EXPOSE_NATIVE_COCOA)
+elseif(WIN32)
+ add_definitions(-DGLFW_EXPOSE_NATIVE_WIN32)
+elseif(UNIX)
+ if(DEFINED CMAKE_USE_WAYLAND)
+ add_definitions(-DGLFW_EXPOSE_NATIVE_WAYLAND)
+ else()
+ add_definitions(-DGLFW_EXPOSE_NATIVE_X11)
+ endif()
+endif()
+
+# Configuration summary
+message(STATUS "")
+message(STATUS "Build Configuration:")
+message(STATUS " DEMO_SIZE_OPT: ${DEMO_SIZE_OPT}")
+message(STATUS " DEMO_STRIP_ALL: ${DEMO_STRIP_ALL}")
+message(STATUS " DEMO_FINAL_STRIP: ${DEMO_FINAL_STRIP}")
+message(STATUS " DEMO_STRIP_EXTERNAL_LIBS: ${DEMO_STRIP_EXTERNAL_LIBS}")
+message(STATUS " DEMO_BUILD_TESTS: ${DEMO_BUILD_TESTS}")
+message(STATUS " DEMO_BUILD_TOOLS: ${DEMO_BUILD_TOOLS}")
+message(STATUS " DEMO_ENABLE_COVERAGE: ${DEMO_ENABLE_COVERAGE}")
+message(STATUS " DEMO_ENABLE_DEBUG_LOGS: ${DEMO_ENABLE_DEBUG_LOGS}")
+message(STATUS " DEMO_HEADLESS: ${DEMO_HEADLESS}")
+message(STATUS " DEMO_WORKSPACE: ${DEMO_WORKSPACE}")
+message(STATUS "")