forked from VIAME/VIAME
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
368 lines (297 loc) · 11.7 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
###
# top level build file for NOAA VIAME
#
cmake_minimum_required( VERSION 3.3 )
project( VIAME )
include( CMakeDependentOption )
###
# Add paths used throughout CMakeLists files
##
list( INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/CMake" "${KWIVER_CMAKE_DIR}" )
set( VIAME_SOURCE_DIR "${CMAKE_SOURCE_DIR}" )
set( VIAME_BINARY_DIR "${CMAKE_BINARY_DIR}/build" )
set( VIAME_BUILD_PREFIX "${CMAKE_BINARY_DIR}/build" )
set( VIAME_BUILD_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" )
set( VIAME_PACKAGES_DIR "${VIAME_SOURCE_DIR}/packages" )
set( VIAME_DOWNLOAD_DIR "${VIAME_PACKAGES_DIR}/downloads" )
###
# Flags relating to examples
##
option( VIAME_INSTALL_EXAMPLES "Install existing VIAME examples" ON )
option( VIAME_DOWNLOAD_MODELS "Download example detection models" ON )
###
# GPU and FFMPEG utilization flags used across projects
##
option( VIAME_ENABLE_CUDA "Enable CUDA-Dependent Code" OFF )
option( VIAME_ENABLE_CUDNN "Enable CUDNN-Dependent Code" OFF )
option( VIAME_ENABLE_FFMPEG "Enable FFMPEG-Dependent Code" OFF )
###
# Add core utilities enable flags
##
option( VIAME_ENABLE_DOCS "Enable Documentation" OFF )
option( VIAME_ENABLE_VIVIA "Enable Vivia GUIs" OFF )
option( VIAME_ENABLE_KWANT "Enable KW Scoring Code" OFF )
###
# Add algorithmic plugin enable flags
##
option( VIAME_ENABLE_VXL "Enable VXL plugins" OFF )
option( VIAME_ENABLE_OPENCV "Enable OpenCV plugins" OFF )
option( VIAME_ENABLE_MATLAB "Enable Matlab plugins" OFF )
option( VIAME_ENABLE_PYTHON "Enable Python plugins" OFF )
option( VIAME_ENABLE_CAFFE "Enable Caffe plugins" OFF )
option( VIAME_ENABLE_FASTER_RCNN "Enable Faster RCNN plugin" OFF )
option( VIAME_ENABLE_SCALLOP_TK "Enable ScallopTK plugin" OFF )
option( VIAME_ENABLE_UW_PREDICTOR "Enable UW predictor plugin" OFF )
option( VIAME_ENABLE_YOLO "Enable YOLO (darknet) plugin" OFF )
option( VIAME_ENABLE_BURNOUT "Enable Burn-Out plugin" OFF )
option( VIAME_ENABLE_SMQTK "Enable SMQTK plugin" OFF )
###
# Add external package build instructions
##
option( VIAME_BUILD_DEPENDENCIES "Build all required dependencies in a super-build" ON )
option( VIAME_CREATE_PACKAGE "Build a binary package at the end of build" OFF )
mark_as_advanced( VIAME_CREATE_PACKAGE )
###
# Add logic relating to enable flags
##
if( VIAME_ENABLE_CAFFE OR VIAME_ENABLE_SCALLOP_TK OR VIAME_ENABLE_MATLAB OR
VIAME_ENABLE_FASTER_RCNN )
set( VIAME_ENABLE_OPENCV ON CACHE BOOL "OpenCV required for other projects" FORCE )
endif()
if( VIAME_ENABLE_FASTER_RCNN OR VIAME_ENABLE_SMQTK )
set( VIAME_ENABLE_PYTHON ON CACHE BOOL "Python required for other projects" FORCE )
endif()
if( VIAME_ENABLE_FASTER_RCNN )
set( VIAME_ENABLE_CAFFE ON CACHE BOOL "Caffe required for other projects" FORCE )
endif()
if( VIAME_ENABLE_KWANT OR VIAME_ENABLE_VIVIA )
set( VIAME_ENABLE_VXL ON CACHE BOOL "VXL required for other projects" FORCE )
endif()
if( VIAME_ENABLE_VIVIA )
set( VIAME_ENABLE_BURNOUT ON CACHE BOOL "Burn-Out required for other projects" FORCE )
endif()
if( VIAME_ENABLE_MATLAB )
find_package( Matlab REQUIRED COMPONENTS ENG_LIBRARY MX_LIBRARY )
endif()
if( VIAME_ENABLE_DOCS )
find_package( Doxygen REQUIRED )
endif()
if( VIAME_ENABLE_PYTHON )
option( VIAME_DISABLE_PYTHON_CHECK "Disable python version checking" OFF )
mark_as_advanced( VIAME_DISABLE_PYTHON_CHECK )
find_package( PythonInterp REQUIRED )
find_package( PythonLibs REQUIRED )
if( NOT ${VIAME_DISABLE_PYTHON_CHECK} AND
( NOT PYTHON_VERSION_MAJOR EQUAL "2" OR NOT PYTHON_VERSION_MINOR EQUAL "7" ) )
message( FATAL_ERROR "Only Python2.7.* is currently supported, please point \
your PYTHON_EXECUTABLE, PYTHON_LIBRARY and PYTHON_INCLUDE_DIR to a \
Python2.7.* install, or set VIAME_DISABLE_PYTHON_CHECK to ignore this \
message and build with other versions at your own peril." )
endif()
if( NOT ${VIAME_DISABLE_PYTHON_CHECK} AND
NOT PYTHONLIBS_VERSION_STRING VERSION_LESS "3.0.0" )
message( FATAL_ERROR "It appears your pipeline executable and headers point \
to different versions of Python. Only Python2.7.* is currently supported, \
please point your PYTHON_LIBRARY and PYTHON_INCLUDE_DIR to a Python2.7.* \
install, or set VIAME_DISABLE_PYTHON_CHECK to ignore this message." )
endif()
if( NOT ${VIAME_DISABLE_PYTHON_CHECK} AND
NOT EXISTS ${PYTHON_INCLUDE_DIR}/pyconfig.h )
message( FATAL_ERROR "pyconfig.h does not exist in your PYTHON_INCLUDE_DIR \
make sure the variable is set correctly and you have python-dev installed." )
endif()
endif()
# VXL enabled triggers yasm to be built, requiring at least some python
if( VIAME_ENABLE_VXL )
find_package( PythonInterp QUIET )
if( NOT PYTHONINTERP_FOUND )
message( FATAL_ERROR "If VXL is enabled, there must be some python install located \
on the system to build, even if VIAME_ENABLE_PYTHON is turned off for all other \
packages. A python binary could not be found. Please install at least python." )
endif()
endif()
if( VIAME_ENABLE_CUDA )
find_package( CUDA QUIET REQUIRED )
endif()
if( VIAME_ENABLE_CUDNN AND NOT VIAME_ENABLE_CUDA )
message( FATAL_ERROR "Cannot enable CUDNN without CUDA support" )
endif()
if( WIN32 AND VIAME_ENABLE_FASTER_RCNN )
message( FATAL_ERROR "Faster R-CNN on windows is currently untested \
in VIAME, either disable it, or if you're ambitious, disable this message \
and continue." )
endif()
if( VIAME_ENABLE_CUDNN )
set( CUDNN_ROOT "" CACHE PATH "CUDNN root folder, leave as blank to auto-detect." )
find_library( CUDNN_LIBRARY REQUIRED
NAMES cudnn libcudnn.so libcudnn.so.5
PATHS ${CUDNN_ROOT}
${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux
${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib lib64 )
if( NOT CUDNN_LIBRARY )
message( FATAL_ERROR "Unable to locate CUDNN library" )
else()
# Different subprojects use each variable
set( CUDNN_LIBRARIES CUDNN_LIBRARY CACHE INTERNAL "" FORCE )
endif()
endif()
if( WIN32 AND VIAME_ENABLE_PYTHON AND CMAKE_CONFIGURATION_TYPES EQUAL "Debug" )
message( FATAL_ERROR "Cannot build in Debug on Windows with Python enabled, \
build in RelWithDebInfo or Release until fixed." )
endif()
if( VIAME_ENABLE_OPENCV )
set( VIAME_OPENCV_VERSION 2.4.11 CACHE STRING "Version of OpenCV to use" )
set_property( CACHE VIAME_OPENCV_VERSION PROPERTY STRINGS 2.4.11 3.1.0 )
endif()
# Set default windows configuration mode to be 'Release'
set( VIAME_FIRST_CONFIGURATION TRUE CACHE BOOL "Has this project been configured." )
mark_as_advanced( VIAME_FIRST_CONFIGURATION )
if( MSVC AND VIAME_FIRST_CONFIGURATION )
set( CMAKE_CONFIGURATION_TYPES "Release" CACHE STRING "This specifies what \
build types (configurations) will be available for selection within \
Visual Studio. Options are: Release, RelWithDebInfo, Debug etc. in a \
semi-colon seperated list." FORCE )
set( VIAME_FIRST_CONFIGURATION FALSE CACHE BOOL "Project has been configured." FORCE )
endif()
if( MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "18.00" )
message( FATAL_ERROR "You must use at least MSVC version 13 or greater" )
endif()
# Include internal common CMake macros used across all CMakeLists.txt
include( common_macros )
###
# Main build loop for when we are building both VIAME and all dependencies
##
if( VIAME_BUILD_DEPENDENCIES )
# Include for CMake external project add command
include( ExternalProject )
# Specifies internal arguments passed to all projects (CXX flag passdowns, etc)
include( common_args )
# Hard VIAME requirements
include( add_project_fletch )
# Add optional YOLO build
if( VIAME_ENABLE_YOLO )
include( add_project_darknet )
endif()
# Add core (required) kwiver requirement
include( add_project_kwiver )
# Add other optional libraries
if( VIAME_ENABLE_SCALLOP_TK )
include( add_project_scallop_tk )
endif()
if( VIAME_ENABLE_BURNOUT )
include( add_project_burnout )
endif()
if( VIAME_ENABLE_VIVIA )
include( add_project_vivia )
endif()
if( VIAME_ENABLE_KWANT )
include( add_project_kwant )
endif()
if( VIAME_ENABLE_FASTER_RCNN )
include( add_project_faster_rcnn )
endif()
if( VIAME_ENABLE_SMQTK )
include( add_project_smqtk )
endif()
# VIAME plugins, adds this project causing the below else() block to run
include( add_project_viame )
# Fixup package
if( VIAME_CREATE_PACKAGE )
include( build_package )
endif()
else()
###
# Look for and use Fletch to find dependencies
##
find_package( kwiver REQUIRED )
include_directories( ${KWIVER_INCLUDE_DIRS} )
link_directories( ${KWIVER_LIBRARY_DIR} )
list( INSERT CMAKE_MODULE_PATH 0 "${KWIVER_CMAKE_DIR}" )
if( IS_DIRECTORY ${fletch_DIR} )
find_package( fletch NO_MODULE )
list( APPEND CMAKE_PREFIX_PATH "${fletch_DIR}" )
endif()
if( VIAME_ENABLE_OPENCV )
find_package( OpenCV REQUIRED )
endif()
include_directories( "${CMAKE_CURRENT_BINARY_DIR}" "${KWIVER_INCLUDE_DIRS}" )
###
# KWIVER CMake config
##
include( kwiver-utils )
##
# System specific compiler flags
include( viame-flags )
##
# Build system hack for visual system, will be removed
include( windows-ksys-hack )
##
# check compiler support
include( kwiver-configcheck )
# set the name for our package exports
set( kwiver_export_name viame_exports )
# Setup python directories for plugin processes in same style as KWIVER
if( VIAME_ENABLE_PYTHON )
set( kwiver_python_subdir "python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" )
set( kwiver_python_output_path "${VIAME_BUILD_PREFIX}/lib/${kwiver_python_subdir}" )
kwiver_create_python_plugin_init( viame )
kwiver_create_python_plugin_init( viame/processes )
endif()
###
# build submodules
###
# add subdirs
##
add_subdirectory( plugins )
add_subdirectory( examples )
###
# Configure setup scripts
##
include( setup_viame_paths )
if( WIN32 )
set( VIAME_PIPELINE_RUNNER_SCRIPT "${VIAME_BINARY_DIR}/pipeline_runner.bat" )
set( VIAME_PROCESSOPEDIA_SCRIPT "${VIAME_BINARY_DIR}/processopedia.bat" )
set( VIAME_PLUGIN_EXPLORER_SCRIPT "${VIAME_BINARY_DIR}/plugin_explorer.bat" )
set( VIAME_SETUP_SCRIPT "${VIAME_BINARY_DIR}/setup_viame.bat" )
configure_file(
${CMAKE_SOURCE_DIR}/CMake/pipeline_runner.bat.in
${VIAME_PIPELINE_RUNNER_SCRIPT}
)
configure_file(
${CMAKE_SOURCE_DIR}/CMake/processopedia.bat.in
${VIAME_PROCESSOPEDIA_SCRIPT}
)
configure_file(
${CMAKE_SOURCE_DIR}/CMake/plugin_explorer.bat.in
${VIAME_PLUGIN_EXPLORER_SCRIPT}
)
configure_file(
${CMAKE_SOURCE_DIR}/CMake/setup_viame.bat.in
${VIAME_SETUP_SCRIPT}
)
install( PROGRAMS ${VIAME_PIPELINE_RUNNER_SCRIPT}
${VIAME_PROCESSOPEDIA_SCRIPT}
${VIAME_PLUGIN_EXPLORER_SCRIPT}
${VIAME_SETUP_SCRIPT}
DESTINATION ${CMAKE_INSTALL_PREFIX} )
else()
set( VIAME_SETUP_SCRIPT_FILE "${VIAME_BINARY_DIR}/setup_viame.sh" )
configure_file(
${CMAKE_SOURCE_DIR}/CMake/setup_viame.sh.in
${VIAME_SETUP_SCRIPT_FILE}
)
install( PROGRAMS ${VIAME_SETUP_SCRIPT_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX} )
endif()
###
# Install system libs if packaging enabled
##
if( VIAME_CREATE_PACKAGE )
set( CMAKE_INSTALL_UCRT_LIBRARIES TRUE )
include( InstallRequiredSystemLibraries )
if( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS )
install( PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION bin COMPONENT System )
endif()
endif()
endif()