-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathCMakeLists.txt
151 lines (121 loc) · 5.28 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
# This Cmake file written by Michael Warren,
# Queensland University of Technology, Australia
# https://wiki.qut.edu.au/display/cyphy/Michael+Warren
# Last updated 2014-11-03
project(openFABMAP)
cmake_minimum_required(VERSION 3.0)
## Cmake setup #################################################################
# make a lib directory in the build directory
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
# tell cmake that the library goes in the library directory
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)
# make a binary directory in the build directory
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
# tell cmake that the binaries goes in the binary directory
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
# Compiler warning level /W3 (msvc) or -Wall (gcc)
if(MSVC)
# Force to always compile with W4
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
endif()
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
endif()
if(NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified.")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Release")
endif()
endif()
## Required Packages ###########################################################
# OpenMP speedups
message(STATUS "")
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
message("Found OpenMP")
endif(OPENMP_FOUND)
# Find OpenCV.
# If it's not found, set OpenCV_DIR to the directory with OpenCVConfig.cmake
if(WIN32)
set(OpenCV_PATHS
$ENV{OPENCV_HOME}
$ENV{OPENCV_DIR}/../../
C:/opencv/
C:/OpenCV2.2/
C:/OpenCV2.3/
C:/OpenCV2.4/
)
else() # Linux
set(OpenCV_PATHS
$ENV{OPENCV_HOME}/build
/usr/local/share/OpenCV/
/usr/share/OpenCV
)
endif()
find_package(OpenCV REQUIRED NO_MODULE PATHS ${OpenCV_PATHS})
message("OpenCV version: ${OpenCV_VERSION}")
if(OpenCV_VERSION VERSION_LESS "2.4.0")
add_definitions(-DUSENONFREE)
elseif(OpenCV_VERSION VERSION_LESS "3.0.0")
if("${OpenCV_LIBRARIES}" MATCHES opencv_nonfree)
message("Non-free packages found. Using e.g. SIFT/SURF")
add_definitions(-DUSENONFREE)
endif()
else()
if("${OpenCV_LIBRARIES}" MATCHES opencv_xfeatures2d)
message("Non-free packages found. Using e.g. SIFT/SURF")
add_definitions(-DUSENONFREE)
endif()
endif()
## openFABMAP library ##########################################################
# List sources
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src OPENFABMAP_FILES)
# Include the headers
file(GLOB OPENFABMAP_IMPL_INCS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp")
file(GLOB OPENFABMAP_INCS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
# tell cmake about the library
add_library(openFABMAP ${OPENFABMAP_FILES}
${OPENFABMAP_IMPL_INCS} ${OPENFABMAP_INCS})
# Tell CMake where the headers are
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${OpenCV_INCLUDE_DIRS})
# Link against the required libraries in OpenCV >=2.2
target_link_libraries(openFABMAP ${OpenCV_LIBRARIES})
## openFABMAPcli executable ####################################################
# Tell the project where settings / doxygen / readme files are (for Qt Creator)
file(GLOB SETTINGS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/samples/settings.yml")
file(GLOB DOXY_FILES "${CMAKE_CURRENT_SOURCE_DIR}"
".travis.yml" "doxygen/*.dox" "doxygen/*.dox.*" "doxygen/*.xml")
set(README_FILES "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
# Copy the settings file across when building (not used for now)
#FILE(COPY ${SETTINGS_FILE} DESTINATION ${CMAKE_BINARY_DIR}/bin)
# Tell cmake about the binary
add_executable(openFABMAPcli ${CMAKE_SOURCE_DIR}/samples/openFABMAPcli.cpp
${SETTINGS_FILE} ${DOXY_FILES} ${README_FILES})
# Tell openFABMAPcli to link against its required libs
target_link_libraries(openFABMAPcli openFABMAP ${OpenCV_LIBRARIES} )
## Doxygen API documentation ###################################################
# Add the 'doc' target to generate API documentation with Doxygen
set(DOXYGEN_CREATE_DOCS false CACHE BOOL "Create documentation with Doxygen")
if(DOXYGEN_CREATE_DOCS)
find_package(Doxygen)
if(DOXYGEN_FOUND)
# Process and copy configuration file
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
# Uncomment ALL to make every time. Otherwise use "make doc"
add_custom_target(doc #ALL
${DOXYGEN_EXECUTABLE}
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
else(DOXYGEN_FOUND)
message(WARNING "Doxygen package not found, no documentation target")
endif(DOXYGEN_FOUND)
endif(DOXYGEN_CREATE_DOCS)