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/DemoDependencies.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/DemoDependencies.cmake')
| -rw-r--r-- | cmake/DemoDependencies.cmake | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/cmake/DemoDependencies.cmake b/cmake/DemoDependencies.cmake new file mode 100644 index 0000000..daac571 --- /dev/null +++ b/cmake/DemoDependencies.cmake @@ -0,0 +1,33 @@ +# External Dependencies and Includes +# Finds and configures external libraries (WGPU, GLFW, platform libs) + +set(CORE_INCLUDES src third_party) + +if(DEMO_CROSS_COMPILE_WIN32) + add_definitions(-DDEMO_CROSS_COMPILE_WIN32) + set(WINDOWS_DEPS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/windows") + set(WGPU_INCLUDE_DIR "${WINDOWS_DEPS_DIR}/include") + set(WGPU_LIBRARY "${WINDOWS_DEPS_DIR}/lib/libwgpu_native.dll.a") + set(GLFW3_INCLUDE_DIR "${WINDOWS_DEPS_DIR}/include") + set(GLFW3_LIBRARY "${WINDOWS_DEPS_DIR}/lib/libglfw3.a") + + list(APPEND CORE_INCLUDES ${WGPU_INCLUDE_DIR} ${WGPU_INCLUDE_DIR}/webgpu ${GLFW3_INCLUDE_DIR}) + set(DEMO_LIBS ${GLFW3_LIBRARY} ${WGPU_LIBRARY} -lgdi32 -lws2_32 -luser32 -lkernel32 -lshell32 -ladvapi32 -ldwmapi) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") +else() + find_library(WGPU_LIBRARY NAMES wgpu_native libwgpu_native REQUIRED) + find_path(WGPU_ROOT_INCLUDE_DIR NAMES wgpu.h REQUIRED) + list(APPEND CORE_INCLUDES ${WGPU_ROOT_INCLUDE_DIR} ${WGPU_ROOT_INCLUDE_DIR}/webgpu-headers) + find_package(glfw3 REQUIRED) + set(DEMO_LIBS glfw ${WGPU_LIBRARY}) +endif() + +list(APPEND CORE_INCLUDES third_party/glfw3webgpu) +include_directories(${CORE_INCLUDES}) + +if(APPLE) + set_source_files_properties(src/platform/platform.cc third_party/glfw3webgpu/glfw3webgpu.c PROPERTIES COMPILE_FLAGS "-x objective-c++") + list(APPEND DEMO_LIBS "-framework Metal" "-framework Foundation" "-framework Cocoa" "-framework QuartzCore") +elseif(NOT DEMO_CROSS_COMPILE_WIN32) + list(APPEND DEMO_LIBS pthread m dl) +endif() |
