forked from vectr-ucla/direct_lidar_inertial_odometry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
119 lines (102 loc) · 3.5 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
###########################################################
# #
# Copyright (c) #
# #
# The Verifiable & Control-Theoretic Robotics (VECTR) Lab #
# University of California, Los Angeles #
# #
# Authors: Kenny J. Chen, Ryan Nemiroff, Brett T. Lopez #
# Contact: {kennyjchen, ryguyn, btlopez}@ucla.edu #
# #
###########################################################
cmake_minimum_required(VERSION 3.12.4)
project(direct_lidar_inertial_odometry)
add_compile_options(-std=c++14)
set(CMAKE_BUILD_TYPE "Release")
find_package( PCL REQUIRED )
include_directories(${PCL_INCLUDE_DIRS})
add_definitions(${PCL_DEFINITIONS})
link_directories(${PCL_LIBRARY_DIRS})
find_package( Eigen3 REQUIRED )
include_directories(${EIGEN3_INCLUDE_DIR})
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)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
sensor_msgs
geometry_msgs
nav_msgs
pcl_ros
message_generation
)
add_service_files(
DIRECTORY srv
FILES
save_pcd.srv
)
generate_messages(
DEPENDENCIES
sensor_msgs
std_msgs
geometry_msgs
)
catkin_package(
CATKIN_DEPENDS
roscpp
std_msgs
sensor_msgs
geometry_msgs
pcl_ros
INCLUDE_DIRS
include
LIBRARIES
${PROJECT_NAME}
nano_gicp
nanoflann
)
include_directories(include)
include_directories(SYSTEM ${catkin_INCLUDE_DIRS})
# Not all machines have <cpuid.h> available
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
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()
# NanoFLANN
add_library(nanoflann STATIC
src/nano_gicp/nanoflann.cc
)
target_link_libraries(nanoflann ${PCL_LIBRARIES})
# 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)
# Odometry Node
add_executable(dlio_odom_node src/dlio/odom_node.cc src/dlio/odom.cc)
add_dependencies(dlio_odom_node ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
target_compile_options(dlio_odom_node PRIVATE ${OpenMP_FLAGS})
target_link_libraries(dlio_odom_node ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenMP_LIBS} Threads::Threads nano_gicp)
# Mapping Node
add_executable (dlio_map_node src/dlio/map_node.cc src/dlio/map.cc)
add_dependencies(dlio_map_node ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)
target_compile_options(dlio_map_node PRIVATE ${OpenMP_FLAGS})
target_link_libraries(dlio_map_node ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenMP_LIBS} Threads::Threads)
# Binaries
install( TARGETS dlio_odom_node dlio_map_node
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} )
install( DIRECTORY cfg launch
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} )