forked from classner/fertilized-forests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
250 lines (234 loc) · 8.61 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
cmake_minimum_required (VERSION 3.2)
# Requirement for the findMatlab script shipped with CMake.
project (fertilized C CXX)
list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/build_support/cmake/modules)
# Versioning.
set (fertilized_VERSION_MAJOR 1)
set (fertilized_VERSION_MINOR 0)
set (fertilized_VERSION_PATCH 2)
set (fertilized_VERSION
"${fertilized_VERSION_MAJOR}.${fertilized_VERSION_MINOR}.${fertilized_VERSION_PATCH}")
set (fertilized_VERSION_NUMBER
"${fertilized_VERSION_MAJOR}${fertilized_VERSION_MINOR}${fertilized_VERSION_PATCH}")
# Set a default build type if none was specified.
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message (STATUS "Setting build type to 'Release' since none was specified.")
set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui.
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# Setup the library.
include_directories (include)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
set (BOOST_COMPONENTS date_time
serialization
filesystem
system
unit_test_framework
thread)
# Options.
option (WITH_SERIALIZATION "Build the serialization routines" ON)
# Python.
find_package (PythonInterp)
find_package (PythonLibs)
if (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
option (WITH_PYTHON "Build the Python interface" ON)
else()
option (WITH_PYTHON "Build the Python interface" OFF)
endif()
# Matlab.
find_package (Matlab)
if (MATLAB_FOUND)
option (WITH_MATLAB "Build the MATLAB interface" ON)
else()
option (WITH_MATLAB "Build the MATLAB interface" OFF)
endif()
# OpenCV.
find_package (OpenCV COMPONENTS core imgproc highgui)
if (OpenCV_FOUND)
include_directories (${OpenCV_INCLUDE_DIRS})
if (OpenCV_LIBRARIES)
set (OpenCV_COMPATIBLE_LIBRARIES ${OpenCV_LIBRARIES})
else()
set (OpenCV_COMPATIBLE_LIBRARIES ${OpenCV_LIBS})
endif()
option (WITH_OPENCV "Enable feature extraction with OpenCV" ON)
else()
option (WITH_OPENCV "Enable feature extraction with OpenCV" OFF)
endif()
# Caffe.
find_package (Caffe)
if (CAFFE_FOUND AND OpenCV_FOUND)
option (WITH_CAFFE "Build the caffe feature extractor" ON)
else()
option (WITH_CAFFE "Build the caffe feature extractor" OFF)
endif()
# CUDA.
find_package (CUDA)
if (CUDA_FOUND)
option (CAFFE_CPU_ONLY "Use the CPU only version of CAFFE" OFF)
else()
option (CAFFE_CPU_ONLY "Use the CPU only version of CAFFE" ON)
endif()
# Configure.
if (WITH_SERIALIZATION)
add_definitions (-DSERIALIZATION_ENABLED)
endif()
if (WITH_PYTHON)
if (NOT PYTHONINTERP_FOUND OR NOT PYTHONLIBS_FOUND)
message (FATAL_ERROR "You specified WITH_PYTHON, but interpreter or libs \
weren't found!")
endif ()
add_definitions (-DPYTHON_ENABLED)
include_directories (${PYTHON_INCLUDE_PATH})
if (${PYTHON_VERSION_STRING} GREATER 3.0)
message (STATUS "Using Python3")
list (APPEND BOOST_COMPONENTS python3)
else()
message (STATUS "Using Python2")
list (APPEND BOOST_COMPONENTS python)
endif ()
# Take care of Boost.NumPy.
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/build_support/external/Boost.NumPy/libs/numpy/cmake ${CMAKE_MODULE_PATH})
endif ()
if (WITH_MATLAB)
if (NOT MATLAB_FOUND)
message (FATAL_ERROR "You specified WITH_MATLAB, but it wasn't found!\
Try to run CMAKE with -DMatlab_ROOT_DIR=...!")
endif ()
endif ()
if (WITH_OPENCV)
if (NOT OpenCV_FOUND)
message (FATAL_ERROR "You specified WITH_OPENCV, but it wasn't found!")
endif ()
endif ()
if (WITH_CAFFE)
if (NOT CAFFE_FOUND)
message (FATAL_ERROR "You specified WITH_CAFFE, but it wasn't found!\
Try to run CMAKE with -DCAFFE_ROOT_DIR=...!\
It is necessary to build the shared library of\
caffe by configuring it with `-DBUILD_SHARED_LIBS=ON`\
on Linux&Mac. You should afterwards either install\
it or set -DCAFFE_ROOT_DIR to the path of the\
caffe or its build oe install directory.")
endif ()
if (NOT WITH_OPENCV)
message (FATAL_ERROR "When building with CAFFE, OpenCV is required!")
endif ()
find_package (Protobuf)
if ("${PROTOBUF_INCLUDE_DIR}" MATCHES "PROTOBUF_INCLUDE_DIR-NOTFOUND")
message (FATAL_ERROR "The protobuf includes are required when linking against CAFFE!")
endif()
include_directories (${PROTOBUF_INCLUDE_DIR})
if (NOT CAFFE_CPU_ONLY AND NOT CUDA_FOUND)
message (FATAL_ERROR "You specified to build the not CPU only version of\
CAFFE but CUDA could not be found!")
endif ()
endif ()
# Use C++11 features.
set (REQ_CPP11_FEATURES
cxx_strong_enums
cxx_auto_type)
# Check for OpenMP support.
find_package (OpenMP)
if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif ()
# Fix clang warnings.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-tautological-compare -Wno-logical-op-parentheses -Wno-deprecated-register")
endif()
# Configure the dependencies.
find_package (Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
# Deactivate boost auto-linking in favor of direct CMake linking.
add_definitions (-DBOOST_ALL_NO_LIB)
include_directories (${Boost_INCLUDE_DIRS})
if (WITH_PYTHON)
find_package (NumPy REQUIRED)
include_directories (${NUMPY_INCLUDE_DIRS})
include_directories (${PROJECT_SOURCE_DIR}/build_support/external/Boost.NumPy)
add_subdirectory (${PROJECT_SOURCE_DIR}/build_support/external/Boost.NumPy/libs/numpy/src)
endif()
find_package(Eigen3 REQUIRED)
add_definitions (-DEIGEN_MPL2_ONLY)
include_directories (${EIGEN3_INCLUDE_DIR})
# Targets.
# Create the library.
add_subdirectory (include)
add_subdirectory (src)
# Create the tests.
add_subdirectory (tests)
enable_testing ()
# Create the bindings.
add_subdirectory (bindings/python)
add_subdirectory (bindings/matlab)
# Create the examples.
add_subdirectory (examples/c++)
# Create the documentation.
add_subdirectory (documentation)
# Summarize.
message ("--------------------------------------------------------------------")
message ("Configuration summary")
message ("--------------------------------------------------------------------")
message ("")
message ("Library options:")
if (WITH_SERIALIZATION)
message (" Building serialization routines")
else ()
message (" Building without serialization routines")
endif ()
if (WITH_PYTHON)
message (" Building Python bindings for version " ${PYTHONLIBS_VERSION_STRING})
message (" Python interpreter:\t" ${PYTHON_EXECUTABLE})
message (" Python include path:\t" ${PYTHON_INCLUDE_DIRS})
message (" Python library:\t" ${PYTHON_LIBRARIES})
else ()
message (" Not building Python bindings")
endif ()
if (WITH_MATLAB)
message (" Building MATLAB bindings")
else ()
message (" Not building MATLAB bindings")
endif ()
if (WITH_OPENCV)
message (" Building with OpenCV")
else ()
message (" Building without OpenCV")
endif ()
if (WITH_CAFFE)
message(" Building caffe interface")
if (CAFFE_CPU_ONLY)
message (" Building CPU only interface (must match CAFFE compilation!)")
else ()
message (" Building CPU&GPU interface (must match CAFFE compilation!)")
endif ()
else ()
message (" Not building caffe interface")
endif ()
message ("")
message ("Compiler options:")
message (" Build type: " ${CMAKE_BUILD_TYPE})
message (" Compiler flags: " ${CMAKE_CXX_COMPILE_FLAGS})
message (" Compiler cxx debug flags: " ${CMAKE_CXX_FLAGS_DEBUG})
message (" Compiler cxx release flags: " ${CMAKE_CXX_FLAGS_RELEASE})
message (" Compiler cxx min size flags: " ${CMAKE_CXX_FLAGS_MINSIZEREL})
message (" Compiler cxx flags: " ${CMAKE_CXX_FLAGS})
message ("")
message ("Installation options:")
message (" Installation prefix path: " ${CMAKE_INSTALL_PREFIX})
message ("")
message ("--------------------------------------------------------------------")
if (WITH_MATLAB)
message (WARNING "After building, the MATLAB files can not be installed "
"automatically. They will reside in the folder `bindings/matlab` in "
"your build folder. They are relocatable, so move them to your "
"favorite location.")
endif()
if (WIN32)
if (WITH_CAFFE)
message (WARNING "Caffe linking is experimental (at best) on Windows! "
"Expect to mess around with the build system! It probably "
"works best with https://github.com/willyd/caffe-builder.")
endif()
endif()