-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
163 lines (143 loc) · 5.22 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
cmake_minimum_required(VERSION 3.8)
project(swiftnav_ros2_driver)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
################################################
# Check the ROS2 version
set(ROS2_FOUND FALSE)
if(DEFINED ENV{ROS_DISTRO})
set(FOUND_ROS2_DISTRO $ENV{ROS_DISTRO})
set(ROS2_FOUND TRUE)
else()
set(ROS2_DISTROS "ardent;crystal;dashing;eloquent;foxy;galactic;humble;rolling")
set(ROS2_FOUND FALSE)
foreach(distro ${ROS2_DISTROS})
if(NOT ROS2_FOUND)
find_path(RCLCPP_H rclcpp.hpp PATHS /opt/ros/${distro}/include/rclcpp)
if(RCLCPP_H)
set(FOUND_ROS2_DISTRO ${distro})
set(ROS2_FOUND TRUE)
endif()
endif()
endforeach()
endif()
if(${FOUND_ROS2_DISTRO} STREQUAL "foxy")
add_definitions(-DFOUND_FOXY)
elseif((${FOUND_ROS2_DISTRO} STREQUAL "galactic") OR (${FOUND_ROS2_DISTRO} STREQUAL "humble"))
add_definitions(-DFOUND_NEWER)
endif()
################################################
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(gps_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(tf2 REQUIRED)
link_directories("/usr/local/lib/")
include_directories("/usr/local/include/")
add_executable(sbp-to-ros
src/sbp-to-ros.cpp
src/data_sources/sbp_file_datasource.cpp
src/data_sources/sbp_serial_datasource.cpp
src/data_sources/sbp_tcp_datasource.cpp
src/data_sources/sbp_data_sources.cpp
src/data_sources/serial.cpp
src/data_sources/tcp.cpp
src/utils/utils.cpp
src/utils/config.cpp
src/logging/ros_logger.cpp
src/logging/sbp_to_ros2_logger.cpp
src/logging/sbp_file_logger.cpp
src/publishers/navsatfix_publisher.cpp
src/publishers/twistwithcovariancestamped_publisher.cpp
src/publishers/timereference_publisher.cpp
src/publishers/gpsfix_publisher.cpp
src/publishers/baseline_publisher.cpp
src/publishers/imu_publisher.cpp
src/publishers/publisher_factory.cpp
)
rosidl_generate_interfaces(${PROJECT_NAME}
"msg/Baseline.msg"
DEPENDENCIES std_msgs
)
if((${FOUND_ROS2_DISTRO} STREQUAL "foxy") OR (${FOUND_ROS2_DISTRO} STREQUAL "galactic"))
rosidl_target_interfaces(sbp-to-ros ${PROJECT_NAME} "rosidl_typesupport_cpp")
else()
rosidl_get_typesupport_target(cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp")
endif()
target_link_libraries(sbp-to-ros sbp serialport "${cpp_typesupport_target}")
target_include_directories(sbp-to-ros PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_compile_features(sbp-to-ros PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
ament_target_dependencies(sbp-to-ros rclcpp sensor_msgs geometry_msgs nav_msgs gps_msgs tf2)
ament_export_dependencies(rosidl_default_runtime)
install(TARGETS
sbp-to-ros
DESTINATION lib/${PROJECT_NAME}
)
install(DIRECTORY
launch
DESTINATION share/${PROJECT_NAME}
)
install(DIRECTORY
config
DESTINATION share/${PROJECT_NAME}
)
if(BUILD_TESTING)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(gps_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(tf2 REQUIRED)
link_directories("/usr/local/lib/")
include_directories("/usr/local/include/")
find_package(ament_lint_auto REQUIRED)
find_package(ament_cmake_gmock REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
ament_add_gmock(${PROJECT_NAME}_test
src/data_sources/sbp_serial_datasource.cpp
src/data_sources/sbp_tcp_datasource.cpp
src/data_sources/serial.cpp
src/data_sources/tcp.cpp
src/utils/utils.cpp
src/utils/config.cpp
src/publishers/baseline_publisher.cpp
src/publishers/gpsfix_publisher.cpp
src/publishers/imu_publisher.cpp
src/publishers/navsatfix_publisher.cpp
src/publishers/twistwithcovariancestamped_publisher.cpp
src/publishers/publisher_factory.cpp
src/publishers/timereference_publisher.cpp
test/mocked_logger.cpp
test/test_network.cpp
test/test_serial.cpp
test/publishers/test_nav_sat_fix_publisher.cpp
test/publishers/test_time_reference_publisher.cpp
test/publishers/test_gps_fix_publisher.cpp
test/publishers/test_custom_publishers.cpp
test/test_main.cpp
)
target_include_directories(${PROJECT_NAME}_test PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)
if((${FOUND_ROS2_DISTRO} STREQUAL "foxy") OR (${FOUND_ROS2_DISTRO} STREQUAL "galactic"))
rosidl_target_interfaces(${PROJECT_NAME}_test ${PROJECT_NAME} "rosidl_typesupport_cpp")
else()
rosidl_get_typesupport_target(cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp")
endif()
target_compile_features(${PROJECT_NAME}_test PRIVATE c_std_99 cxx_std_17) # Require C99 and C++17
target_link_libraries(${PROJECT_NAME}_test sbp serialport "${cpp_typesupport_target}")
ament_target_dependencies(${PROJECT_NAME}_test rclcpp sensor_msgs geometry_msgs nav_msgs gps_msgs tf2)
ament_export_dependencies(rosidl_default_runtime)
endif()
ament_package()