Skip to content

Commit 4cc037d

Browse files
committed
Update CMake setup for cpp-library and enhance property handling
- Updated minimum required CMake version from 3.20 to 3.24. - Changed cpp-library version from 4.0.3 to 5.0.0 for improved features. - Adjusted the order of commands to ensure proper setup of cpp-library and enable dependency tracking before project declaration. - Modified property handling in tests to return "NOTFOUND" for unsupported properties, ensuring clarity in mock implementations.
1 parent 25cf15c commit 4cc037d

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

setup.cmake

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,22 +309,25 @@ endif()
309309

310310
# Generate CMakeLists.txt
311311
file(WRITE "${PROJECT_DIR}/CMakeLists.txt"
312-
"cmake_minimum_required(VERSION 3.20)
312+
"cmake_minimum_required(VERSION 3.24)
313313
314-
# Project declaration - cpp_library_setup will use this name and detect version from git tags
315-
project(${ARG_NAME})
316-
317-
# Setup CPM
318-
if(PROJECT_IS_TOP_LEVEL AND NOT CPM_SOURCE_CACHE AND NOT DEFINED ENV{CPM_SOURCE_CACHE})
314+
# Setup CPM cache before project()
315+
if(NOT CPM_SOURCE_CACHE AND NOT DEFINED ENV{CPM_SOURCE_CACHE})
319316
set(CPM_SOURCE_CACHE \"\${CMAKE_SOURCE_DIR}/.cache/cpm\" CACHE PATH \"CPM source cache\")
320-
message(STATUS \"Setting cpm cache dir to: \${CPM_SOURCE_CACHE}\")
321317
endif()
322318
include(cmake/CPM.cmake)
323319
324-
# Fetch cpp-library via CPM
325-
CPMAddPackage(\"gh:stlab/cpp-library@4.0.3\")
320+
# Fetch cpp-library before project()
321+
CPMAddPackage(\"gh:stlab/cpp-library@5.0.0\")
326322
include(\${cpp-library_SOURCE_DIR}/cpp-library.cmake)
327323
324+
# Enable dependency tracking before project()
325+
cpp_library_enable_dependency_tracking()
326+
327+
# Now declare project
328+
project(${ARG_NAME})
329+
330+
# Setup library
328331
cpp_library_setup(
329332
DESCRIPTION \"${ARG_DESCRIPTION}\"
330333
NAMESPACE ${ARG_NAMESPACE}

tests/install/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ function(get_target_property OUTPUT_VAR TARGET PROPERTY)
2424
set(${OUTPUT_VAR} "NOTFOUND" PARENT_SCOPE)
2525
endif()
2626
else()
27-
_get_target_property(${OUTPUT_VAR} ${TARGET} ${PROPERTY})
27+
# For other properties, return NOTFOUND since we're only mocking INTERFACE_LINK_LIBRARIES
28+
set(${OUTPUT_VAR} "NOTFOUND" PARENT_SCOPE)
2829
endif()
2930
endfunction()
3031

0 commit comments

Comments
 (0)