Skip to content

[#674-4/5] Decompose 996-line CMakeLists.txt into cmake/ modules #678

Description

@kcenon

What

Decompose the (post sub-issues #1-#3) root CMakeLists.txt into per-concern modules under cmake/, leaving the top-level file as a thin orchestrator (~50-80 lines: cmake_minimum_required, project(...), policy settings, then include(cmake/...) calls in dependency order). Match the canonical layout used by sibling repos in the broader EPIC.

Why

After the legacy fallback removal and source-list cleanup, the remaining content of CMakeLists.txt is still monolithic. Sibling repos in the ecosystem (e.g. container_system after PR #540) already use a per-concern cmake-module layout. Aligning monitoring_system removes a recurring friction point: every time someone touches options/dependencies/install rules they no longer have to scroll through ~600+ lines to find the right block.

The container_system precedent (kcenon/container_system PR #540) reduced its top-level from 743 → 49 lines and produced 11 modules. monitoring_system should land in a similar range after sub-issues #1-#3 trim the file first.

Where

  • Top-level CMakeLists.txt
  • Existing cmake/ directory (verify what's already modular before creating duplicates)

How

Suggested Decomposition

Adapt to reality after inspecting existing cmake/:

Module Responsibility
cmake/options.cmake option(...) declarations, feature toggles
cmake/dependencies.cmake find_package, vcpkg, third-party resolution
cmake/compile_options.cmake warning flags, sanitizers, std settings, IPO/LTO
cmake/sources.cmake source-list file(GLOB_RECURSE ...) calls (post sub-issue #3)
cmake/targets.cmake add_library(...) and target_* calls
cmake/install.cmake install() rules, export sets, package config
cmake/test.cmake enable_testing(), ctest registration
cmake/documentation.cmake Doxygen target wiring (if present)
cmake/summary.cmake end-of-configure summary block (if present)

If cmake/ already contains some of these, extend them rather than overwriting.

Important: behaviour parity

This is a refactor, not a redesign. Expected outputs:

  • Build artefacts identical to pre-PR develop
  • cmake --install produces the same export layout
  • ctest results match

If local toolchain available: diff cmake --install build/ --prefix /tmp/before vs /tmp/after. Otherwise rely on CI delta.

Dependencies

  • Blocked by: legacy fallback removal sub-issue (no point decomposing two paths)
  • Blocked by: hardcoded paths cleanup sub-issue (so the source-list module is meaningful)

Risk Profile

Higher than sub-issues #1-#3. CMake decomposition rearranges variable scope, evaluation order of find_package vs option, and target-property propagation. Expect at least one CI ordering issue to surface — honour the 3-fail rule strictly.

Acceptance Criteria

  • Top-level CMakeLists.txt ≤ ~80 lines (orchestrator only)
  • Every concern lives in its own cmake/<area>.cmake
  • Build green, ctest passes
  • Install layout unchanged compared to pre-PR develop (verified by diff if possible, otherwise by reasoning)
  • PR merged with every CI check pass/neutral

Estimated Size

L. Mechanical relocation is medium effort; verifying parity is fiddly.

Part of #674

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/highHigh priority - Critical for productionsize/LLarge - 3-5 days of worktype/buildBuild system and dependenciestype/refactorCode refactoring without functional changes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions