forked from Cardinal-Space-Mining/direct_lidar_odometry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
115 lines (88 loc) · 3.61 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
#############################################################
# #
# Copyright (c) 2022, University of California, Los Angeles #
# #
# Authors: Kenny J. Chen, Brett T. Lopez #
# Contact: [email protected], [email protected] #
# #
#############################################################
cmake_minimum_required(VERSION 3.12.4)
project(direct_lidar_odometry)
find_package( PCL REQUIRED )
find_package(rosidl_default_generators REQUIRED)
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(pcl_ros REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(Threads REQUIRED)
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
rosidl_generate_interfaces(
${PROJECT_NAME}
srv/SavePCD.srv
DEPENDENCIES
)
rosidl_get_typesupport_target(cpp_typesupport_target
${PROJECT_NAME} rosidl_typesupport_cpp)
include_directories(${PCL_INCLUDE_DIRS})
# add_definitions(${PCL_DEFINITIONS})
include_directories(${EIGEN3_INCLUDE_DIR})
include_directories(include)
include_directories(SYSTEM)
# NanoFLANN
add_library(nanoflann STATIC
src/nano_gicp/nanoflann.cc
)
target_link_libraries(nanoflann ${PCL_LIBRARIES})
ament_target_dependencies(nanoflann)
# NanoGICP
add_library(nano_gicp STATIC
src/nano_gicp/lsq_registration.cc
src/nano_gicp/nano_gicp.cc
)
target_link_libraries(nano_gicp ${PCL_LIBRARIES} ${OpenMP_LIBS} nanoflann)
ament_target_dependencies(nano_gicp)
# Odometry Node
add_executable(dlo_odom_node src/dlo/odom_node.cc src/dlo/odom.cc)
target_link_libraries(dlo_odom_node ${PCL_LIBRARIES} ${OpenMP_LIBS} Threads::Threads nano_gicp)
ament_target_dependencies(dlo_odom_node "tf2_ros" "pcl_ros" "nav_msgs" "pcl_conversions" "rclcpp" "sensor_msgs" "geometry_msgs")
# Mapping Node
add_executable (dlo_map_node src/dlo/map_node.cc src/dlo/map.cc)
target_link_libraries(dlo_map_node ${PCL_LIBRARIES} ${cpp_typesupport_target})
ament_target_dependencies(dlo_map_node "tf2_ros" "pcl_ros" "pcl_conversions" "rclcpp")
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME} nano_gicp nanoflann)
ament_export_dependencies(rclcpp std_msgs sensor_msgs geometry_msgs pcl_ros)
ament_package()
# Binaries
install( TARGETS dlo_odom_node dlo_map_node
DESTINATION lib/${PROJECT_NAME}
)
install( DIRECTORY cfg launch
DESTINATION share/${PROJECT_NAME}
)
add_compile_options(-std=c++14)
link_directories(${PCL_LIBRARY_DIRS})
include(FindOpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else(OPENMP_FOUND)
message("ERROR: OpenMP could not be found.")
endif(OPENMP_FOUND)
file(WRITE ${CMAKE_BINARY_DIR}/test_cpuid.cpp "#include <cpuid.h>")
try_compile(HAS_CPUID ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test_cpuid.cpp)
file(REMOVE ${CMAKE_BINARY_DIR}/test_cpuid.cpp)
if(HAS_CPUID)
add_compile_definitions(HAS_CPUID)
endif()
target_compile_options(dlo_odom_node PRIVATE ${OpenMP_FLAGS})
target_compile_options(dlo_map_node PRIVATE ${OpenMP_FLAGS})