forked from allenh1/rplidar_ros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
85 lines (68 loc) · 2.43 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
cmake_minimum_required(VERSION 3.9.5)
project(rplidar_ros2)
if (NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif ()
# Default to C++14
if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif ()
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -pedantic)
endif ()
# Create sdk library
add_library(rplidar_sdk SHARED
sdk/src/rplidar_driver.cpp
sdk/src/arch/linux/net_serial.cpp
sdk/src/arch/linux/net_socket.cpp
sdk/src/arch/linux/timer.cpp
sdk/src/hal/thread.cpp)
target_include_directories(rplidar_sdk
PUBLIC
sdk/include
sdk/src
PRIVATE
sdk/src/arch/linux
sdk/src/hal)
find_package(ament_cmake_auto REQUIRED)
find_package(ament_cmake_ros REQUIRED)
# Can't use ament_target_dependencies here, so need to manually
# create targets for ros2 dependencies
list(APPEND ros2_dependencies
rclcpp
sensor_msgs
std_srvs
rclcpp_components)
# create targets from ros 2 packages
foreach (dep IN LISTS ros2_dependencies)
find_package(${dep} REQUIRED)
add_library(${dep} INTERFACE)
target_link_libraries(${dep} INTERFACE ${${dep}_LIBRARIES})
target_include_directories(${dep} INTERFACE ${${dep}_INCLUDE_DIRS})
endforeach ()
ament_auto_find_build_dependencies(REQUIRED
rclcpp
sensor_msgs
std_srvs
rclcpp_components)
add_library(rplidar_node SHARED src/RPLidarNode.cpp)
target_link_libraries(rplidar_node rclcpp sensor_msgs std_srvs rclcpp_components rplidar_sdk)
ament_target_dependencies(rplidar_node rclcpp sensor_msgs std_srvs rclcpp_components)
target_include_directories(rplidar_node PUBLIC include)
# build direct ROS 1 port
ament_auto_add_executable(rplidar_client src/client.cpp)
target_link_libraries(rplidar_client rclcpp sensor_msgs std_srvs rclcpp_components)
ament_target_dependencies(rplidar_client rclcpp sensor_msgs std_srvs rclcpp_components)
# build composition node
ament_auto_add_executable(rplidar src/rplidar.cpp)
target_link_libraries(rplidar rplidar_node)
install(TARGETS rplidar_client rplidar rplidar_sdk
DESTINATION lib/${PROJECT_NAME})
install(DIRECTORY launch rviz config
DESTINATION share/${PROJECT_NAME})
# Install the shared library composition node
install(TARGETS rplidar_node
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
ament_auto_package()