This repository was archived by the owner on Mar 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
348 lines (296 loc) · 9.28 KB
/
CMakeLists.txt
File metadata and controls
348 lines (296 loc) · 9.28 KB
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
#
# Development of this module has been funded by the Monterey Bay Aquarium
# Research Institute (MBARI) and the David and Lucile Packard Foundation
#
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(lrauv_ignition_plugins)
# Option to enable profiler
option(ENABLE_PROFILER "Enable Ignition Profiler" FALSE)
if(ENABLE_PROFILER)
add_definitions("-DIGN_PROFILER_ENABLE=1")
else()
add_definitions("-DIGN_PROFILER_ENABLE=0")
endif()
#============================================================================
# Find dependencies
find_package(ignition-cmake2 REQUIRED)
find_package(ignition-gazebo7 REQUIRED COMPONENTS gui)
set(IGN_GAZEBO_VER ${ignition-gazebo7_VERSION_MAJOR})
find_package(ignition-gui7 REQUIRED)
set(IGN_GUI_VER ${ignition-gui7_VERSION_MAJOR})
find_package(ignition-rendering7 REQUIRED)
set(IGN_RENDERING_VER ${ignition-rendering7_VERSION_MAJOR})
find_package(ignition-sensors7 REQUIRED)
set(IGN_SENSORS_VER ${ignition-sensors7_VERSION_MAJOR})
find_package(ignition-msgs9 REQUIRED)
set(IGN_MSGS_VER ${ignition-msgs9_VERSION_MAJOR})
find_package(ignition-plugin1 REQUIRED COMPONENTS register)
set(IGN_PLUGIN_VER ${ignition-plugin1_VERSION_MAJOR})
find_package(ignition-utils1 REQUIRED)
set(IGN_UTILS_VER ${ignition-utils1_VERSION_MAJOR})
find_package(ignition-common5 REQUIRED COMPONENTS profiler)
set(IGN_COMMON_VER ${ignition-common5_VERSION_MAJOR})
find_package (Eigen3 3.3 REQUIRED)
find_package(PCL 1.2 REQUIRED)
# Build protobuf messages
add_subdirectory(proto)
#============================================================================
# Plugins
# add_lrauv_plugin (<plugin_name>
# [PROTO] msg1 msg2 ... [PCL] [GUI] [RENDERING] [PRIVATE_LINK_LIBS] [INCLUDE_COMMS])
#
# Configure and install plugins.
#
# <plugin_name> Required. Name of the plugin library, which matches source file.
#
# [PROTO]: Optional. If included, plugin will be linked against custom protobuf
# messages that are listed.
#
# [PCL]: Optional. If included, plugin will be linked against PCL.
#
# [GUI]: Optional. Include for GUI plugins.
#
# [RENDERING]: Optional. Include to link against Ignition Rendering.
#
# [PRIVATE_LINK_LIBS]: Specify a list of libraries to be privately linked.
#
# [INCLUDE_COMMS]: Optional. Include comms header files.
function(add_lrauv_plugin PLUGIN)
set(options PCL GUI RENDERING INCLUDE_COMMS)
set(oneValueArgs)
set(multiValueArgs PROTO PRIVATE_LINK_LIBS)
cmake_parse_arguments(add_lrauv_plugin
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(PLUGIN_SOURCES src/${PLUGIN}.cc)
set(INSTALL_LIB lib)
# GUI plugin
if (add_lrauv_plugin_GUI)
QT5_WRAP_CPP(${PLUGIN}_headers_MOC src/${PLUGIN}.hh)
QT5_ADD_RESOURCES(${PLUGIN}_RCC src/${PLUGIN}.qrc)
set(PLUGIN_SOURCES ${PLUGIN_SOURCES}
${${PLUGIN}_headers_MOC}
${${PLUGIN}_RCC}
)
set(INSTALL_LIB lib/gui)
endif()
# All plugins
add_library(${PLUGIN}
SHARED ${PLUGIN_SOURCES})
set_property(TARGET ${PLUGIN} PROPERTY CXX_STANDARD 17)
target_link_libraries(${PLUGIN}
PUBLIC
ignition-common${IGN_COMMON_VER}::profiler
ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}
ignition-gazebo${IGN_GAZEBO_VER}::ignition-gazebo${IGN_GAZEBO_VER}
PRIVATE
${add_lrauv_plugin_PRIVATE_LINK_LIBS}
)
# Link against proto libraries
if (add_lrauv_plugin_PROTO)
target_include_directories(${PLUGIN}
PUBLIC ${CMAKE_BINARY_DIR}/proto)
target_link_libraries(${PLUGIN}
PUBLIC ${add_lrauv_plugin_PROTO})
add_dependencies(${PLUGIN} ${add_lrauv_plugin_PROTO})
endif()
# Include comms
if (add_lrauv_plugin_INCLUDE_COMMS)
target_include_directories(${PLUGIN}
PUBLIC include)
endif()
# Include PCL
if (add_lrauv_plugin_PCL)
target_include_directories(${PLUGIN}
PUBLIC ${PCL_INCLUDE_DIRS})
endif()
# GUI
if (add_lrauv_plugin_GUI)
target_link_libraries(${PLUGIN}
PUBLIC
TINYXML2::TINYXML2
PRIVATE
ignition-gui${IGN_GUI_VER}::ignition-gui${IGN_GUI_VER}
)
target_include_directories(${PLUGIN}
PUBLIC ${PCL_INCLUDE_DIRS})
endif()
# Rendering
if (add_lrauv_plugin_RENDERING)
target_link_libraries(${PLUGIN}
PRIVATE
ignition-rendering${IGN_RENDERING_VER}::ignition-rendering${IGN_RENDERING_VER}
)
endif()
install(
TARGETS ${PLUGIN}
DESTINATION ${INSTALL_LIB})
endfunction()
add_subdirectory(src/comms/)
add_lrauv_plugin(AcousticCommsPlugin
INCLUDE_COMMS
PROTO
lrauv_acoustic_message
lrauv_internal_comms
PRIVATE_LINK_LIBS
CommsSupport)
add_lrauv_plugin(ControlPanelPlugin GUI
PROTO
lrauv_command
lrauv_state)
add_lrauv_plugin(HydrodynamicsPlugin)
add_lrauv_plugin(RangeBearingPlugin
INCLUDE_COMMS
PROTO
lrauv_range_bearing_request
lrauv_range_bearing_response
lrauv_acoustic_message)
add_lrauv_plugin(ReferenceAxis GUI RENDERING)
add_lrauv_plugin(ScienceSensorsSystem
PCL
PRIVATE_LINK_LIBS
ignition-sensors${IGN_SENSORS_VER}::ignition-sensors${IGN_SENSORS_VER}
${PCL_LIBRARIES})
add_lrauv_plugin(TethysCommPlugin
PROTO
lrauv_command
lrauv_state)
add_lrauv_plugin(TimeAnalysisPlugin)
add_lrauv_plugin(WorldCommPlugin
PROTO
lrauv_init)
#============================================================================
# Install public headers
install(
DIRECTORY include/
DESTINATION include
FILES_MATCHING
PATTERN "*.hh")
#============================================================================
# Examples
foreach(EXAMPLE
example_buoyancy
example_controller
example_elevator
example_mass_shifter
example_rudder
example_spawn
example_thruster
keyboard_teleop
multi_lrauv_race)
set(EXAMPLE_EXEC LRAUV_${EXAMPLE})
add_executable(${EXAMPLE_EXEC} example/${EXAMPLE}.cc)
set_property(TARGET ${EXAMPLE_EXEC} PROPERTY CXX_STANDARD 17)
target_include_directories(${EXAMPLE_EXEC}
PUBLIC ${CMAKE_BINARY_DIR}/proto)
target_link_libraries(${EXAMPLE_EXEC}
PRIVATE ignition-gazebo${IGN_GAZEBO_VER}::ignition-gazebo${IGN_GAZEBO_VER}
PUBLIC lrauv_command
lrauv_init)
install(
TARGETS ${EXAMPLE_EXEC}
DESTINATION bin)
endforeach()
#============================================================================
# Hooks
configure_file(
"hooks/hook.dsv.in"
"${CMAKE_CURRENT_BINARY_DIR}/hooks/hook.dsv" @ONLY
)
#============================================================================
# World generation
set(WORLD_NAME "portuguese_ledge")
add_custom_command(
OUTPUT world_gen_cmd
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/worlds/empy_expander.py
${CMAKE_CURRENT_SOURCE_DIR}/worlds/${WORLD_NAME}.sdf.em
${CMAKE_CURRENT_BINARY_DIR}/worlds/${WORLD_NAME}.sdf
)
add_custom_target(world_gen_target ALL
DEPENDS world_gen_cmd
)
#============================================================================
# Tests
if(BUILD_TESTING)
# Fetch and configure GTest
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
include(Dart)
# Build-time constants
set("PROJECT_BINARY_PATH" ${CMAKE_CURRENT_BINARY_DIR})
set("PROJECT_SOURCE_PATH" ${CMAKE_CURRENT_SOURCE_DIR})
configure_file(test/helper/TestConstants.hh.in TestConstants.hh @ONLY)
include(GoogleTest)
# Tests
foreach(TEST_TARGET
test_acoustic_comms_orientation
test_ahrs
test_buoyancy_action
test_controller
test_drop_weight
test_elevator
test_hydrodynamics_equilibrium_velocity
test_mass_shifter
test_mission_depth_vbs
test_mission_pitch_and_depth_mass_vbs
test_mission_pitch_mass
test_mission_yoyo_circle
test_rudder
test_spawn
test_state_msg)
add_executable(
${TEST_TARGET}
test/${TEST_TARGET}.cc
)
target_include_directories(${TEST_TARGET}
PUBLIC ${CMAKE_BINARY_DIR}/proto)
target_link_libraries(${TEST_TARGET}
PUBLIC gtest_main
PRIVATE ignition-gazebo${IGN_GAZEBO_VER}::ignition-gazebo${IGN_GAZEBO_VER}
lrauv_command
lrauv_init
lrauv_state
lrauv_range_bearing_request
lrauv_range_bearing_response
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
gtest_discover_tests(${TEST_TARGET})
endforeach()
add_executable(test_comms test/test_comms.cc)
target_include_directories(test_comms
PUBLIC
${CMAKE_BINARY_DIR}/proto
include/)
target_link_libraries(test_comms
PUBLIC gtest_main
PRIVATE ignition-gazebo${IGN_GAZEBO_VER}::ignition-gazebo${IGN_GAZEBO_VER}
lrauv_acoustic_message
lrauv_internal_comms
CommsSupport)
gtest_discover_tests(test_comms)
add_executable(test_range_bearing test/test_range_bearing.cc)
target_include_directories(test_range_bearing
PUBLIC
${CMAKE_BINARY_DIR}/proto
include/)
target_link_libraries(test_range_bearing
PUBLIC gtest_main
PRIVATE ignition-gazebo${IGN_GAZEBO_VER}::ignition-gazebo${IGN_GAZEBO_VER}
lrauv_range_bearing_request
lrauv_range_bearing_response)
gtest_discover_tests(test_range_bearing)
endif()
#============================================================================
# Resources
install(
DIRECTORY
data
models
worlds
${CMAKE_CURRENT_BINARY_DIR}/hooks
DESTINATION share/${PROJECT_NAME})