forked from raulmur/ORB_SLAM2
-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
240 lines (208 loc) · 6.92 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
cmake_minimum_required(VERSION 2.8)
project(SD_SLAM)
option(USE_ANDROID "Android Cross Compilation" OFF)
set(USE_PANGOLIN ON)
set(DEBUG OFF)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release)
ENDIF()
MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})
if(USE_ANDROID)
MESSAGE(STATUS "Compiling for Android")
ADD_DEFINITIONS(-DANDROID)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -std=c++11")
set(EIGEN3_INCLUDE_DIR /usr/include/eigen3)
set(OPENCV_SDK /opt/OpenCV-android-sdk)
# Configure OpenCV
include_directories(${OPENCV_SDK}/sdk/native/jni/include)
add_library(lib_opencv SHARED IMPORTED)
set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${OPENCV_SDK}/sdk/native/libs/${ANDROID_ABI}/libopencv_java3.so)
else()
MESSAGE(STATUS "Compiling on Unix")
if(USE_PANGOLIN)
ADD_DEFINITIONS(-DPANGOLIN)
endif()
if(DEBUG)
ADD_DEFINITIONS(-g)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native -std=c++11")
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
find_package(OpenCV 3.0 QUIET)
if(NOT OpenCV_FOUND)
find_package(OpenCV 2.4.3 REQUIRED)
endif()
find_package(Eigen3 3.1.0 REQUIRED)
if(USE_PANGOLIN)
find_package(Pangolin REQUIRED)
endif()
endif()
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/src
${EIGEN3_INCLUDE_DIR}
)
if(USE_PANGOLIN)
include_directories(${Pangolin_INCLUDE_DIRS})
endif()
if(USE_ANDROID)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib/${ANDROID_ABI})
else()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
endif()
# Set SD-SLAM sourcefiles
LIST(APPEND SOURCEFILES
# SD-SLAM system
src/System.cc
src/Tracking.cc
src/ImageAlign.cc
src/LocalMapping.cc
src/LoopClosing.cc
src/ORBextractor.cc
src/ORBmatcher.cc
src/Converter.cc
src/MapPoint.cc
src/KeyFrame.cc
src/Map.cc
src/Optimizer.cc
src/PnPsolver.cc
src/Frame.cc
src/Sim3Solver.cc
src/Initializer.cc
src/Config.cc
src/PatternDetector.cc
# Sensors
src/sensors/EKF.cc
src/sensors/Sensor.cc
src/sensors/ConstantVelocity.cc
src/sensors/IMU.cc
# Extra
src/extra/utils.cc
)
if(NOT USE_ANDROID AND USE_PANGOLIN)
LIST(APPEND SOURCEFILES
# UI
src/ui/FrameDrawer.cc
src/ui/MapDrawer.cc
src/ui/Viewer.cc
src/ui/Plane.cc
)
endif()
# Set g2o sourcefiles
LIST(APPEND SOURCEFILES
# g2o types
src/extra/g2o/types/types_sba.h
src/extra/g2o/types/types_six_dof_expmap.h
src/extra/g2o/types/types_sba.cpp
src/extra/g2o/types/types_six_dof_expmap.cpp
src/extra/g2o/types/types_seven_dof_expmap.cpp
src/extra/g2o/types/types_seven_dof_expmap.h
src/extra/g2o/types/se3quat.h
src/extra/g2o/types/se3_ops.h
src/extra/g2o/types/se3_ops.hpp
# g2o core
src/extra/g2o/core/base_edge.h
src/extra/g2o/core/base_binary_edge.h
src/extra/g2o/core/hyper_graph_action.cpp
src/extra/g2o/core/base_binary_edge.hpp
src/extra/g2o/core/hyper_graph_action.h
src/extra/g2o/core/base_multi_edge.h
src/extra/g2o/core/hyper_graph.cpp
src/extra/g2o/core/base_multi_edge.hpp
src/extra/g2o/core/hyper_graph.h
src/extra/g2o/core/base_unary_edge.h
src/extra/g2o/core/linear_solver.h
src/extra/g2o/core/base_unary_edge.hpp
src/extra/g2o/core/marginal_covariance_cholesky.cpp
src/extra/g2o/core/base_vertex.h
src/extra/g2o/core/marginal_covariance_cholesky.h
src/extra/g2o/core/base_vertex.hpp
src/extra/g2o/core/matrix_structure.cpp
src/extra/g2o/core/batch_stats.cpp
src/extra/g2o/core/matrix_structure.h
src/extra/g2o/core/batch_stats.h
src/extra/g2o/core/openmp_mutex.h
src/extra/g2o/core/block_solver.h
src/extra/g2o/core/block_solver.hpp
src/extra/g2o/core/parameter.cpp
src/extra/g2o/core/parameter.h
src/extra/g2o/core/cache.cpp
src/extra/g2o/core/cache.h
src/extra/g2o/core/optimizable_graph.cpp
src/extra/g2o/core/optimizable_graph.h
src/extra/g2o/core/solver.cpp
src/extra/g2o/core/solver.h
src/extra/g2o/core/creators.h
src/extra/g2o/core/optimization_algorithm_factory.cpp
src/extra/g2o/core/estimate_propagator.cpp
src/extra/g2o/core/optimization_algorithm_factory.h
src/extra/g2o/core/estimate_propagator.h
src/extra/g2o/core/factory.cpp
src/extra/g2o/core/optimization_algorithm_property.h
src/extra/g2o/core/factory.h
src/extra/g2o/core/sparse_block_matrix.h
src/extra/g2o/core/sparse_optimizer.cpp
src/extra/g2o/core/sparse_block_matrix.hpp
src/extra/g2o/core/sparse_optimizer.h
src/extra/g2o/core/hyper_dijkstra.cpp
src/extra/g2o/core/hyper_dijkstra.h
src/extra/g2o/core/parameter_container.cpp
src/extra/g2o/core/parameter_container.h
src/extra/g2o/core/optimization_algorithm.cpp
src/extra/g2o/core/optimization_algorithm.h
src/extra/g2o/core/optimization_algorithm_with_hessian.cpp
src/extra/g2o/core/optimization_algorithm_with_hessian.h
src/extra/g2o/core/optimization_algorithm_levenberg.cpp
src/extra/g2o/core/optimization_algorithm_levenberg.h
src/extra/g2o/core/jacobian_workspace.cpp
src/extra/g2o/core/jacobian_workspace.h
src/extra/g2o/core/robust_kernel.cpp
src/extra/g2o/core/robust_kernel.h
src/extra/g2o/core/robust_kernel_factory.cpp
src/extra/g2o/core/robust_kernel_factory.h
src/extra/g2o/core/robust_kernel_impl.cpp
src/extra/g2o/core/robust_kernel_impl.h
# g2o stuff
src/extra/g2o/stuff/string_tools.h
src/extra/g2o/stuff/color_macros.h
src/extra/g2o/stuff/macros.h
src/extra/g2o/stuff/timeutil.cpp
src/extra/g2o/stuff/misc.h
src/extra/g2o/stuff/timeutil.h
src/extra/g2o/stuff/string_tools.cpp
src/extra/g2o/stuff/property.cpp
src/extra/g2o/stuff/property.h
)
add_library(${PROJECT_NAME} SHARED ${SOURCEFILES})
install(TARGETS ${PROJECT_NAME} DESTINATION lib)
install(DIRECTORY src/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
if(USE_ANDROID)
LIST(APPEND REQUIRED_LIBRARIES lib_opencv log)
else()
LIST(APPEND REQUIRED_LIBRARIES ${OpenCV_LIBS})
if(USE_PANGOLIN)
LIST(APPEND REQUIRED_LIBRARIES ${Pangolin_LIBRARIES})
endif()
endif()
target_link_libraries(${PROJECT_NAME} ${REQUIRED_LIBRARIES})
if(NOT USE_ANDROID)
# Build examples
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Monocular)
add_executable(monocular
Examples/Monocular/monocular.cc)
target_link_libraries(monocular ${PROJECT_NAME})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/RGB-D)
add_executable(rgbd
Examples/RGB-D/rgbd.cc)
target_link_libraries(rgbd ${PROJECT_NAME})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Fusion)
add_executable(monocular_imu
Examples/Fusion/monocular_imu.cc)
target_link_libraries(monocular_imu ${PROJECT_NAME})
# Calibration
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Calibration)
add_executable(calibration
Examples/Calibration/calibration.cc)
target_link_libraries(calibration ${PROJECT_NAME})
endif()