-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
167 lines (144 loc) · 4.99 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
164
165
166
167
###########################################################
# #
# 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 #
# Mpdified by piluohong SCAU #
###########################################################
cmake_minimum_required(VERSION 3.12.4)
project(hc_lio)
# add_compile_options(-std=c++14)
set(CMAKE_CXX_FLAGS "-std=c++14")
set(CMAKE_BUILD_TYPE "Release")
# set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g -pthread")
add_definitions(-w)
add_definitions(-DROOT_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\")
set(PCL_DIR "/home/h/ku/pcl-1.12.0/share/pcl-1.12") #18.04
find_package(PCL 1.12.0 REQUIRED QUIET)
find_package(GTSAM REQUIRED QUIET)
find_package(Eigen3 REQUIRED QUIET)
find_package(octomap REQUIRED QUIET)
add_definitions(-DOCTOMAP_NODEBUGOUT)
find_package(PythonLibs 3.6)
# find_package (GeographicLib REQUIRED)
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
octomap_ros
octomap_msgs
livox_ros_driver2
visualization_msgs
tf2_ros
)
# include_directories (${GeographicLib_INCLUDE_DIRS})
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
nav_msgs
visualization_msgs
livox_ros_driver2
tf2_ros
INCLUDE_DIRS
include
DEPENDS PCL GTSAM OCTOMAP
LIBRARIES
${PROJECT_NAME}
nano_gicp
nanoflann
fast_gicp
)
include_directories(
include
${catkin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
${GTSAM_INCLUDE_DIRS}
#${GEOGRAPHICLIB_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS})
link_directories(
include
${catkin_LIBRARIES}
${PCL_LIBRARY_DIRS}
${GTSAM_LIBRARY_DIRS}
#${GEOGRAPHICLIB_LIBRARY_DIRS}
${PYTHON_LIBRARY_DIRS})
# 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})
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)
add_library(fast_gicp STATIC
src/fvgicp/fast_gicp.cpp
src/fvgicp/dwvgicp.cpp
src/fvgicp/lsq_registration.cpp
include/fvgicp/dwvgicp.hpp
include/fvgicp/fast_gicp.hpp
include/fvgicp/lsq_registration.hpp
include/fvgicp/dwvgicp_impl.hpp
)
target_link_libraries(fast_gicp ${PCL_LIBRARIES} ${OpenMP_LIBS})
# Odometry Node
add_executable(dlio_odom_node src/odom/odom_node.cc include/ikd-Tree/ikd_Tree.cpp src/odom/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} ${GTSAM_LIBRARIES} ${PCL_LIBRARIES} ${OpenMP_CXX_FLAGS} ${GeographicLib_LIBRARIES} ${OCTOMAP_LIBRARIES}
${PYTHON_LIBRARIES} Threads::Threads nano_gicp fast_gicp gtsam)
#message(${OpenMP_LIBS})
# # Mapping Node
add_executable (dlio_map_node src/odom/map_node.cc src/odom/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_CXX_FLAGS} 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} )