forked from ctu-mrs/ros2_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
233 lines (181 loc) · 6.55 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
cmake_minimum_required(VERSION 3.5)
project(ros2_examples)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
# include_directories(
# include
# )
## --------------------------------------------------------------
## | subscriber example |
## --------------------------------------------------------------
add_library(subscriber_example SHARED
src/subscriber_example.cpp
)
# TODO WHY IS THIS HERE?
target_compile_definitions(subscriber_example
PRIVATE "ros2_examples_BUILDING_DLL")
ament_target_dependencies(subscriber_example
rclcpp
rclcpp_components
std_msgs
)
# TODO HOW DOES THIS WORK?
rclcpp_components_register_nodes(subscriber_example PLUGIN "ros2_examples::SubscriberExample" EXECUTABLE subscriber_example)
## --------------------------------------------------------------
## | publisher example |
## --------------------------------------------------------------
add_library(publisher_example SHARED
src/publisher_example.cpp
)
# TODO WHY IS THIS HERE?
target_compile_definitions(publisher_example
PRIVATE "ros2_examples_BUILDING_DLL")
ament_target_dependencies(publisher_example
rclcpp
rclcpp_components
std_msgs
)
# TODO HOW DOES THIS WORK?
rclcpp_components_register_nodes(publisher_example PLUGIN "ros2_examples::PublisherExample" EXECUTABLE publisher_example)
## --------------------------------------------------------------
## | service server example |
## --------------------------------------------------------------
add_library(service_server_example SHARED
src/service_server_example.cpp
)
# TODO WHY IS THIS HERE?
target_compile_definitions(service_server_example
PRIVATE "ros2_examples_BUILDING_DLL")
ament_target_dependencies(service_server_example
rclcpp
rclcpp_components
std_srvs
)
# TODO HOW DOES THIS WORK?
rclcpp_components_register_nodes(service_server_example PLUGIN "ros2_examples::ServiceServerExample" EXECUTABLE service_server_example)
## --------------------------------------------------------------
## | service client example |
## --------------------------------------------------------------
add_library(service_client_example SHARED
src/service_client_example.cpp
)
# TODO WHY IS THIS HERE?
target_compile_definitions(service_client_example
PRIVATE "ros2_examples_BUILDING_DLL")
ament_target_dependencies(service_client_example
rclcpp
rclcpp_components
std_srvs
)
# TODO HOW DOES THIS WORK?
rclcpp_components_register_nodes(service_client_example PLUGIN "ros2_examples::ServiceClientExample" EXECUTABLE service_client_example)
## --------------------------------------------------------------
## | timer example |
## --------------------------------------------------------------
add_library(timer_example SHARED
src/timer_example.cpp
)
# TODO WHY IS THIS HERE?
target_compile_definitions(timer_example
PRIVATE "ros2_examples_BUILDING_DLL")
ament_target_dependencies(timer_example
rclcpp
rclcpp_components
std_srvs
)
# TODO HOW DOES THIS WORK?
rclcpp_components_register_nodes(timer_example PLUGIN "ros2_examples::TimerExample" EXECUTABLE timer_example)
## --------------------------------------------------------------
## | params example |
## --------------------------------------------------------------
add_library(params_example SHARED
src/params_example.cpp
)
# TODO WHY IS THIS HERE?
target_compile_definitions(params_example
PRIVATE "ros2_examples_BUILDING_DLL")
ament_target_dependencies(params_example
rclcpp
rclcpp_components
std_msgs
std_srvs
)
# makes a component executable
# rclcpp_components_register_nodes(lib_name PLUGIN "namespace::class_name" EXECUTABLE executable_name)
# # lib_name = add_library(lib_name ...
# # executable_name => ros2 run package_name executable_name
rclcpp_components_register_nodes(params_example PLUGIN "ros2_examples::ParamsExample" EXECUTABLE params_example)
## --------------------------------------------------------------
## | tf2_broadcaster_example |
## --------------------------------------------------------------
add_library(tf2_broadcaster_example SHARED
src/tf2_broadcaster_example.cpp
)
# TODO WHY IS THIS HERE?
target_compile_definitions(tf2_broadcaster_example
PRIVATE "tf2_broadcaster_example_BUILDING_DLL")
ament_target_dependencies(tf2_broadcaster_example
rclcpp
rclcpp_components
tf2_ros
geometry_msgs
)
# TODO HOW DOES THIS WORK?
rclcpp_components_register_nodes(tf2_broadcaster_example PLUGIN "ros2_examples::Tf2BroadcasterExample" EXECUTABLE tf2_broadcaster_example)
## --------------------------------------------------------------
## | tf2_broadcaster_example |
## --------------------------------------------------------------
add_library(tf2_listener_example SHARED
src/tf2_listener_example.cpp
)
# TODO WHY IS THIS HERE?
target_compile_definitions(tf2_listener_example
PRIVATE "tf2_listener_example_BUILDING_DLL")
ament_target_dependencies(tf2_listener_example
rclcpp
rclcpp_components
tf2_ros
geometry_msgs
)
# TODO HOW DOES THIS WORK?
rclcpp_components_register_nodes(tf2_listener_example PLUGIN "ros2_examples::Tf2ListenerExample" EXECUTABLE tf2_listener_example)
## --------------------------------------------------------------
## | bank of unused stuff |
## --------------------------------------------------------------
# target_link_libraries(timer_example
# )
# set(node_plugins "${node_plugins}${PROJECT_NAME}::ServiceServerExample\n")
## --------------------------------------------------------------
## | install |
## --------------------------------------------------------------
install(TARGETS
params_example
subscriber_example
publisher_example
service_server_example
service_client_example
timer_example
tf2_broadcaster_example
tf2_listener_example
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
# install(DIRECTORY include/
# DESTINATION include/
# )
install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
)
install(DIRECTORY config
DESTINATION share/${PROJECT_NAME}
)
ament_package()