Skip to content

Commit 414ea74

Browse files
committed
Refactor CMake setup to include CTest after project() call
- Moved CTest inclusion to cpp_library_setup() to ensure it is called after project() declaration. - Updated comments to clarify the order of operations for dependency tracking and testing support. - This change aligns with best practices for CMake project configuration.
1 parent 4cc037d commit 414ea74

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

cpp-library.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ function(cpp_library_enable_dependency_tracking)
3434
message(STATUS "cpp-library: Dependency tracking will be enabled during project() call")
3535
endfunction()
3636

37-
# Include CTest for testing support
38-
include(CTest)
39-
4037
# Include all the component modules
38+
# Note: CTest is NOT included here because it requires project() to be called first.
39+
# It will be included in cpp_library_setup() which is called after project().
4140
include("${CPP_LIBRARY_ROOT}/cmake/cpp-library-setup.cmake")
4241
include("${CPP_LIBRARY_ROOT}/cmake/cpp-library-testing.cmake")
4342
include("${CPP_LIBRARY_ROOT}/cmake/cpp-library-docs.cmake")
@@ -166,6 +165,9 @@ function(cpp_library_setup)
166165
endif()
167166
set(ARG_NAME "${PROJECT_NAME}")
168167

168+
# Include CTest for testing support (must be after project())
169+
include(CTest)
170+
169171
# Calculate clean name (without namespace prefix) for target alias
170172
# If PROJECT_NAME starts with NAMESPACE-, strip it; otherwise use PROJECT_NAME as-is
171173
string(REGEX REPLACE "^${ARG_NAMESPACE}-" "" CLEAN_NAME "${ARG_NAME}")

0 commit comments

Comments
 (0)