-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
70 lines (58 loc) · 2.46 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
cmake_minimum_required(VERSION 3.10)
project(libyaml_vendor)
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_vendor_package REQUIRED)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
find_package(yaml 0.2.5 EXACT QUIET)
ament_vendor(libyaml_vendor
SATISFIED ${yaml_FOUND}
VCS_URL https://github.com/yaml/libyaml.git
VCS_VERSION 0.2.5
CMAKE_ARGS
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}$<$<BOOL:${MSVC}>: /wd4244 /wd4267 /wd4996>"
)
ament_export_dependencies(yaml)
if(BUILD_TESTING)
if(TARGET libyaml_vendor)
add_library(yaml_library INTERFACE)
externalproject_get_property(libyaml_vendor INSTALL_DIR)
target_include_directories(yaml_library INTERFACE "${INSTALL_DIR}/include")
target_link_directories(yaml_library INTERFACE "${INSTALL_DIR}/lib")
target_link_libraries(yaml_library INTERFACE ${CMAKE_LINK_LIBRARY_FLAG}yaml)
add_dependencies(yaml_library libyaml_vendor)
else()
add_library(yaml_library ALIAS yaml)
endif()
# We need to install a Findyaml.cmake file that does not respect
# ament_cmake_lint_cmake's convention/filename and package/stdargs rules
# See https://github.com/ros2/libyaml_vendor/pull/45#issuecomment-1087559657
list(APPEND AMENT_LINT_AUTO_EXCLUDE
ament_cmake_lint_cmake
)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
find_package(ament_cmake_lint_cmake REQUIRED)
ament_lint_cmake("--filter=-convention/filename,-package/stdargs")
find_package(ament_cmake_gtest REQUIRED)
find_package(performance_test_fixture REQUIRED)
# Give cppcheck hints about macro definitions coming from outside this package
get_target_property(ament_cmake_cppcheck_ADDITIONAL_INCLUDE_DIRS
performance_test_fixture::performance_test_fixture INTERFACE_INCLUDE_DIRECTORIES)
ament_add_gtest(test_yaml_reader test/test_reader.cpp
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
if(TARGET test_yaml_reader)
target_link_libraries(test_yaml_reader yaml_library)
endif()
add_performance_test(benchmark_reader test/benchmark/benchmark_reader.cpp
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
if(TARGET benchmark_reader)
target_link_libraries(benchmark_reader yaml_library)
endif()
endif()
install(DIRECTORY cmake DESTINATION share/${PROJECT_NAME})
ament_package(CONFIG_EXTRAS libyaml_vendor-extras.cmake)