Skip to content

Commit

Permalink
[build] ensure compatibility with yaml-cpp < 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller committed Jul 29, 2024
1 parent 0b60453 commit 4c8d172
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
11 changes: 3 additions & 8 deletions app/meas_cutter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion ecal/tests/cpp/config_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions thirdparty/yaml-cpp/compatibility-yaml-cpp.cmake
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 4c8d172

Please sign in to comment.