-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
167 lines (138 loc) · 4.13 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
cmake_minimum_required(VERSION 3.5)
project(domain_bridge)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rcutils REQUIRED)
# Leverage rosbag2's generic type support utilities
find_package(rosbag2_cpp REQUIRED)
find_package(rosidl_typesupport_cpp REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(yaml_cpp_vendor REQUIRED)
find_package(zstd_vendor REQUIRED)
find_package(zstd REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
msg/CompressedMsg.msg
)
add_library(${PROJECT_NAME}_lib SHARED
src/${PROJECT_NAME}/component_manager.cpp
src/${PROJECT_NAME}/compress_messages.cpp
src/${PROJECT_NAME}/domain_bridge.cpp
src/${PROJECT_NAME}/domain_bridge_options.cpp
src/${PROJECT_NAME}/parse_domain_bridge_yaml_config.cpp
src/${PROJECT_NAME}/qos_options.cpp
src/${PROJECT_NAME}/service_bridge_options.cpp
src/${PROJECT_NAME}/topic_bridge_options.cpp
)
target_include_directories(${PROJECT_NAME}_lib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
if(CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(${PROJECT_NAME}_lib stdc++fs)
endif()
ament_target_dependencies(${PROJECT_NAME}_lib
rclcpp
rclcpp_components
rcutils
rosbag2_cpp
rosidl_typesupport_cpp
yaml_cpp_vendor
zstd
)
rosidl_get_typesupport_target(cpp_typesupport_target
${PROJECT_NAME} "rosidl_typesupport_cpp")
target_link_libraries(${PROJECT_NAME}_lib "${cpp_typesupport_target}")
set_target_properties(${PROJECT_NAME}_lib PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
add_executable(${PROJECT_NAME}_exec
src/domain_bridge.cpp
)
ament_target_dependencies(${PROJECT_NAME}_exec
"rclcpp_components")
set_target_properties(${PROJECT_NAME}_exec PROPERTIES OUTPUT_NAME ${PROJECT_NAME} PREFIX "")
target_link_libraries(${PROJECT_NAME}_exec
${PROJECT_NAME}_lib
)
# Only needed to build domain_bridge_rti_qos executable.
find_package(rti_connext_dds_cmake_module QUIET)
find_package(rcpputils QUIET)
set(executables ${PROJECT_NAME}_exec)
if(rti_connext_dds_cmake_module_FOUND AND rcpputils_FOUND)
rti_find_connextpro()
if(RTIConnextDDS_FOUND)
add_executable(${PROJECT_NAME}_rti_exec
src/domain_bridge_rti_qos.cpp
)
set_target_properties(${PROJECT_NAME}_rti_exec
PROPERTIES OUTPUT_NAME ${PROJECT_NAME}_rti_qos PREFIX "")
target_link_libraries(${PROJECT_NAME}_rti_exec
${PROJECT_NAME}_lib
RTIConnextDDS::c_api
)
ament_target_dependencies(${PROJECT_NAME}_rti_exec
rcpputils
)
list(APPEND executables ${PROJECT_NAME}_rti_exec)
endif()
endif()
install(DIRECTORY include/
DESTINATION include
)
install(TARGETS ${executables}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
install(TARGETS ${PROJECT_NAME}_lib
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
install(DIRECTORY examples launch
DESTINATION share/${PROJECT_NAME}
)
ament_export_targets(export_${PROJECT_NAME})
ament_export_dependencies(
rclcpp
rclcpp_components
rosbag2_cpp
rcutils
yaml_cpp_vendor
zstd_vendor
zstd
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
find_package(test_msgs REQUIRED)
ament_lint_auto_find_test_dependencies()
add_subdirectory(test)
add_library(${PROJECT_NAME}_test_component_lib SHARED
test/${PROJECT_NAME}/test_component.cpp
)
ament_target_dependencies(${PROJECT_NAME}_test_component_lib
rclcpp
rclcpp_components
test_msgs
)
rclcpp_components_register_node(${PROJECT_NAME}_test_component_lib
PLUGIN "domain_bridge::TestComponent"
EXECUTABLE test_component)
install(TARGETS ${PROJECT_NAME}_test_component_lib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)
endif()
ament_package()