-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
124 lines (110 loc) · 3.66 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
cmake_minimum_required(VERSION 3.5)
project(rtt_ros2)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(ament_index_cpp REQUIRED)
find_package(Boost REQUIRED COMPONENTS filesystem system)
find_package(LibXml2 REQUIRED)
find_package(rclcpp REQUIRED)
find_package(OROCOS-RTT REQUIRED COMPONENTS rtt-marshalling rtt-scripting)
include(${OROCOS-RTT_USE_FILE_PATH}/UseOROCOS-RTT.cmake)
# generate detail headers
foreach(generated_header
include/orocos/${PROJECT_NAME}/detail/rclcpp_version.h
)
configure_file(
${generated_header}.in
${CMAKE_BINARY_DIR}/${generated_header}
@ONLY
)
endforeach()
# setup targets
include_directories(include/orocos)
orocos_library(rtt_ros2
src/rtt_ros2.cpp
EXPORT ${PROJECT_NAME}
INCLUDES DESTINATION include/orocos
)
# Note: Dependency ament_index_cpp is actually not PUBLIC, but
# ament_target_dependencies() does not support PRIVATE...
# (https://github.com/ament/ament_cmake/issues/158)
#ament_target_dependencies(rtt_ros2 PUBLIC ament_index_cpp)
ament_target_dependencies(rtt_ros2 ament_index_cpp)
target_link_libraries(rtt_ros2 Boost::filesystem)
if(TARGET LibXml2::LibXml2)
target_link_libraries(rtt_ros2 LibXml2::LibXml2)
else()
target_compile_definitions(rtt_ros2 PRIVATE ${LIBXML2_DEFINITIONS})
target_include_directories(rtt_ros2 PRIVATE ${LIBXML2_INCLUDE_DIR})
target_link_libraries(rtt_ros2 ${LIBXML2_LIBRARIES})
endif()
orocos_plugin(rtt_ros2_service
src/rtt_ros2_service.cpp
)
target_link_libraries(rtt_ros2_service rtt_ros2)
# install
install(
DIRECTORY cmake
DESTINATION share/${PROJECT_NAME}
)
install(
DIRECTORY include/
DESTINATION include
)
install(
DIRECTORY ${CMAKE_BINARY_DIR}/include/
DESTINATION include
)
# export information to downstream packages
ament_export_dependencies(ament_index_cpp)
#ament_export_dependencies(Boost) # exported in rtt_ros2-extras.cmake
#ament_export_dependencies(LibXml2) # exported in rtt_ros2-extras.cmake
ament_export_include_directories(include/orocos)
if(COMMAND ament_export_targets)
ament_export_targets(${PROJECT_NAME} HAS_LIBRARY_TARGET)
else()
ament_export_interfaces(${PROJECT_NAME} HAS_LIBRARY_TARGET)
endif()
# linters
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
# export no plugin dependencies for this package, such that package.xml is not searched
# for recursive dependencies
ament_index_register_resource("rtt_ros2_plugin_depends" CONTENT "")
# register environment hooks to prepend to RTT_COMPONENT_PATH and PKG_CONFIG_PATH
set(
AMENT_CMAKE_ENVIRONMENT_HOOKS_DESC_rtt_component_path
"prepend-non-duplicate;RTT_COMPONENT_PATH;lib/orocos"
)
ament_environment_hooks(env_hook/rtt_component_path.sh.in)
set(
AMENT_CMAKE_ENVIRONMENT_HOOKS_DESC_pkg_config_path
"prepend-non-duplicate;PKG_CONFIG_PATH;lib/pkgconfig"
)
ament_environment_hooks(env_hook/pkg_config_path.sh.in)
# must be called *after* the targets to check exported libraries etc.
ament_package(
CONFIG_EXTRAS
cmake/${PROJECT_NAME}-extras.cmake
cmake/${PROJECT_NAME}_export_plugin_depend_hook-extras.cmake
cmake/${PROJECT_NAME}_export_plugin_depend.cmake
cmake/${PROJECT_NAME}_use_orocos.cmake
)
# orocos_generate_package() is deprecated for ROS 2.
# Prefer cmake target export and import instead, in combination with
# ament_export_interfaces() or ament_export_targets() when building with
# ament_cmake.
orocos_generate_package()