-
Notifications
You must be signed in to change notification settings - Fork 41
/
CMakeLists.txt
307 lines (276 loc) · 8.75 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
cmake_minimum_required(VERSION 3.5)
project(septentrio_gnss_driver)
## Compile as C++17
add_compile_options(-std=c++17)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to Release as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
set(WARNFLAGS "-Wall -Wextra -Wpedantic -Wcast-align -Wnon-virtual-dtor -Woverloaded-virtual -Wcast-qual -Wctor-dtor-privacy")
## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED)
LIST(APPEND CMAKE_MODULE_PATH "/usr/share/cmake/geographiclib")
find_package(GeographicLib REQUIRED)
## For PCAP file handling
find_library(libpcap_LIBRARIES pcap)
if ("${libpcap_LIBRARIES}" STREQUAL "pcap-NOTFOUND")
set(libpcap_FOUND FALSE)
else ()
set(libpcap_FOUND TRUE)
endif ()
find_package(ament_cmake QUIET)
find_package(catkin QUIET)
if(catkin_FOUND)
## ROS 1 -----------------------------------------------------------------------------------------------
add_compile_definitions(ROS1)
set(ENV{ROS_VERSION} "1")
configure_file(${CMAKE_SOURCE_DIR}/msg_cache/BlockHeaderRos1.msg ${CMAKE_SOURCE_DIR}/msg/BlockHeader.msg COPYONLY)
## Dependencies
find_package(catkin REQUIRED COMPONENTS
roscpp
nmea_msgs
sensor_msgs
geometry_msgs
nav_msgs
diagnostic_msgs
gps_common
message_generation
tf2
tf2_eigen
tf2_geometry_msgs
tf2_ros
)
## Declare messages
add_message_files(
FILES
AIMPlusStatus.msg
BaseVectorCart.msg
BaseVectorGeod.msg
BlockHeader.msg
GALAuthStatus.msg
RFBand.msg
RFStatus.msg
MeasEpoch.msg
MeasEpochChannelType1.msg
MeasEpochChannelType2.msg
PVTCartesian.msg
PVTGeodetic.msg
PosCovCartesian.msg
PosCovGeodetic.msg
ReceiverTime.msg
VelCovCartesian.msg
VelCovGeodetic.msg
AttEuler.msg
AttCovEuler.msg
INSNavCart.msg
INSNavGeod.msg
IMUSetup.msg
VectorInfoCart.msg
VectorInfoGeod.msg
VelSensorSetup.msg
ExtSensorMeas.msg
)
## Generate messages
generate_messages(
DEPENDENCIES
std_msgs
sensor_msgs
diagnostic_msgs
gps_common
)
# Catkin package
catkin_package(
INCLUDE_DIRS include
LIBRARIES
CATKIN_DEPENDS roscpp message_runtime
DEPENDS Boost
)
# Build
include_directories(
include
${catkin_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${GeographicLib_INCLUDE_DIRS}
)
add_executable(${PROJECT_NAME}_node
src/septentrio_gnss_driver/communication/communication_core.cpp
src/septentrio_gnss_driver/communication/message_handler.cpp
src/septentrio_gnss_driver/communication/telegram_handler.cpp
src/septentrio_gnss_driver/crc/crc.cpp
src/septentrio_gnss_driver/node/rosaic_node_ros1.cpp
src/septentrio_gnss_driver/parsers/nmea_parsers/gpgga.cpp
src/septentrio_gnss_driver/parsers/nmea_parsers/gprmc.cpp
src/septentrio_gnss_driver/parsers/nmea_parsers/gpgsa.cpp
src/septentrio_gnss_driver/parsers/nmea_parsers/gpgsv.cpp
src/septentrio_gnss_driver/parsers/parsing_utilities.cpp
src/septentrio_gnss_driver/parsers/string_utilities.cpp
)
add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME}_node
${catkin_LIBRARIES}
boost_regex # ordering is important for regex https://stackoverflow.com/questions/17588440/cannot-link-boost-regex
${Boost_LIBRARIES}
${libpcap_LIBRARIES}
${GeographicLib_LIBRARIES}
)
# Installation
install(TARGETS ${PROJECT_NAME}_node
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)
install(DIRECTORY config launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
#-------------------------------------------------------------------------------------------------------
elseif(ament_cmake_FOUND)
## ROS 2 -----------------------------------------------------------------------------------------------
add_compile_definitions(ROS2)
set(ENV{ROS_VERSION} "2")
configure_file(${CMAKE_SOURCE_DIR}/msg_cache/BlockHeaderRos2.msg ${CMAKE_SOURCE_DIR}/msg/BlockHeader.msg COPYONLY)
unset(CATKIN_INSTALL_INTO_PREFIX_ROOT)
unset(CATKIN_SYMLINK_INSTALL)
# Dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(diagnostic_msgs REQUIRED)
find_package(nmea_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(gps_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_eigen REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
## Declare messages
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/AIMPlusStatus.msg"
"msg/BaseVectorCart.msg"
"msg/BaseVectorGeod.msg"
"msg/BlockHeader.msg"
"msg/GALAuthStatus.msg"
"msg/RFBand.msg"
"msg/RFStatus.msg"
"msg/MeasEpoch.msg"
"msg/MeasEpochChannelType1.msg"
"msg/MeasEpochChannelType2.msg"
"msg/PVTCartesian.msg"
"msg/PVTGeodetic.msg"
"msg/PosCovCartesian.msg"
"msg/PosCovGeodetic.msg"
"msg/ReceiverTime.msg"
"msg/VelCovCartesian.msg"
"msg/VelCovGeodetic.msg"
"msg/AttEuler.msg"
"msg/AttCovEuler.msg"
"msg/INSNavCart.msg"
"msg/INSNavGeod.msg"
"msg/IMUSetup.msg"
"msg/VectorInfoCart.msg"
"msg/VectorInfoGeod.msg"
"msg/VelSensorSetup.msg"
"msg/ExtSensorMeas.msg"
DEPENDENCIES std_msgs
)
set(library_name septentrio_gnss_driver_core)
set(executable_name septentrio_gnss_driver_node)
set(dependencies
rclcpp
rclcpp_components
diagnostic_msgs
nmea_msgs
sensor_msgs
geometry_msgs
gps_msgs
nav_msgs
tf2
tf2_eigen
tf2_geometry_msgs
tf2_ros
)
## shared library
add_library(${library_name} SHARED
src/septentrio_gnss_driver/communication/communication_core.cpp
src/septentrio_gnss_driver/communication/message_handler.cpp
src/septentrio_gnss_driver/communication/telegram_handler.cpp
src/septentrio_gnss_driver/crc/crc.cpp
src/septentrio_gnss_driver/node/main.cpp
src/septentrio_gnss_driver/node/rosaic_node.cpp
src/septentrio_gnss_driver/parsers/nmea_parsers/gpgga.cpp
src/septentrio_gnss_driver/parsers/nmea_parsers/gprmc.cpp
src/septentrio_gnss_driver/parsers/nmea_parsers/gpgsa.cpp
src/septentrio_gnss_driver/parsers/nmea_parsers/gpgsv.cpp
src/septentrio_gnss_driver/parsers/parsing_utilities.cpp
src/septentrio_gnss_driver/parsers/string_utilities.cpp
)
target_include_directories(${library_name} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(${library_name}
boost_regex # ordering is important for regex https://stackoverflow.com/questions/17588440/cannot-link-boost-regex
${Boost_LIBRARIES}
pcap
${GeographicLib_LIBRARIES}
)
ament_target_dependencies(${library_name}
${dependencies}
)
if(${rosidl_cmake_VERSION} VERSION_LESS 2.5.0)
rosidl_target_interfaces(${library_name}
${PROJECT_NAME} "rosidl_typesupport_cpp")
else()
rosidl_get_typesupport_target(
cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp")
target_link_libraries(${library_name} "${cpp_typesupport_target}")
add_compile_definitions(ROS2_VER_N250)
endif()
## executable
add_executable(${executable_name}
src/septentrio_gnss_driver/node/main.cpp
)
target_link_libraries(${executable_name}
${library_name}
)
ament_target_dependencies(${executable_name}
${dependencies}
)
rclcpp_components_register_nodes(${library_name} "rosaic_node::ROSaicNode")
# Testing
find_package(ament_cmake_gtest REQUIRED)
add_subdirectory(test)
# Export Targets
ament_export_targets(${library_name} HAS_LIBRARY_TARGET)
ament_export_dependencies(${dependencies} rosidl_default_runtime)
# Installation
install(TARGETS
${library_name} EXPORT ${library_name}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(TARGETS ${executable_name} EXPORT ${executable_name}
DESTINATION lib/${PROJECT_NAME}
)
install(DIRECTORY include/
DESTINATION include/
)
install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
)
install(DIRECTORY config
DESTINATION share/${PROJECT_NAME}
)
ament_package()
##-------------------------------------------------------------------------
else()
message(FATAL_ERROR "Build failed because neither catkin nor ament found.")
endif()