-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
415 lines (348 loc) · 10.8 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
cmake_minimum_required(VERSION 3.1.2)
project(mrs_lib)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# please, NEVER commit those alternative flags with specific overrides of optimization
# add the address sanitizer compiler flags to debug build type
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined -fno-omit-frame-pointer") # because normal release is just -O2
# add the address sanitizer linker flags to debug build type
# set(CMAKE_LD_FLAGS_DEBUG "${CMAKE_LD_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined") # because normal release is just -O2
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") # because normal release is just -O2
# please, really do not commit your temporary custom flags :-)
add_definitions(-Wall)
add_definitions(-Wextra)
add_definitions(-Wpedantic)
# if(CATKIN_ENABLE_TESTING AND MRS_ENABLE_TESTING)
# add_definitions(-fsanitize=address -g3 -fno-omit-frame-pointer)
# add_link_options(-fsanitize=address)
# endif()
if(COVERAGE)
message(WARNING "building with --coverage, the performance might be limited")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif()
# remove warning info from PCL
set(PCL_FIND_QUIETLY INTERNAL)
set(CATKIN_DEPENDENCIES
cmake_modules
cv_bridge
geometry_msgs
image_transport
mrs_msgs
nav_msgs
pcl_conversions
pcl_msgs
pcl_ros
roscpp
sensor_msgs
std_msgs
tf2
tf2_geometry_msgs
tf_conversions
visualization_msgs
)
find_package(catkin REQUIRED COMPONENTS
${CATKIN_DEPENDENCIES}
)
find_package(yaml-cpp REQUIRED)
# include Eigen3
find_package(Eigen3 REQUIRED)
set(Eigen_INCLUDE_DIRS ${EIGEN3_INCLUDE_DIRS})
set(Eigen_LIBRARIES ${EIGEN3_LIBRARIES})
# include OpenCV
find_package(OpenCV REQUIRED HINTS /usr/local/lib)
###################################
## catkin specific configuration ##
###################################
set(LIBRARIES
MrsLib_SafetyZone
MrsLib_Profiler
MrsLib_ScopeTimer
MrsLib_IirFilter
MrsLib_NotchFilter
MrsLib_Utils
MrsLib_ParamProvider
MrsLib_ParamLoader
MrsLib_MedianFilter
MrsLib_OdomLKF
MrsLib_Geometry
MrsLib_BatchVisualizer
MrsLib_AttitudeConverter
MrsLib_Transformer
MrsLib_ImagePublisher
MrsLib_Timer
MrsLib_TransformBroadcaster
MrsLib_Math
MrsLib_DynamicPublisher
MrsLib_TimeoutManager
)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS ${CATKIN_DEPENDENCIES}
DEPENDS Eigen YAML_CPP
LIBRARIES ${LIBRARIES}
)
## --------------------------------------------------------------
## | Build |
## --------------------------------------------------------------
include_directories(
include
${catkin_INCLUDE_DIRS}
${Eigen_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${pcl_ros_INCLUDE_DIRS}
${YAML_CPP_INCLUDE_DIRS}
)
add_library(MrsLib_TimeoutManager src/timeout_manager/timeout_manager.cpp)
target_link_libraries(MrsLib_TimeoutManager
${catkin_LIBRARIES}
)
add_library(MrsLib_DynamicPublisher src/dynamic_publisher/dynamic_publisher.cpp)
target_link_libraries(MrsLib_DynamicPublisher
${catkin_LIBRARIES}
)
add_executable(dynamic_publisher_example src/dynamic_publisher/example.cpp)
target_link_libraries(dynamic_publisher_example
MrsLib_DynamicPublisher
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(repredictor_example src/repredictor/example.cpp)
target_link_libraries(repredictor_example
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(service_client_handler_example src/service_client_handler/example.cpp)
target_link_libraries(service_client_handler_example
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_OdomLKF src/lkf/LKF_MRS_odom.cpp)
target_link_libraries(MrsLib_OdomLKF
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(lkf_example src/lkf/example.cpp)
target_link_libraries(lkf_example
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(dkf_example src/dkf/example.cpp)
target_link_libraries(dkf_example
MrsLib_Geometry
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
# # Slows the compilation of the library waaaay too much - just generate the conversions on-demand
# # instead of pre-generating all combinations.
# add_library(MrsLib_VectorConverter src/vector_converter/vector_converter.cpp)
# target_link_libraries(MrsLib_VectorConverter
# ${catkin_LIBRARIES}
# ${Eigen_LIBRARIES}
# ${pcl_ros_LIBRARIES}
# )
# target_include_directories(MrsLib_VectorConverter PRIVATE
# ${pcl_ros_INCLUDE_DIRS}
# )
add_executable(vector_converter_example src/vector_converter/example.cpp)
target_link_libraries(vector_converter_example
# MrsLib_VectorConverter
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
${pcl_ros_LIBRARIES}
)
target_include_directories(vector_converter_example PRIVATE
${pcl_ros_INCLUDE_DIRS}
)
add_executable(ukf_example src/ukf/example.cpp)
target_link_libraries(ukf_example
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(nckf_tests src/nckf/nckf_tests.cpp)
target_link_libraries(nckf_tests
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_SafetyZone src/safety_zone/safety_zone.cpp
src/safety_zone/line_operations.cpp
src/safety_zone/polygon/polygon.cpp
)
target_link_libraries(MrsLib_SafetyZone
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_Profiler src/profiler/profiler.cpp)
target_link_libraries(MrsLib_Profiler
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_ScopeTimer src/scope_timer/scope_timer.cpp)
target_link_libraries(MrsLib_ScopeTimer
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_MedianFilter src/median_filter/median_filter.cpp)
target_link_libraries(MrsLib_MedianFilter
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_IirFilter src/iir_filter/iir_filter.cpp)
target_link_libraries(MrsLib_IirFilter
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_NotchFilter src/notch_filter/notch_filter.cpp)
target_link_libraries(MrsLib_NotchFilter
MrsLib_IirFilter
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(mutex_tests src/mutex/mutex_tests.cpp)
target_link_libraries(mutex_tests
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_AttitudeConverter src/attitude_converter/attitude_converter.cpp)
target_link_libraries(MrsLib_AttitudeConverter
MrsLib_Geometry
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_Transformer src/transformer/transformer.cpp)
target_link_libraries(MrsLib_Transformer
MrsLib_Geometry
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
target_include_directories(MrsLib_Transformer PRIVATE
${pcl_ros_INCLUDE_DIRS}
)
add_executable(transformer_example src/transformer/example.cpp)
target_link_libraries(transformer_example
MrsLib_Transformer
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_Utils src/utils/utils.cpp)
target_link_libraries(MrsLib_Utils
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_ParamProvider src/param_loader/param_provider.cpp)
target_link_libraries(MrsLib_ParamProvider
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
${YAML_CPP_LIBRARIES}
)
add_library(MrsLib_ParamLoader src/param_loader/param_loader.cpp)
target_link_libraries(MrsLib_ParamLoader
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
MrsLib_ParamProvider
)
add_library(MrsLib_TransformBroadcaster src/transform_broadcaster/transform_broadcaster.cpp)
target_link_libraries(MrsLib_TransformBroadcaster
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(param_loader_example src/param_loader/example.cpp)
target_link_libraries(param_loader_example
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
MrsLib_ParamLoader
)
add_executable(param_provider_example src/param_loader/param_provider_example.cpp)
target_link_libraries(param_provider_example
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
MrsLib_ParamProvider
)
add_executable(subscribe_handler_example src/subscribe_handler/example.cpp)
target_link_libraries(subscribe_handler_example
MrsLib_TimeoutManager
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(subscribe_handler_simple_example src/subscribe_handler/simple_example.cpp)
target_link_libraries(subscribe_handler_simple_example
MrsLib_TimeoutManager
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(rheiv_example src/rheiv/example.cpp)
target_link_libraries(rheiv_example
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_library(MrsLib_BatchVisualizer src/batch_visualizer/batch_visualizer.cpp src/batch_visualizer/visual_object.cpp)
target_link_libraries(MrsLib_BatchVisualizer
MrsLib_Geometry
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
${GAZEBO_INCLUDE_DIRS}
)
add_library(MrsLib_ImagePublisher src/image_publisher/image_publisher.cpp)
target_link_libraries(MrsLib_ImagePublisher
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
${OpenCV_LIBRARIES}
${GAZEBO_INCLUDE_DIRS}
)
add_executable(batch_visualizer_demo src/batch_visualizer/batch_visualizer_demo.cpp)
target_link_libraries(batch_visualizer_demo
MrsLib_Geometry
MrsLib_BatchVisualizer
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
${GAZEBO_INCLUDE_DIRS}
)
add_library(MrsLib_Math src/math/math.cpp)
target_link_libraries(MrsLib_Math
${catkin_LIBRARIES}
)
add_library(MrsLib_Geometry src/geometry/misc.cpp src/geometry/cyclic.cpp src/geometry/shapes.cpp src/geometry/conversions.cpp)
target_link_libraries(MrsLib_Geometry
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
${OpenCV_LIBRARIES}
${GAZEBO_INCLUDE_DIRS}
)
add_library(MrsLib_Timer src/timer/timer.cpp)
target_link_libraries(MrsLib_Timer
${catkin_LIBRARIES}
)
add_executable(geometry_tests src/geometry/tests.cpp)
target_link_libraries(geometry_tests
MrsLib_Geometry
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
add_executable(cyclic_example src/geometry/cyclic_example.cpp)
target_link_libraries(cyclic_example
MrsLib_Geometry
${catkin_LIBRARIES}
${Eigen_LIBRARIES}
)
## --------------------------------------------------------------
## | Testing |
## --------------------------------------------------------------
if(CATKIN_ENABLE_TESTING AND MRS_ENABLE_TESTING)
message(WARNING "Testing enabled.")
add_subdirectory(test)
endif()
## --------------------------------------------------------------
## | Install |
## --------------------------------------------------------------
install(TARGETS ${LIBRARIES}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)
install(DIRECTORY include/mrs_lib/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)
install(DIRECTORY
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
FILES_MATCHING PATTERN "*.xml"
)