-
Notifications
You must be signed in to change notification settings - Fork 68
/
CMakeLists.txt
194 lines (171 loc) · 6.44 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
cmake_minimum_required(VERSION 3.5.0)
project(static_mapping)
#######################################################
### Compiler Options
#######################################################
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "-O2 -Wall \
-Wextra -fPIC \
-Wno-sign-compare \
-Wno-unused-parameter \
-Wno-unused-but-set-variable ")
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
### enable openmp or not ###
option(USE_OPENMP "Enable OpenMP?" ON) # set to OFF to disable
if(USE_OPENMP)
FIND_PACKAGE(OpenMP)
if(OPENMP_FOUND OR OpenMP_FOUND)
message(STATUS "OpenMP flags = ${OpenMP_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
else(OPENMP_FOUND OR OpenMP_FOUND)
message(STATUS "OpenMP not supported")
endif(OPENMP_FOUND OR OpenMP_FOUND)
endif(USE_OPENMP)
#######################################################
### Dependencies
#######################################################
include_directories("third_parties" "." "builder")
set(require_libs )
#### cuda ####
# option(USE_CUDA "Enable Cuda?" OFF)
# if(USE_CUDA)
# find_package(CUDA REQUIRED)
# include_directories(${CUDA_INCLUDE_DIRS})
# find_package(CudaUtils REQUIRED)
# include_directories(${CUDA_UTILS_INCLUDE_DIR})
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ICP_USE_CUDA_")
# set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "")
# set(CUDA_CHECKER_TARGET_FILE ${PROJECT_SOURCE_DIR}/tools/check_cuda)
# set(CUDA_CHECKER_SRC_FILE ${PROJECT_SOURCE_DIR}/tools/check_cuda.cu)
# execute_process(COMMAND nvcc -lcuda ${CUDA_CHECKER_SRC_FILE} -o ${CUDA_CHECKER_TARGET_FILE})
# execute_process(COMMAND ${CUDA_CHECKER_TARGET_FILE}
# RESULT_VARIABLE CUDA_RETURN_CODE
# OUTPUT_VARIABLE CUDA_ARCH)
# if(${CUDA_RETURN_CODE} EQUAL 0)
# set(CUDA_SUCCESS TRUE)
# else()
# set(CUDA_SUCCESS FALSE)
# endif()
# if (${CUDA_SUCCESS})
# message(STATUS "CUDA Architecture: ${CUDA_ARCH}")
# message(STATUS "CUDA Version: ${CUDA_VERSION_STRING}")
# message(STATUS "CUDA Path: ${CUDA_TOOLKIT_ROOT_DIR}")
# message(STATUS "CUDA Libararies: ${CUDA_LIBRARIES}")
# message(STATUS "CUDA Performance Primitives: ${CUDA_npp_LIBRARY}")
# endif()
# set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-O3;${CUDA_ARCH};--use_fast_math;-Xcompiler -fopenmp)
# add_subdirectory(registrators/cuda)
# list(APPEND require_libs registrators_cuda)
# endif(USE_CUDA)
#### pcl ####
find_package(PCL REQUIRED QUIET)
if(${PCL_VERSION} VERSION_GREATER "1.8.0" OR
${PCL_VERSION} VERSION_EQUAL "1.8.0")
message(STATUS "pcl version ${PCL_VERSION}")
## it is a trick to remove annoying warning in pcl-1.8 like this
## warning: ‘pcl::SAC_SAMPLE_SIZE’ ... [-Wdeprecated-declarations]
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem /usr/include/pcl-1.8")
endif()
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
link_libraries(${PCL_LIBRARIES})
find_package(Boost REQUIRED COMPONENTS
timer
thread)
list(APPEND require_libs Boost::timer Boost::thread)
add_subdirectory(tools)
#### gtsam ####
find_package(GTSAM REQUIRED)
include_directories(${GTSAM_INCLUDE_DIR})
list(APPEND require_libs gtsam)
#### png ####
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
message( STATUS "Found PNG in dir: ${PNG_INCLUDE_DIR}")
list(APPEND require_libs ${PNG_LIBRARY})
#### eigen ####
find_package(Eigen3 3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIR})
message( STATUS
"Found Eigen in dir: ${EIGEN3_INCLUDE_DIR} version: ${EIGEN3_VERSION}")
#### libpointmatcher ####
find_package(libpointmatcher REQUIRED)
include_directories(${libpointmatcher_INCLUDE_DIRS})
list(APPEND require_libs ${libpointmatcher_LIBRARIES})
#### tbb ####
find_package(TBB REQUIRED)
message(STATUS "TBB version: ${TBB_INTERFACE_VERSION}")
include_directories(${TBB_INCLUDE_DIRS})
list(APPEND require_libs ${TBB_LIBRARIES})
find_package(gflags REQUIRED)
list(APPEND require_libs ${GFLAGS_LIBRARIES})
find_package(Glog REQUIRED)
list(APPEND require_libs ${GLOG_LIBRARIES})
find_package(GeographicLib REQUIRED)
include_directories(${GeographicLib_INCLUDE_DIRS})
list(APPEND require_libs ${GeographicLib_LIBRARIES})
find_package(ImageMagick REQUIRED)
message(STATUS "Image Magick version : ${ImageMagick_VERSION_STRING}")
list(APPEND require_libs ${ImageMagick_LIBRARIES})
option(ENABLE_PROF "Enable profiling?" ON)
if(ENABLE_PROF)
message(STATUS "Enable simple profiling.")
add_definitions(-DENABLE_PROFILING)
set(PROF_LOG_DIR ".static_mapping_log")
add_definitions(-D_PROF_LOG_DIR_=".static_mapping_log")
execute_process (COMMAND bash -c "mkdir -p ~/${PROF_LOG_DIR}")
endif(ENABLE_PROF)
option(ENABLE_TEST "" OFF)
if(ENABLE_TEST)
find_package(Boost REQUIRED COMPONENTS unit_test_framework thread)
enable_testing()
add_custom_target(check COMMAND "ctest")
add_subdirectory(test)
endif(ENABLE_TEST)
option(ENABLE_EXAMPLE "" ON)
if(ENABLE_EXAMPLE)
message(SATUS "Enable building examples")
endif(ENABLE_EXAMPLE)
#######################################################
### Source files
#######################################################
add_subdirectory(common)
add_subdirectory(descriptor)
add_subdirectory(back_end)
add_subdirectory(registrators)
add_subdirectory(pre_processors)
add_subdirectory(builder)
add_subdirectory(third_parties)
#######################################################
### Target
#######################################################
# link_libraries(glog)
list(APPEND static_mapping_libs ${PROJECT_NAME}_builder
${PROJECT_NAME}_builder_data
${PROJECT_NAME}_backend
${PROJECT_NAME}_registrators
${PROJECT_NAME}_pre_processors
${PROJECT_NAME}_descriptor
${PROJECT_NAME}_common
pugixml)
message(STATUS "Local libs: ${static_mapping_libs}")
message(STATUS "Link libs: ${require_libs}")
message(STATUS "CXX FLAGS: ${CMAKE_CXX_FLAGS}")
if($ENV{ROS_DISTRO} STREQUAL "melodic")
message(STATUS "Using ROS melodic")
add_definitions(-DURDFDOM_HEADERS_HAS_SHARED_PTR_DEFS=1)
# Do stuff specific to Kinetic
elseif($ENV{ROS_DISTRO} STREQUAL "kinetic")
message(STATUS "Using ROS kinetic")
elseif($ENV{ROS_DISTRO} STREQUAL "noetic")
message(STATUS "Using ROS noetic")
add_definitions(-DURDFDOM_HEADERS_HAS_SHARED_PTR_DEFS=1)
else()
message(STATUS "Unknown ROS distro:")
message(STATUS $ENV{ROS_DISTRO})
endif()
#### ros cpp ####
add_subdirectory(ros_node)