Skip to content

Commit 94d1f17

Browse files
authored
refactor(cmake): remove legacy directory fallback from monitoring_system library (#681)
The library definition at the root carried two parallel branches: 1. Outer if(EXISTS .../kcenon/monitoring AND EXISTS .../src) gating a 'new directory structure' build path. 2. Inner if(SOURCE_COUNT GREATER 0) gating the GLOB result, with an else() that hardcoded 11 cpp files (Fall back to legacy structure). 3. Outer else() that hardcoded the same 11 cpp files (Use legacy directory structure). After PR #680 consolidated src/impl into the canonical feature directories, the legacy branches can never trigger: - include/kcenon/monitoring and src/ both always exist. - The GLOB always finds sources (33 files at the time of writing). - The hardcoded fallback list is a stale subset of the real source set; activating it would silently miss most of the library. Replace the dual-structure scaffolding with a single GLOB-based add_library() call. CMakeLists.txt drops 57 lines (996 -> 939) and the build now has exactly one path, mirroring the EPIC #674 goal of collapsing the legacy fallback before further CMake decomposition. No behavioural change for current builds (the GLOB path was already the live one). The hardcoded source lists in the deleted fallback branches no longer reflect the actual src/ layout, so removing them also eliminates a drift hazard.
1 parent f68fbfb commit 94d1f17

1 file changed

Lines changed: 19 additions & 76 deletions

File tree

CMakeLists.txt

Lines changed: 19 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -514,88 +514,31 @@ if(MONITORING_ENABLE_UBSAN)
514514
target_link_options(monitoring_system_interface INTERFACE -fsanitize=undefined)
515515
endif()
516516

517-
# Check for new structure
517+
# Source layout (canonical, post src/impl consolidation)
518518
set(MONITORING_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
519519
set(MONITORING_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
520520

521-
if(EXISTS ${MONITORING_INCLUDE_DIR}/kcenon/monitoring AND EXISTS ${MONITORING_SOURCE_DIR})
522-
message(STATUS "Monitoring System: Using new directory structure")
523-
524-
# Collect source files from new structure
525-
file(GLOB_RECURSE MONITORING_HEADERS
526-
${MONITORING_INCLUDE_DIR}/kcenon/monitoring/*.h
527-
)
528-
529-
file(GLOB_RECURSE MONITORING_SOURCES
530-
${MONITORING_SOURCE_DIR}/*.cpp
531-
)
532-
533-
# Check if new structure has sources
534-
list(LENGTH MONITORING_SOURCES SOURCE_COUNT)
535-
if(SOURCE_COUNT GREATER 0)
536-
# Create library with new structure
537-
add_library(monitoring_system STATIC
538-
${MONITORING_SOURCES}
539-
${MONITORING_HEADERS}
540-
)
521+
# Collect source files
522+
file(GLOB_RECURSE MONITORING_HEADERS
523+
${MONITORING_INCLUDE_DIR}/kcenon/monitoring/*.h
524+
)
541525

542-
target_include_directories(monitoring_system
543-
PUBLIC
544-
$<BUILD_INTERFACE:${MONITORING_INCLUDE_DIR}>
545-
$<INSTALL_INTERFACE:include>
546-
PRIVATE
547-
$<BUILD_INTERFACE:${MONITORING_SOURCE_DIR}>
548-
)
549-
else()
550-
# Fall back to legacy structure
551-
message(STATUS "Monitoring System: New structure incomplete, using src sources")
552-
add_library(monitoring_system STATIC
553-
src/context/thread_context.cpp
554-
src/core/distributed_tracer.cpp
555-
src/core/performance_monitor.cpp
556-
src/core/thread_local_buffer.cpp
557-
src/core/central_collector.cpp
558-
src/core/adaptive_monitor.cpp
559-
src/collectors/container_collector.cpp
560-
src/platform/linux_metrics.cpp
561-
src/platform/windows_metrics.cpp
562-
src/platform/cgroup_metrics.cpp
563-
src/platform/docker_metrics.cpp
564-
)
526+
file(GLOB_RECURSE MONITORING_SOURCES
527+
${MONITORING_SOURCE_DIR}/*.cpp
528+
)
565529

566-
target_include_directories(monitoring_system
567-
PUBLIC
568-
$<BUILD_INTERFACE:${MONITORING_INCLUDE_DIR}>
569-
$<INSTALL_INTERFACE:include>
570-
PRIVATE
571-
$<BUILD_INTERFACE:${MONITORING_SOURCE_DIR}>
572-
)
573-
endif()
574-
else()
575-
# Use legacy structure
576-
message(STATUS "Monitoring System: Using legacy directory structure")
577-
add_library(monitoring_system STATIC
578-
src/context/thread_context.cpp
579-
src/core/distributed_tracer.cpp
580-
src/core/performance_monitor.cpp
581-
src/core/thread_local_buffer.cpp
582-
src/core/central_collector.cpp
583-
src/core/adaptive_monitor.cpp
584-
src/collectors/container_collector.cpp
585-
src/platform/linux_metrics.cpp
586-
src/platform/windows_metrics.cpp
587-
src/platform/cgroup_metrics.cpp
588-
src/platform/docker_metrics.cpp
589-
)
530+
add_library(monitoring_system STATIC
531+
${MONITORING_SOURCES}
532+
${MONITORING_HEADERS}
533+
)
590534

591-
target_include_directories(monitoring_system
592-
PUBLIC
593-
$<BUILD_INTERFACE:${MONITORING_INCLUDE_DIR}>
594-
$<INSTALL_INTERFACE:include>
595-
PRIVATE
596-
$<BUILD_INTERFACE:${MONITORING_SOURCE_DIR}>
597-
)
598-
endif()
535+
target_include_directories(monitoring_system
536+
PUBLIC
537+
$<BUILD_INTERFACE:${MONITORING_INCLUDE_DIR}>
538+
$<INSTALL_INTERFACE:include>
539+
PRIVATE
540+
$<BUILD_INTERFACE:${MONITORING_SOURCE_DIR}>
541+
)
599542

600543
target_link_libraries(monitoring_system PUBLIC
601544
monitoring_system_interface

0 commit comments

Comments
 (0)