diff --git a/app/meas_cutter/CMakeLists.txt b/app/meas_cutter/CMakeLists.txt index 4209e6c380..637b0783c8 100644 --- a/app/meas_cutter/CMakeLists.txt +++ b/app/meas_cutter/CMakeLists.txt @@ -1,6 +1,6 @@ # ========================= eCAL LICENSE ================================= # -# Copyright (C) 2016 - 2019 Continental Corporation +# Copyright (C) 2016 - 2024 Continental Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,13 +22,8 @@ find_package(Threads REQUIRED) find_package(tclap REQUIRED) find_package(yaml-cpp REQUIRED) -#compatibility with yaml-cpp < 0.8.0 -if (NOT TARGET yaml-cpp::yaml-cpp AND TARGET yaml-cpp) - # ALIASing a imported non-global library requires CMake 3.18 so we do this - add_library(yaml-cpp::yaml-cpp INTERFACE IMPORTED) - target_link_libraries(yaml-cpp::yaml-cpp INTERFACE yaml-cpp) -endif() - +include(${ECAL_PROJECT_ROOT}/thirdparty/yaml-cpp/compatibility-yaml-cpp.cmake) +yaml_cpp_create_compatibility_targets() set(meas_cutter_src src/main.cpp diff --git a/ecal/core/CMakeLists.txt b/ecal/core/CMakeLists.txt index 893b5ed150..1cd2628884 100644 --- a/ecal/core/CMakeLists.txt +++ b/ecal/core/CMakeLists.txt @@ -24,6 +24,8 @@ find_package(ecaludp REQUIRED) if (ECAL_CORE_CONFIGURATION) find_package(yaml-cpp REQUIRED) + include(${ECAL_PROJECT_ROOT}/thirdparty/yaml-cpp/compatibility-yaml-cpp.cmake) + yaml_cpp_create_compatibility_targets() endif() if (ECAL_CORE_COMMAND_LINE) diff --git a/ecal/tests/cpp/config_test/CMakeLists.txt b/ecal/tests/cpp/config_test/CMakeLists.txt index f2b7ae7363..acb2f81501 100644 --- a/ecal/tests/cpp/config_test/CMakeLists.txt +++ b/ecal/tests/cpp/config_test/CMakeLists.txt @@ -23,6 +23,9 @@ find_package(GTest REQUIRED) find_package(tclap REQUIRED) find_package(yaml-cpp REQUIRED) +include(${ECAL_PROJECT_ROOT}/thirdparty/yaml-cpp/compatibility-yaml-cpp.cmake) +yaml_cpp_create_compatibility_targets() + set(cmd_parser_src ${ECAL_CORE_PROJECT_ROOT}/core/src/config/ecal_cmd_parser.cpp ${ECAL_CORE_PROJECT_ROOT}/core/src/util/advanced_tclap_output.cpp @@ -33,7 +36,7 @@ set(cmd_parser_src ) set(config_reader_src - ${CMAKE_SOURCE_DIR}/ecal/core/src/config/configuration_reader.h + ${ECAL_CORE_PROJECT_ROOT}/core/src/config/configuration_reader.h ) set(config_test_src diff --git a/thirdparty/yaml-cpp/compatibility-yaml-cpp.cmake b/thirdparty/yaml-cpp/compatibility-yaml-cpp.cmake new file mode 100644 index 0000000000..4716ad5226 --- /dev/null +++ b/thirdparty/yaml-cpp/compatibility-yaml-cpp.cmake @@ -0,0 +1,8 @@ +# Create targets to be compatible with yaml-cpp < 0.8.0 +macro(yaml_cpp_create_compatibility_targets) + if (NOT TARGET yaml-cpp::yaml-cpp AND TARGET yaml-cpp) + # ALIASing a imported non-global library requires CMake 3.18 so we do this + add_library(yaml-cpp::yaml-cpp INTERFACE IMPORTED) + target_link_libraries(yaml-cpp::yaml-cpp INTERFACE yaml-cpp) + endif() +endmacro() \ No newline at end of file