-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
executable file
·259 lines (210 loc) · 10.6 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# ----------------------------------------------------------------------------
# Basic Configuration
# ----------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
Project (GlobalFusion)
#------------------------------------------------------
# Compiler
#------------------------------------------------------
add_definitions(-std=c++14)
#------------------------------------------------------
# Build type
#------------------------------------------------------
#IF(NOT CMAKE_BUILD_TYPE )
# #SET( CMAKE_BUILD_TYPE "Release" )
# SET( CMAKE_BUILD_TYPE "Debug" )
#ENDIF()
SET( CMAKE_BUILD_TYPE "Debug" )
#SET( CMAKE_BUILD_TYPE "Release" )
#------------------------------------------------------
# Lib Names and Dirs
#------------------------------------------------------
#
OPTION(BUILD_UTILS "Set to OFF to not build utils" ON)
OPTION(USE_CONTRIB "Set to ON if contrib are installed" OFF)
OPTION(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
# ----------------------------------------------------------------------------
# Find Dependencies
# ----------------------------------------------------------------------------
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake-modules)
find_package(OpenCV 3.4.5 EXACT REQUIRED) # same with ros.
#set(GTSAM_DIR "/home/gi/Downloads/gtsam")
find_package(GTSAM REQUIRED)
find_package(Eigen3 3.1.0 REQUIRED)
#find_package(catkin REQUIRED COMPONENTS
# cv_bridge
# image_transport
# roscpp
# sensor_msgs
# geometry_msgs
# roseus
# visualization_msgs
# )
find_package(PCL REQUIRED)
find_package (DBoW3 REQUIRED PATH ../loop_closing/DBow3/)
find_package (Glog REQUIRED)
set (OpenCV_LIB_DIR "/home/gi/Downloads/opencv-3.4.5/build/lib")
find_package(OpenCV 3.4.5 REQUIRED)
IF(USE_CONTRIB)
add_definitions(-DUSE_CONTRIB)
ENDIF()
include_directories(${OpenCV_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
../loop_closing/DBow3/src
./include/
${catkin_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${catkin_INCLUDE_DIRS}
../multi_cam_utils/
./src/
./src/utils/
${GTSAM_INCLUDE_DIR}
${GLOG_INCLUDE_DIRS}
)
MESSAGE("DBOW3 LIBS:${DBoW3_LIBS}")
SET(REQUIRED_LIBRARIES ${REQUIRED_LIBRARIES} ${OpenCV_LIBS} ${PCL_LIBRARIES} ${catkin_LIBRARIES} ${DBoW3_LIBS} ${GLOG_LIBRARIES} -lpthread gtsam gtsam_unstable;${Boost_PROGRAM_OPTIONS_LIBRARY} glog::glog ${excluded_examples})
# ----------------------------------------------------------------------------
# PROJECT CONFIGURATION
# force some variables that could be defined in the command line to be written to cache
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Uninstall target, for "make uninstall"
# ----------------------------------------------------------------------------
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
# ----------------------------------------------------------------------------
# create configuration file from .in file (If you use windows take care with paths)
# ----------------------------------------------------------------------------
INSTALL(FILES "${PROJECT_BINARY_DIR}/Find${PROJECT_NAME}.cmake" DESTINATION ${LIB_INSTALL_DIR}/cmake/ )
INSTALL(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" DESTINATION ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME} )
# ----------------------------------------------------------------------------
# Program Optimization and debug (Extracted from OpenCV)
# ----------------------------------------------------------------------------
set(WARNINGS_ARE_ERRORS OFF CACHE BOOL "Treat warnings as errors")
set(WHOLE_PROGRAM_OPTIMIZATION OFF CACHE BOOL "Flags for whole program optimization.")
set(EXTRA_C_FLAGS "")
set(EXTRA_C_FLAGS_RELEASE "")
set(EXTRA_C_FLAGS_DEBUG "")
set(EXTRA_EXE_LINKER_FLAGS "")
set(EXTRA_EXE_LINKER_FLAGS_RELEASE "")
set(EXTRA_EXE_LINKER_FLAGS_DEBUG "")
#set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wall -Wextra -Wno-sign-compare")
IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
set(ENABLE_PROFILING OFF CACHE BOOL "Enable profiling in the GCC compiler (Add flags: -g -pg)")
set(USE_OMIT_FRAME_POINTER ON CACHE BOOL "Enable -fomit-frame-pointer for GCC")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES arm*) # We can use only -O2 because the -O3 causes gcc crash
set(USE_O2 ON CACHE BOOL "Enable -O2 for GCC")
set(USE_FAST_MATH OFF CACHE BOOL "Enable -ffast-math for GCC")
endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES powerpc*)
set(USE_O3 ON CACHE BOOL "Enable -O3 for GCC")
set(USE_POWERPC ON CACHE BOOL "Enable PowerPC for GCC")
endif ()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES amd64* OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64*)
set(USE_O3 ON CACHE BOOL "Enable -O3 for GCC")
set(USE_FAST_MATH OFF CACHE BOOL "Enable -ffast-math for GCC")
set(USE_MMX ON CACHE BOOL "Enable MMX for GCC")
set(USE_SSE ON CACHE BOOL "Enable SSE for GCC")
set(USE_SSE2 ON CACHE BOOL "Enable SSE2 for GCC")
set(USE_SSE3 ON CACHE BOOL "Enable SSE3 for GCC")
endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES i686* OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES x86)
set(USE_O3 ON CACHE BOOL "Enable -O3 for GCC")
set(USE_FAST_MATH OFF CACHE BOOL "Enable -ffast-math for GCC")
set(USE_MMX ON CACHE BOOL "Enable MMX for GCC")
set(USE_SSE OFF CACHE BOOL "Enable SSE for GCC")
set(USE_SSE2 OFF CACHE BOOL "Enable SSE2 for GCC")
set(USE_SSE3 OFF CACHE BOOL "Enable SSE3 for GCC")
endif ()
if(WARNINGS_ARE_ERRORS)
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Werror")
endif()
# The -Wno-long-long is required in 64bit systems when including system headers.
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64* OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES amd64*)
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-long-long")
endif()
# Whole program optimization
if(WHOLE_PROGRAM_OPTIMIZATION)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -fwhole-program --combine")
endif()
# Other optimizations
if(USE_OMIT_FRAME_POINTER)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -fomit-frame-pointer")
endif()
if(USE_O2)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O2")
endif()
if(USE_O3)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -O3")
endif()
if(USE_FAST_MATH)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -ffast-math")
endif()
if(USE_POWERPC)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mcpu=G3 -mtune=G5")
endif()
if(USE_MMX)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -mmmx")
endif()
if(USE_SSE)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse")
endif()
if(USE_SSE2)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse2")
endif()
if(USE_SSE3 AND NOT MINGW) # SSE3 should be disabled under MingW because it generates compiler errors
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -msse3")
endif()
if(ENABLE_PROFILING)
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -pg -g")
else()
if(NOT APPLE)
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -ffunction-sections")
endif()
endif()
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE} -DNDEBUG ")
set(EXTRA_C_FLAGS_DEBUG "-g3 -O0 -DDEBUG -D_DEBUG -Wall -Wextra -Wno-sign-compare")
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
message( STATUS "GNU COMPILER")
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
ELSE() # MSVC
ENDIF()#END OF COMPILER SPECIFIC OPTIONS
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS_RELEASE}")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS_DEBUG}")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -std=c++11")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -std=c++11")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_EXE_LINKER_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${EXTRA_EXE_LINKER_FLAGS_RELEASE}")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${EXTRA_EXE_LINKER_FLAGS_DEBUG}")
#------------------------------------------------
# DIRS
#------------------------------------------------
find_package(OpenCV 3.4.5 REQUIRED)
add_subdirectory(src)
#target_link_libraries(demo ${PROJECT_NAME} ${OpenCV_LIBS})
# file(COPY demo/images DESTINATION ${CMAKE_BINARY_DIR}/)
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
message( STATUS "General configuration for ${PROJECT_NAME} ${PROJECT_VERSION}")
MESSAGE( STATUS "-------------------------------------------------------------------------------" )
message(" Built as dynamic libs?:" ${BUILD_SHARED_LIBS})
message(" Compiler:" "${CMAKE_COMPILER}" "${CMAKE_CXX_COMPILER}")
message( STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
message( STATUS "C++ flags (Release): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
message( STATUS "C++ flags (Debug): ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
message( STATUS "C++ flags (Relase+Debug): ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
message( STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message( STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
MESSAGE( STATUS )
MESSAGE( STATUS "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}" )
MESSAGE( STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}" )
MESSAGE( STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}" )
MESSAGE( STATUS "CMAKE_MODULE_PATH = ${CMAKE_MODULE_PATH}" )
MESSAGE( STATUS "BUILD_UTILS= ${BUILD_UTILS}" )
MESSAGE( STATUS "BUILD_TESTS= ${BUILD_TESTS}" )
MESSAGE( STATUS "OPENCV_DIR= ${OpenCV_DIR} VERSION=${OpenCV_VERSION}" )
MESSAGE( STATUS "USE_CONTRIB= ${USE_CONTRIB}" )
MESSAGE( STATUS "OpenCV_LIB_DIR=${OpenCV_LIB_DIR}")
MESSAGE( STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}")