forked from NamDinhRobotics/proSLAM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
213 lines (173 loc) · 6.96 KB
/
CMakeLists.txt
File metadata and controls
213 lines (173 loc) · 6.96 KB
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
cmake_minimum_required(VERSION 2.8.3)
project(srrg_proslam)
find_package(srrg_cmake_modules REQUIRED)
set(CMAKE_MODULE_PATH ${srrg_cmake_modules_INCLUDE_DIRS})
#ds determine build type, default build type: release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE)
endif()
message("${PROJECT_NAME}|build type: '${CMAKE_BUILD_TYPE}'")
#ds flags for release build
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -march=native -Wall -pedantic -Ofast -DNDEBUG")
message("${PROJECT_NAME}|adding flags for '${CMAKE_BUILD_TYPE}': '-std=c++11 -march=native -Wall -pedantic -Ofast -DNDEBUG'")
#ds flags for other build(s) (e.g. debug)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -march=native -Wall -pedantic -O0 -g -fstack-check")
message("${PROJECT_NAME}|adding flags for '${CMAKE_BUILD_TYPE}': '-std=c++11 -march=native -Wall -pedantic -O0 -g -fstack-check'")
endif()
#ds enable ARM flags if applicable
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -funsafe-math-optimizations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -funsafe-math-optimizations")
message("${PROJECT_NAME}|enabling ARM neon optimizations")
endif()
#ds specify target binary descriptor bit size (256 if not defined)
add_definitions(-DSRRG_PROSLAM_DESCRIPTOR_SIZE_BITS=256)
#ds specify target log level: 0 ERROR, 1 WARNING, 2 INFO, 3 DEBUG (defaults to 2 if not defined)
add_definitions(-DSRRG_PROSLAM_LOG_LEVEL=2)
#ds enable descriptor merging in HBST (and other SRRG components) - careful for collisions with landmark merging!
add_definitions(-DSRRG_MERGE_DESCRIPTORS)
#ds load Eigen library
find_package(Eigen3 REQUIRED)
message("${PROJECT_NAME}|using Eigen version: '3' (${EIGEN3_INCLUDE_DIR})")
#ds enable Eigen for HBST
add_definitions(-DSRRG_HBST_HAS_EIGEN)
#ds check if a supported ros version is installed to determine which packages we include
set(SRRG_PROSLAM_HAS_ROS false)
if("$ENV{ROS_DISTRO}" STREQUAL "kinetic" OR "$ENV{ROS_DISTRO}" STREQUAL "indigo" OR "$ENV{ROS_DISTRO}" STREQUAL "melodic")
#ds ROS support enabled
message("${PROJECT_NAME}|using ROS version: '$ENV{ROS_DISTRO}' (building nodes)")
set(SRRG_PROSLAM_HAS_ROS true)
find_package(catkin REQUIRED COMPONENTS
srrg_core
srrg_gl_helpers
srrg_core_viewers
srrg_hbst
roscpp
sensor_msgs
cv_bridge
nav_msgs
message_filters
image_geometry
)
#ds switch to ROS opencv libraries without calling find_package to avoid conflicts with other existing OpenCV installations
set(OpenCV_DIR "ROS")
set(OpenCV_LIBS ${catkin_LIBRARIES})
message("${PROJECT_NAME}|using ROS OpenCV version: '${OpenCV_VERSION}' (${OpenCV_DIR})")
add_definitions(-DSRRG_HBST_HAS_OPENCV)
else()
#ds build proslam without ROS components
find_package(catkin REQUIRED COMPONENTS
srrg_core
srrg_gl_helpers
srrg_core_viewers
srrg_hbst
)
#ds OpenCV - OpenCV_DIR might be overwritten by user
find_package(OpenCV REQUIRED)
message("${PROJECT_NAME}|using OpenCV version: '${OpenCV_VERSION}' (${OpenCV_DIR})")
add_definitions(-DSRRG_HBST_HAS_OPENCV)
endif()
#ds check for OpenCV contrib library (optional)
string(FIND "${OpenCV_LIBS}" "xfeatures2d" FOUND_OPENCV_CONTRIB)
if(NOT ${FOUND_OPENCV_CONTRIB} EQUAL -1)
message("${PROJECT_NAME}|found xfeatures2d library, building contributed OpenCV components")
add_definitions(-DSRRG_PROSLAM_HAS_OPENCV_CONTRIB)
else()
message("${PROJECT_NAME}|xfeatures2d library not found, using ORB instead of BRIEF descriptors")
endif()
#ds load QGLViewer library
find_package(QGLViewer REQUIRED)
#ds attempt to locate a g2o package through cmake modules
find_package(G2O QUIET)
#ds set ownership model for g2o TODO retrieve this information from g2o (current g2o requires cmake 3+)
if (${CMAKE_MAJOR_VERSION} GREATER 2)
#ds (comment this line if you're using an older g2o version but cmake 3+)
add_definitions(-DSRRG_PROSLAM_G2O_HAS_NEW_OWNERSHIP_MODEL)
message("${PROJECT_NAME}|found CMake 3+: assuming new g2o ownership model")
else()
#ds old g2o ownership model is used
message("${PROJECT_NAME}|found CMake 2: assuming old g2o ownership model")
endif()
#ds check if a custom g2o library is installed
set(SRRG_PROSLAM_HAS_OWN_G2O false)
#ds if theres no SRRG g2o installation
if("${G2O_SRRG_DIR}" STREQUAL "")
#ds check if theres also no srrg g2o installation
if("$ENV{G2O_ROOT}" STREQUAL "")
#ds no custom g2o installation found, fallback to catkin g2o
message("${PROJECT_NAME}|using catkin g2o")
else()
#ds use custom g2o
message("${PROJECT_NAME}|using custom g2o: '$ENV{G2O_ROOT}'")
set(SRRG_PROSLAM_HAS_OWN_G2O true)
endif()
else()
#ds use srrg g2o
message("${PROJECT_NAME}|using SRRG g2o: '${G2O_SRRG_DIR}'")
set(SRRG_PROSLAM_HAS_OWN_G2O true)
endif()
#ds if a custom g2o package was found
if(SRRG_PROSLAM_HAS_OWN_G2O)
#ds add it to our variables
set(g2o_INCLUDE_DIRS ${G2O_INCLUDE_DIR})
set(g2o_LIBRARIES ${G2O_SOLVER_CSPARSE_EXTENSION} ${G2O_TYPES_SLAM3D} ${G2O_CORE_LIBRARY} ${G2O_STUFF_LIBRARY})
else()
#ds attempt to find a catkin g2o
find_package(g2o_catkin REQUIRED)
#ds add it to our variables
set(g2o_INCLUDE_DIRS ${g2o_catkin_INCLUDE_DIRS})
set(g2o_LIBRARIES ${g2o_catkin_LIBRARIES})
endif()
#ds load suite sparse for pose graph optimization
find_package(SuiteSparse REQUIRED)
#ds specify additional locations of header files
#ds treating them as system includes to surpress warnings (!)
include_directories(SYSTEM
${EIGEN3_INCLUDE_DIR}
${g2o_INCLUDE_DIRS}
${CSPARSE_INCLUDE_DIR}
${OpenCV_INCLUDE_DIRS}
${QGLVIEWER_INCLUDE_DIR}
${catkin_INCLUDE_DIRS}
${SRRG_QT_INCLUDE_DIRS}
src
)
#ds help the catkin tool on 16.04 (cmake seems unable to find single libraries, although catkin claims the link_directories call is not required)
#ds in order to avoid linking against the catkin_LIBRARIES bulk everytime enable this so one can select single libraries
link_directories(${catkin_LIBRARY_DIRS})
#ds set up catkin package (exported components)
catkin_package(
INCLUDE_DIRS
${EIGEN3_INCLUDE_DIR}
${g2o_INCLUDE_DIRS}
${CSPARSE_INCLUDE_DIR}
${OpenCV_INCLUDE_DIRS}
${QGLVIEWER_INCLUDE_DIR}
${catkin_INCLUDE_DIRS}
${SRRG_QT_INCLUDE_DIRS}
src
LIBRARIES
#ds package libraries
srrg_proslam_aligners_library
srrg_proslam_framepoint_generation_library
srrg_proslam_map_optimization_library
srrg_proslam_position_tracking_library
srrg_proslam_relocalization_library
srrg_proslam_types_library
srrg_proslam_visualization_library
srrg_proslam_slam_assembly_library
#ds export the used libraries in this project (consistency for integration)
${g2o_LIBRARIES}
${CSPARSE_LIBRARY}
${OpenCV_LIBS}
yaml-cpp
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${QGLVIEWER_LIBRARY}
${SRRG_QT_LIBRARIES}
)
#ds set sources
add_subdirectory(src)
add_subdirectory(executables)