-
Notifications
You must be signed in to change notification settings - Fork 156
/
CMakeLists.txt
316 lines (266 loc) · 9.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
cmake_minimum_required(VERSION 3.4)
set(CMAKE_CXX_STANDARD 14)
message("Current Cmake version is : " ${CMAKE_VERSION})
project(lidar_odom CXX)
########################
# brief #
########################
#Main CMAKEList file for Lidar SLAM
#By Yue Pan @ETHZ
#Please follow the README and the install_dep_lib.sh to install the required libs
########################
# set compile options #
########################
#delete the cache to rebuild after changing the options
option(BUILD_WITH_CUDA "Build with CUDA for GPU computation" OFF)
option(BUILD_WITH_OPENCV "Build with OpenCV2 for Image related Processing" ON)
option(BUILD_WITH_LIBLAS "Build with LIBLAS for *.LAS point cloud data IO" OFF)
option(BUILD_WITH_HDF5 "Build with HDF5 for *.H5 point cloud data IO" ON)
option(BUILD_WITH_PROJ4 "Build with PROJ4 for Geo-coordinate Projection" OFF)
option(BUILD_WITH_CERES "Build with CERES for Non-linear Optimization" ON)
option(BUILD_WITH_G2O "Build with G2O for Non-linear Optimization" OFF)
option(BUILD_WITH_GTSAM "Build with GTSAM for Non-linear Optimization" OFF)
option(BUILD_WITH_SOPHUS "Build with SOPHUS for Lie-Group related Operations" OFF)
option(BUILD_WITH_TEASER "Build with TEASER++ for faster Global Registration (or RANSAC would be used)" ON)
option(BUILD_TOOLS "Build the point cloud format transformation tools" ON)
option(BUILD_PAIRWISE_REG "Build the pairwise registration test" ON)
option(BUILD_REPLAY "Build the Lidar SLAM replaying tool" ON)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{CXXFLAGS} -Wall -Wno-unused-variable -Werror=return-type")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb3")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -ggdb3 -DNDEBUG")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules")
########################
# find libs & include #
########################
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
find_package(Boost REQUIRED COMPONENTS thread)
find_package(OpenMP REQUIRED)
include_directories(${OpenMP_FOUND_INCLUDE_DIRS})
message("OpenMP [OK]:" ${OpenMP_FOUND_INCLUDE_DIRS})
#Eigen (involved in pcl, not needed)
find_package(Eigen3 REQUIRED NO_MODULE QUIET)
message("Eigen3 [OK]")
#PCL (neccessary)
#Boost, vtk, flann, eigen are involved in PCL
find_package(PCL REQUIRED QUIET)
include_directories(${PCL_INCLUDE_DIRS})
add_definitions(${PCL_DEFINITIONS})
list(REMOVE_ITEM PCL_LIBRARIES "vtkproj4")
message("PCL [OK]:" ${PCL_INCLUDE_DIRS})
#GFLAG (neccessary)
find_package(GFLAGS REQUIRED QUIET)
include_directories(${GFLAGS_INCLUDE_DIRS})
message("GFLAGS [OK]:" ${GFLAGS_INCLUDE_DIRS})
#GLOG (neccessary)
find_package(GLOG REQUIRED QUIET)
include_directories(${GLOG_INCLUDE_DIRS})
message("GLOG [OK]:" ${GLOG_INCLUDE_DIRS})
#CUDA (not used)
if (BUILD_WITH_CUDA)
find_package(CUDA 9.0 REQUIRED QUIET)
message("CUDA [OK]")
endif (BUILD_WITH_CUDA)
#HDF5 (optional: enable if you'd like to use H5 format IO )
if (BUILD_WITH_HDF5)
# DISABLE FIND_PACKAGE HERE BECAUSE WE MAY FIND THE WRONG HDF5 IN ANACONDA
# find_package(HDF5 REQUIRED QUIET)
# if (HDF5_FOUND)
# include_directories(${HDF5_INCLUDE_DIR})
# message("HDF5 [OK]")
# add_definitions(-DHDF5_ON)
# else ()
set(HDF5_INCLUDE_DIR /usr/include/hdf5/serial)
include_directories(${HDF5_INCLUDE_DIR})
message("HDF5 [OK]")
add_definitions(-DHDF5_ON)
# endif (HDF5_FOUND)
endif (BUILD_WITH_HDF5)
#LIBLAS (optional: enable if your'd like to use LAS format IO)
if (BUILD_WITH_LIBLAS)
find_package(LIBLAS REQUIRED QUIET)
include_directories(${LIBLAS_INCLUDE_DIR})
message("LIBLAS [OK]: " ${LIBLAS_INCLUDE_DIR})
add_definitions(-DLIBLAS_ON)
endif (BUILD_WITH_LIBLAS)
#PROJ4 (optional: enable if you'd like to do geo-projection)
if (BUILD_WITH_PROJ4)
find_package(PROJ4 REQUIRED QUIET)
if (PROJ4_FOUND)
include_directories(${PROJ4_INCLUDE_DIR})
message("PROJ4 [OK]")
add_definitions(-DPROJ4_ON)
else (PROJ4_FOUND)
set(PROJ4_ROOT /usr/local/include/proj)
include_directories(${PROJ4_INCLUDE_DIR})
message("PROJ4 [OK]")
add_definitions(-DPROJ4_ON)
endif (PROJ4_FOUND)
endif (BUILD_WITH_PROJ4)
#CERES (optional)
# glog and gflag are involved in ceres
if (BUILD_WITH_CERES)
find_package(Ceres REQUIRED QUIET)
include_directories(${CERES_INCLUDE_DIRS})
message("CERES [OK]:" ${CERES_INCLUDE_DIRS})
add_definitions(-DCERES_ON)
endif (BUILD_WITH_CERES)
#G2O (optional)
if (BUILD_WITH_G2O)
find_package(G2O REQUIRED QUIET)
message("G2O [OK]")
include_directories(${G2O_INCLUDE_DIR})
add_definitions(-DG2O_ON)
find_package(SuiteSparse REQUIRED QUIET)
if (SuiteSparse_FOUND)
message("SUITESPARSE_FOUND [OK]")
include_directories(${CSPARSE_INCLUDE_DIR})
else (SuiteSparse_FOUND)
include_directories(/usr/include/suitesparse)
endif (SuiteSparse_FOUND)
endif (BUILD_WITH_G2O)
#GTSAM (optional)
if (BUILD_WITH_GTSAM)
find_package(GTSAM REQUIRED QUIET)
message("GTSAM [OK]: " ${GTSAM_INCLUDE_DIR})
include_directories(${GTSAM_INCLUDE_DIR})
add_definitions(-DGTSAM_ON)
endif (BUILD_WITH_GTSAM)
# Sophus (optional, only used in baseline registration method fast vgicp)
if (BUILD_WITH_SOPHUS)
find_package(Sophus REQUIRED QUIET)
message("Sophus [OK]")
include_directories(${Sophus_INCLUDE_DIRS})
add_definitions(-DSOPHUS_ON)
endif (BUILD_WITH_SOPHUS)
#TEASER++
if (BUILD_WITH_TEASER)
find_package(teaserpp REQUIRED QUIET)
include_directories(${teaserpp_INCLUDE_DIRS})
message("Teaser++ [OK]")
add_definitions(-DTEASER_ON)
endif (BUILD_WITH_TEASER)
#OpenCV2
if (BUILD_WITH_OPENCV)
find_package(OpenCV REQUIRED QUIET)
include_directories(${OpenCV_INCLUDE_DIRS})
message("OPENCV [OK]: " ${OpenCV_INCLUDE_DIRS})
add_definitions(-DOPENCV_ON)
endif (BUILD_WITH_OPENCV)
# include folder
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/include/common)
include_directories(${PROJECT_SOURCE_DIR}/include/nav)
include_directories(${PROJECT_SOURCE_DIR}/include/pgo)
include_directories(${PROJECT_SOURCE_DIR}/include/baseline_reg)
include_directories(${PROJECT_SOURCE_DIR}/include/tools)
# source folder
set(SRC_LIST
include/baseline_reg/fast_vgicp.h
include/baseline_reg/fast_vgicp_impl.hpp
include/baseline_reg/fast_vgicp_utility.h
include/baseline_reg/fast_vgicp_voxel.h
include/baseline_reg/gicp_omp.h
include/baseline_reg/gicp_omp_impl.hpp
include/baseline_reg/ndt_omp.h
include/baseline_reg/ndt_omp_impl.hpp
include/baseline_reg/voxel_grid_covariance_omp.h
include/baseline_reg/voxel_grid_covariance_omp_impl.hpp
include/common/cfilter.hpp
include/common/cprocessing.hpp
include/common/cregistration.hpp
include/common/dataio.hpp
include/common/h5_io.hpp
include/common/map_viewer.h
include/common/map_viewer.hpp
include/common/pca.hpp
include/common/utility.hpp
include/nav/common_nav.h
include/nav/geo_tran.h
include/nav/odom_error_compute.h
include/pgo/build_pose_graph.h
include/pgo/graph_optimizer.h
include/pgo/map_manager.h
src/build_pose_graph.cpp
src/common_nav.cpp
src/graph_optimizer.cpp
src/map_manager.cpp
)
########################
# link libs #
########################
set(DEP_LIBS ${DEP_LIBS} Threads::Threads Boost::thread OpenMP::OpenMP_CXX)
set(DEP_LIBS ${DEP_LIBS} Eigen3::Eigen)
#link pcl lib (neccessary)
set(DEP_LIBS ${DEP_LIBS} ${PCL_LIBRARIES})
set(DEP_LIBS ${DEP_LIBS} ${GFLAGS_LIBRARIES})
set(DEP_LIBS ${DEP_LIBS} ${GLOG_LIBRARIES})
if (BUILD_WITH_HDF5)
#link libhdf5 lib (optional)
#link openmpi [needed by hdf5]
set(DEP_LIBS ${DEP_LIBS} mpi_cxx hdf5_serial libhdf5_cpp.so)
endif (BUILD_WITH_HDF5)
if (BUILD_WITH_PROJ4)
#link proj4
set(DEP_LIBS ${DEP_LIBS} ${PROJ4_LIBRARIES})
endif (BUILD_WITH_PROJ4)
if (BUILD_WITH_LIBLAS)
#link Liblas
set(DEP_LIBS ${DEP_LIBS} ${LIBLAS_LIBRARY} liblas.so.2.4.0)
endif (BUILD_WITH_LIBLAS)
if (BUILD_WITH_CERES)
#link ceres lib (optional)
set(DEP_LIBS ${DEP_LIBS} ${CERES_LIBRARIES})
endif (BUILD_WITH_CERES)
if (BUILD_WITH_SOPHUS)
#link sophus lib (optional)
set(DEP_LIBS ${DEP_LIBS} ${Sophus_LIBRARIES})
endif (BUILD_WITH_SOPHUS)
if (BUILD_WITH_G2O)
#manually link g2o_libs (optional)
set(DEP_LIBS ${DEP_LIBS} g2o_types_slam3d g2o_core g2o_stuff g2o_types_sba g2o_csparse_extension)
endif (BUILD_WITH_G2O)
if (BUILD_WITH_GTSAM)
#link gtsam lib (optional)
set(DEP_LIBS ${DEP_LIBS} ${GTSAM_LIBRARIES} gtsam)
endif (BUILD_WITH_GTSAM)
if (BUILD_WITH_TEASER)
#link teaser ++ (optional)
set(DEP_LIBS ${DEP_LIBS} teaserpp::teaser_registration teaserpp::teaser_io)
endif (BUILD_WITH_TEASER)
if (BUILD_WITH_OPENCV)
#link opencv (optional)
set(DEP_LIBS ${DEP_LIBS} ${OpenCV_LIBS})
endif (BUILD_WITH_OPENCV)
########################
# add executables #
########################
#test lidar odometry
add_executable(mulls_slam ${PROJECT_SOURCE_DIR}/test/mulls_slam.cpp ${SRC_LIST} ${REG_SRC_LIST})
target_link_libraries(mulls_slam ${DEP_LIBS})
if (BUILD_PAIRWISE_REG)
#test pairwise registration (both global and local) [not used]
add_executable(mulls_reg ${PROJECT_SOURCE_DIR}/test/mulls_reg.cpp ${SRC_LIST})
target_link_libraries(mulls_reg ${DEP_LIBS})
endif ()
if (BUILD_REPLAY)
#test slam recapping and checking [compile at the first time]
add_executable(replay_slam ${PROJECT_SOURCE_DIR}/test/vis_slam.cpp)
target_link_libraries(replay_slam ${DEP_LIBS})
endif ()
if (BUILD_TOOLS)
#format_transformer tool for kitti [compile at the first time]
add_executable(bin2pcd ${PROJECT_SOURCE_DIR}/test/format_transformer/kitti_bin2pcd.cpp)
target_link_libraries(bin2pcd ${DEP_LIBS})
#format_transformer tool for semantic kitti [compile at the first time]
add_executable(labelbin2pcd ${PROJECT_SOURCE_DIR}/test/format_transformer/semantic_kitti_label2pcd.cpp)
target_link_libraries(labelbin2pcd ${DEP_LIBS})
add_executable(txt2pcd ${PROJECT_SOURCE_DIR}/test/format_transformer/txt2pcd.cpp)
target_link_libraries(txt2pcd ${DEP_LIBS})
endif ()