From 52a89713e6983cd96fa1ebfaec1c971026e83981 Mon Sep 17 00:00:00 2001 From: Florian Uhlig Date: Fri, 1 Sep 2023 16:35:17 +0200 Subject: [PATCH] build: Support yaml-cpp 0.8+ Beginning from version 0.8.0 the exported target has been renamed to `yaml-cpp::yaml-cpp`. To support also older versions choose the correct target name stored in a CMake variable. (cherry-picked from commit 2af719f542ef170e7782257459df0db4d0217730) --- CMakeLists.txt | 11 +++++++++++ fairtools/MCConfigurator/CMakeLists.txt | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd4c81bd24..cec2bc9fa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,6 +260,17 @@ if( yaml-cpp_FOUND INTERFACE_INCLUDE_DIRECTORIES "${YAML_CPP_INCLUDE_DIR}" ) endif() +# Workaround to fix a problem with the imported target name +# The target name includes the namespace yaml-cpp begining +# from version 0.8.0. So the new exported target is now +# yaml-cpp::yaml-cpp. +if(yaml-cpp_FOUND) + if(TARGET yaml-cpp::yaml-cpp) + set(YAMLCPPLIB yaml-cpp::yaml-cpp) + else() + set(YAMLCPPLIB yaml-cpp) + endif() +endif() configure_file(${CMAKE_SOURCE_DIR}/cmake/private/FairRootConfigVersion.cmake.in "${CMAKE_BINARY_DIR}/FairRootConfigVersion.cmake" @ONLY) diff --git a/fairtools/MCConfigurator/CMakeLists.txt b/fairtools/MCConfigurator/CMakeLists.txt index 46d60475a1..508e4a7499 100644 --- a/fairtools/MCConfigurator/CMakeLists.txt +++ b/fairtools/MCConfigurator/CMakeLists.txt @@ -30,7 +30,7 @@ target_include_directories(${target} SYSTEM PUBLIC target_link_libraries(${target} PUBLIC FairRoot::Base # FairGenericVMCConfig - yaml-cpp + ${YAMLCPPLIB} PRIVATE FairRoot::Tools