forked from ov2slam/ov2slam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·225 lines (191 loc) · 4.87 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
cmake_minimum_required(VERSION 3.22)
project(ov2slam)
if(POLICY CMP0022)
cmake_policy(SET CMP0022 NEW)
endif()
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -march=native -g")
########
# OpenCV
########
find_package(OpenCV REQUIRED)
#######
# NOTE!
#######
# Set to OFF if you did not compile OpenCV w. opencv_contrib
set(WITH_OPENCV_CONTRIB ON)
if (OpenCV_FOUND)
message(STATUS "Found OpenCV lib : ${OpenCV_VERSION} - ${OpenCV_INCLUDE_DIRS}")
if(WITH_OPENCV_CONTRIB)
message(STATUS "Going to use OpenCV contrib!")
add_definitions(-DOPENCV_CONTRIB)
endif()
endif (OpenCV_FOUND)
########
# Eigen3
########
find_package(Eigen3 REQUIRED)
if (Eigen3_FOUND)
message(STATUS "Found Eigen3 lib : ${Eigen3_VERSION} - ${EIGEN3_INCLUDE_DIRS}")
endif (Eigen3_FOUND)
########
# OpenGV
########
find_package(opengv)
if (opengv_FOUND)
message(STATUS "Found Opengv lib : ${opengv_INCLUDE_DIR} - ${opengv_DIR}")
add_definitions(-DUSE_OPENGV)
endif (opengv_FOUND)
#######
# Ceres
#######
find_package(Ceres REQUIRED)
if (Ceres_FOUND)
message(STATUS "Found Ceres lib : ${CERES_VERSION} - ${Ceres_DIR}")
endif (Ceres_FOUND)
########
# Sophus
########
find_package(Sophus REQUIRED)
if (Sophus_FOUND)
message(STATUS "Found Sophus lib : ${Sophus_VERSION} - ${Sophus_DIR}")
endif (Sophus_FOUND)
##########
# iBOW-LCD
##########
find_package(obindex2)
find_package(lcdetector)
set(WITH_IBOW_LCD OFF)
if (lcdetector_FOUND)
set(WITH_IBOW_LCD ON)
add_definitions(-DIBOW_LCD)
message(STATUS "iBoW-LCD found! Going to use Loop Closer! : ${lcdetector_VERSION} - ${lcdetector_DIR}")
endif (lcdetector_FOUND)
#######################
## Find ROS packages ##
#######################
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(PCL REQUIRED)
find_package(pcl_conversions REQUIRED)
find_package(backward_ros REQUIRED)
###########
## Build ##
###########
## Declare a C++ library
add_library(${PROJECT_NAME} SHARED
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
${OpenCV_INCLUDE_DIRS}
PRIVATE
${PROJECT_SOURCE_DIR}/include/
${PROJECT_SOURCE_DIR}/include/ceres_parametrization/
)
target_link_libraries(${PROJECT_NAME}
Eigen3::Eigen
Sophus::Sophus
Ceres::ceres
${OpenCV_LIBRARIES}
)
if (lcdetector_FOUND)
target_include_directories(
${PROJECT_NAME}
PRIVATE
${PROJECT_SOURCE_DIR}/thirdparty/obindex2/lib/include/
${PROJECT_SOURCE_DIR}/thirdparty/ibow_lcd/include/ # should be found by cmake
)
target_link_libraries(
${PROJECT_NAME}
lcdetector::lcdetector
)
endif (lcdetector_FOUND)
if (opengv_FOUND)
target_link_libraries(
${PROJECT_NAME}
opengv
)
endif (opengv_FOUND)
ament_target_dependencies(${PROJECT_NAME}
rclcpp
tf2
tf2_ros
visualization_msgs
pcl_conversions
PCL
std_msgs
cv_bridge
backward_ros
)
install(DIRECTORY include/ DESTINATION include/)
install(TARGETS ${PROJECT_NAME} DESTINATION lib/)
## 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)
ament_target_dependencies(${PROJECT_NAME}_node
rclcpp
image_transport
std_msgs
sensor_msgs
cv_bridge
)
## Add mandatory dependencies
target_include_directories(${PROJECT_NAME}_node
PRIVATE
${PROJECT_SOURCE_DIR}/include/
${PROJECT_SOURCE_DIR}/include/ceres_parametrization/
)
## Specify libraries to link a library or executable target against
target_link_libraries(${PROJECT_NAME}_node
${PROJECT_NAME}
)
if (lcdetector_FOUND)
target_include_directories(
${PROJECT_NAME}_node
PRIVATE
${PROJECT_SOURCE_DIR}/thirdparty/obindex2/lib/include/
${PROJECT_SOURCE_DIR}/thirdparty/ibow_lcd/include/ # should be found by cmake
)
target_link_libraries(
${PROJECT_NAME}_node
obindex2::obindex2
lcdetector::lcdetector
)
endif (lcdetector_FOUND)
install(TARGETS
${PROJECT_NAME}_node
DESTINATION lib/${PROJECT_NAME}
INCLUDES DESTINATION include
)
ament_package()