forked from ov2slam/ov2slam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·209 lines (171 loc) · 5.37 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
cmake_minimum_required(VERSION 2.8.3)
project(ov2slam)
if(POLICY CMP0022)
cmake_policy(SET CMP0022 NEW)
endif()
#######
# NOTE!
#######
# Set to OFF if you did not compile OpenCV w. opencv_contrib
set(WITH_OPENCV_CONTRIB ON)
if( ${CMAKE_VERSION} VERSION_LESS "3.8.2" )
set(CMAKE_CXX_STANDARD 14)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_BUILD_TYPE "Release")
#######
# NOTE!
#######
# You might need to remove the -march=native if you experience
# exceptions related to ceres or opengv.
# opengv comes natively with the march=native option while
# ceres requires to specify it at build time.
# If you experience exceptions you can either re-compile
# opengv and ov2slam without -march=native or re-compile
# ceres with it
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -march=native -g")
if(WITH_OPENCV_CONTRIB)
message("\nGoing to use OpenCV contrib! (WITH_OPENCV_CONTRIB is set to : ${WITH_OPENCV_CONTRIB}.
Set it to OFF is OpenCV was not compiled with the opencv_contrib modules)\n")
add_definitions(-DOPENCV_CONTRIB)
endif()
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED
COMPONENTS
roscpp
std_msgs
sensor_msgs
cv_bridge
image_transport
tf
pcl_ros
)
# iBOW-LCD
#
# First check if the related thridparty libs have been
# built. Only set the use of iBoW-LCD to true if built.
set(WITH_IBOW_LCD OFF)
if( EXISTS "${PROJECT_SOURCE_DIR}/Thirdparty/ibow_lcd/build/liblcdetector.so" )
add_definitions(-DIBOW_LCD)
set(WITH_IBOW_LCD ON)
message(STATUS "iBoW-LCD found! Going to use Loop Closer!")
else ( )
message(STATUS "iBoW-LCD NOT found! Loop Closer will not be enabled!")
endif ( )
## System dependencies are found with CMake's conventions
# OpenCV
find_package(OpenCV REQUIRED)
if(OpenCV_VERSION_MAJOR LESS 3)
message( FATAL_ERROR "OpenCV 3 or 4 is required! Current version : ${OpenCV_VERSION}" )
endif()
if(OpenCV_VERSION VERSION_LESS "3.3.0")
message("ENABLE Internal ParallelLoopBodyLambdaWrapper Class definition (OpenCV < 3.3.0)")
add_definitions(-DOPENCV_LAMBDA_MISSING)
endif()
#Eigen3
find_package(Eigen3 3.3.0 REQUIRED NO_MODULE)
if (Eigen3_FOUND)
message(STATUS "Found Eigen3 lib : ${Eigen3_VERSION} - ${EIGEN3_INCLUDE_DIRS}")
endif (Eigen3_FOUND)
# add_definitions(-DEIGEN_DONT_VECTORIZE -DEIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
#OpenGV
find_package(opengv QUIET)
# Bug include CMake 1.17
get_target_property(opengv_INCLUDE_DIR opengv INTERFACE_INCLUDE_DIRECTORIES)
if (opengv_FOUND)
message(STATUS "Found Opengv lib : ${opengv_INCLUDE_DIR} - ${opengv_DIR}")
add_definitions(-DUSE_OPENGV)
endif (opengv_FOUND)
# Ceres
find_package(Ceres NO_DEFAULT_PATH PATHS ${PROJECT_SOURCE_DIR}/Thirdparty/ceres-solver/install/)
find_package(Ceres REQUIRED)
if (Ceres_FOUND)
message(STATUS "Found Ceres lib : ${CERES_VERSION} - ${Ceres_DIR}")
endif (Ceres_FOUND)
#Sophus
# First search for a custom build of Sophus within this project
find_package(Sophus NO_DEFAULT_PATH PATHS ${PROJECT_SOURCE_DIR}/Thirdparty/Sophus/build/)
find_package(Sophus REQUIRED)
if (Sophus_FOUND)
message(STATUS "Found Sophus lib : ${Sophus_VERSION} - ${Sophus_DIR}")
endif (Sophus_FOUND)
catkin_package()
###########
## Build ##
###########
## add backward
add_subdirectory(Thirdparty/backward-cpp)
## Declare a C++ library
add_library(${PROJECT_NAME}
src/ov2slam.cpp
src/camera_visualizer.cpp
src/visual_front_end.cpp
src/frame.cpp
src/slam_params.cpp
src/camera_calibration.cpp
src/feature_extractor.cpp
src/feature_tracker.cpp
src/map_manager.cpp
src/map_point.cpp
src/mapper.cpp
src/multi_view_geometry.cpp
src/ceres_parametrization.cpp
src/optimizer.cpp
src/estimator.cpp
src/loop_closer.cpp
)
# Add mandatory dependencies
target_include_directories(${PROJECT_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/include
${catkin_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/include/ceres_parametrization
)
target_link_libraries(${PROJECT_NAME}
PUBLIC
${catkin_LIBRARIES}
Eigen3::Eigen
Sophus::Sophus
PRIVATE
${OpenCV_LIBS}
Ceres::ceres
)
# Add optional dependencies if they are found
if (WITH_IBOW_LCD)
target_include_directories(
${PROJECT_NAME}
PUBLIC
${PROJECT_SOURCE_DIR}/Thirdparty/obindex2/lib/include/
${PROJECT_SOURCE_DIR}/Thirdparty/ibow_lcd/include/
)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
${PROJECT_SOURCE_DIR}/Thirdparty/ibow_lcd/build/liblcdetector.so
)
endif (WITH_IBOW_LCD)
if (opengv_FOUND)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
opengv
)
endif (opengv_FOUND)
## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
add_executable(${PROJECT_NAME}_node src/ov2slam_node.cpp ${BACKWARD_ENABLE})
add_backward(${PROJECT_NAME}_node)
## Specify libraries to link a library or executable target against
target_link_libraries(
${PROJECT_NAME}_node
PRIVATE
${PROJECT_NAME}
)