From e086334a0850a77a29909d5f3f21fdd941c53caf Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Wed, 23 Oct 2024 12:31:09 +0200 Subject: [PATCH] Update yaml-cpp dependency handling - Added CPM fallback in case package is not found automatically. - Using yaml-cpp::yaml-cpp target instead of yaml-cpp to silence deprecation warnings on newer cmake versions. --- common/config/yaml/CMakeLists.txt | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/common/config/yaml/CMakeLists.txt b/common/config/yaml/CMakeLists.txt index 5ff8c23eb1..635887e37e 100644 --- a/common/config/yaml/CMakeLists.txt +++ b/common/config/yaml/CMakeLists.txt @@ -1,25 +1,18 @@ -find_package(yaml-cpp REQUIRED PATHS /usr/lib/aarch64-linux-gnu/pkgconfig/) -# include(FetchContent) - -# FetchContent_Declare( -# yaml-cpp -# GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git -# GIT_TAG 0.8.0 -# ) -# FetchContent_GetProperties(yaml-cpp) - -# if(NOT yaml-cpp_POPULATED) -# message(STATUS "Fetching yaml-cpp...") -# FetchContent_Populate(yaml-cpp) -# add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR}) -# endif() +find_package(yaml-cpp) +if (NOT yaml-cpp_FOUND) + CPMAddPackage("gh:jbeder/yaml-cpp#yaml-cpp-0.7.0@0.7.0") +else() + if (NOT TARGET yaml-cpp::yaml-cpp) + add_library(yaml-cpp::yaml-cpp ALIAS yaml-cpp) + endif() +endif() add_library(params_yaml_static config_yaml.cpp) -target_link_libraries(params_yaml_static PUBLIC UTIL yaml-cpp) +target_link_libraries(params_yaml_static PUBLIC UTIL yaml-cpp::yaml-cpp) if (ENABLE_TESTS) add_subdirectory(tests) endif() add_library(params_yaml MODULE config_yaml.cpp) -target_link_libraries(params_yaml PUBLIC UTIL yaml-cpp) +target_link_libraries(params_yaml PUBLIC UTIL yaml-cpp::yaml-cpp) set_target_properties(params_yaml PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})