forked from Livox-SDK/livox_ros_driver2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
122 lines (101 loc) · 3.06 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
# Copyright(c) 2020 livoxtech limited.
cmake_minimum_required(VERSION 3.5)
project(livox_ros_driver2)
# Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()
list(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/cmake/modules")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
endif()
# Printf version info
include(cmake/version.cmake)
project(${PROJECT_NAME} VERSION ${LIVOX_ROS_DRIVER2_VERSION} LANGUAGES CXX)
message(STATUS "${PROJECT_NAME} version: ${LIVOX_ROS_DRIVER2_VERSION}")
#---------------------------------------------------------------------------------------
# Add ROS Version MACRO
#---------------------------------------------------------------------------------------
add_definitions(-DBUILDING_ROS2)
# find dependencies
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
find_package(PCL REQUIRED)
find_package(std_msgs REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(livox_sdk2 REQUIRED)
# check apr
find_package(PkgConfig)
pkg_check_modules(APR apr-1)
if (APR_FOUND)
message(${APR_INCLUDE_DIRS})
message(${APR_LIBRARIES})
endif (APR_FOUND)
# generate custom msg headers
set(LIVOX_INTERFACES livox_interfaces2)
rosidl_generate_interfaces(${LIVOX_INTERFACES}
"msg/CustomPoint.msg"
"msg/CustomMsg.msg"
DEPENDENCIES builtin_interfaces std_msgs
LIBRARY_NAME ${PROJECT_NAME}
)
## PCL library
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
# livox ros2 driver target
ament_auto_add_library(${PROJECT_NAME} SHARED
src/livox_ros_driver2.cpp
src/lddc.cpp
src/driver_node.cpp
src/lds.cpp
src/lds_lidar.cpp
src/comm/comm.cpp
src/comm/ldq.cpp
src/comm/semaphore.cpp
src/comm/lidar_imu_data_queue.cpp
src/comm/cache_index.cpp
src/comm/pub_handler.cpp
src/parse_cfg_file/parse_cfg_file.cpp
src/parse_cfg_file/parse_livox_lidar_cfg.cpp
src/call_back/lidar_common_callback.cpp
src/call_back/livox_lidar_callback.cpp
)
# get include directories of custom msg headers
rosidl_get_typesupport_target(cpp_typesupport_target
${LIVOX_INTERFACES} "rosidl_typesupport_cpp")
target_link_libraries(${PROJECT_NAME} "${cpp_typesupport_target}")
# include file direcotry
target_include_directories(${PROJECT_NAME} PUBLIC
${PCL_INCLUDE_DIRS}
${APR_INCLUDE_DIRS}
${livox_sdk2_INCLUDE_DIRS}
${LIVOX_INTERFACES_INCLUDE_DIRECTORIES} # for custom msgs
3rdparty
src
)
# link libraries
target_link_libraries(${PROJECT_NAME}
${livox_sdk2_LIBRARIES}
${LIVOX_INTERFACE_TARGET} # for custom msgs
${PPT_LIBRARY}
${Boost_LIBRARY}
${PCL_LIBRARIES}
${APR_LIBRARIES}
)
rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "livox_ros::DriverNode"
EXECUTABLE ${PROJECT_NAME}_node
)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()
ament_auto_package(INSTALL_TO_SHARE
config
launch
)