forked from Soldann/MORB_SLAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
177 lines (161 loc) · 5.23 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
#catkin_lint: ignore subproject
cmake_minimum_required(VERSION 3.16.3)
project(
morb_slam_ros
VERSION 1.0
LANGUAGES CXX)
# Release by default Turn on Debug with "-DCMAKE_BUILD_TYPE=Debug"
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
find_package(
catkin REQUIRED
COMPONENTS roscpp
rospy
std_msgs
cv_bridge
image_transport
tf
sensor_msgs
message_generation)
find_package(OpenCV 4.2 REQUIRED)
find_package(Eigen3 3.1.0 REQUIRED)
catkin_package(
INCLUDE_DIRS
include
Thirdparty/DBoW2/include
Thirdparty/g2o
Thirdparty/Sophus
LIBRARIES
${PROJECT_NAME}
DBoW2
g2o
CATKIN_DEPENDS
roscpp
rospy
std_msgs
cv_bridge
image_transport
tf
sensor_msgs
message_runtime
DEPENDS
EIGEN3
OpenCV)
add_subdirectory(Thirdparty/g2o)
add_subdirectory(Thirdparty/DBoW2)
add_subdirectory(Thirdparty/Sophus)
add_library(
${PROJECT_NAME}
src/Atlas.cc
src/CameraModels/KannalaBrandt8.cpp
src/CameraModels/Pinhole.cpp
src/Config.cc
src/Converter.cc
src/Frame.cc
src/G2oTypes.cc
src/GeometricTools.cc
src/ImuTypes.cc
src/KeyFrame.cc
src/KeyFrameDatabase.cc
src/LocalMapping.cc
src/LoopClosing.cc
src/Map.cc
src/MapPoint.cc
src/MLPnPsolver.cpp
src/OptimizableTypes.cpp
src/Optimizer.cc
src/ORBextractor.cc
src/ORBmatcher.cc
src/Settings.cc
src/Sim3Solver.cc
src/System.cc
src/Tracking.cc
src/TwoViewReconstruction.cc)
target_include_directories(
${PROJECT_NAME}
PUBLIC $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Thirdparty/DBoW2/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Thirdparty/Sophus>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Thirdparty/g2o>
PRIVATE $<BUILD_INTERFACE:${EIGEN3_INCLUDE_DIRS}> ${catkin_INCLUDE_DIRS})
target_link_libraries(
${PROJECT_NAME}
${OpenCV_LIBS}
${EIGEN3_LIBS}
DBoW2
g2o
-lboost_serialization
-lcrypto)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
if(CMAKE_BUILD_TYPE EQUAL "Release" OR CMAKE_BUILD_TYPE EQUAL "RelWithDebInfo")
target_compile_options(
orb_slam3
PRIVATE -O3
PUBLIC -march=native)
endif()
add_custom_target(vocabulary ALL)
add_custom_command(
TARGET vocabulary
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E tar xf ${PROJECT_SOURCE_DIR}/Vocabulary/ORBvoc.txt.tar.gz
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Vocabulary/
DEPENDS ${PROJECT_SOURCE_DIR}/Vocabulary/ORBvoc.txt.tar.gz
COMMENT "Unpacking ORBvoc.txt.tar.gz"
VERBATIM)
add_dependencies(${PROJECT_NAME} vocabulary)
# Build ROS nodes
set(LIBS
${EIGEN3_LIBS}
${catkin_LIBRARIES}
${OpenCV_LIBS}
${PROJECT_NAME})
# mono node
add_executable(${PROJECT_NAME}_mono src/ROS/mono_node.cc src/ROS/common.cc)
target_link_libraries(${PROJECT_NAME}_mono ${LIBS})
target_include_directories(
${PROJECT_NAME}_mono
PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE $<BUILD_INTERFACE:${EIGEN3_INCLUDE_DIRS}> ${catkin_INCLUDE_DIRS})
# mono-inertial node
add_executable(${PROJECT_NAME}_mono_inertial src/ROS/mono_inertial_node.cc src/ROS/common.cc)
target_link_libraries(${PROJECT_NAME}_mono_inertial ${LIBS})
target_include_directories(
${PROJECT_NAME}_mono_inertial
PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE $<BUILD_INTERFACE:${EIGEN3_INCLUDE_DIRS}> ${catkin_INCLUDE_DIRS})
# stereo node
add_executable(${PROJECT_NAME}_stereo src/ROS/stereo_node.cc src/ROS/common.cc)
target_link_libraries(${PROJECT_NAME}_stereo ${LIBS})
target_include_directories(
${PROJECT_NAME}_stereo
PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE $<BUILD_INTERFACE:${EIGEN3_INCLUDE_DIRS}> ${catkin_INCLUDE_DIRS})
# stereo-inertial node
add_executable(${PROJECT_NAME}_stereo_inertial src/ROS/stereo_inertial_node.cc src/ROS/common.cc)
target_link_libraries(${PROJECT_NAME}_stereo_inertial ${LIBS})
target_include_directories(
${PROJECT_NAME}_stereo_inertial
PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE $<BUILD_INTERFACE:${EIGEN3_INCLUDE_DIRS}> ${catkin_INCLUDE_DIRS})
# RGB-D node
add_executable(${PROJECT_NAME}_rgbd src/ROS/rgbd_node.cc src/ROS/common.cc)
target_link_libraries(${PROJECT_NAME}_rgbd ${LIBS})
target_include_directories(
${PROJECT_NAME}_rgbd
PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE $<BUILD_INTERFACE:${EIGEN3_INCLUDE_DIRS}> ${catkin_INCLUDE_DIRS})
# Install targets
install(
TARGETS ${PROJECT_NAME}
${PROJECT_NAME}_mono
${PROJECT_NAME}_mono_inertial
${PROJECT_NAME}_stereo
${PROJECT_NAME}_stereo_inertial
${PROJECT_NAME}_rgbd
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/ Thirdparty/Sophus/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
install(FILES ${PROJECT_SOURCE_DIR}/Vocabulary/ORBvoc.txt DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/Vocabulary)