forked from ukoethe/vigra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
456 lines (374 loc) · 15.4 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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
cmake_minimum_required(VERSION 2.6)
##################################################
#
# basic initializations
#
##################################################
PROJECT(vigra)
# read the current version from config_version.hxx
file(READ ${vigra_SOURCE_DIR}/include/vigra/config_version.hxx VIGRA_VERSION_FILE)
string(REGEX MATCH "VIGRA_VERSION_MAJOR[ \t\n]+[^ \t\n]+" VIGRA_VERSION_MAJOR ${VIGRA_VERSION_FILE})
string(REGEX REPLACE "VIGRA_VERSION_MAJOR[ \t\n]" "" VIGRA_VERSION_MAJOR ${VIGRA_VERSION_MAJOR})
string(REGEX MATCH "VIGRA_VERSION_MINOR[ \t\n]+[^ \t\n]+" VIGRA_VERSION_MINOR ${VIGRA_VERSION_FILE})
string(REGEX REPLACE "VIGRA_VERSION_MINOR[ \t\n]" "" VIGRA_VERSION_MINOR ${VIGRA_VERSION_MINOR})
string(REGEX MATCH "VIGRA_VERSION_PATCH[ \t\n]+[^ \t\n]+" VIGRA_VERSION_PATCH ${VIGRA_VERSION_FILE})
string(REGEX REPLACE "VIGRA_VERSION_PATCH[ \t\n]" "" VIGRA_VERSION_PATCH ${VIGRA_VERSION_PATCH})
SET(vigra_version_short ${VIGRA_VERSION_MAJOR}.${VIGRA_VERSION_MINOR})
SET(vigra_version ${VIGRA_VERSION_MAJOR}.${VIGRA_VERSION_MINOR}.${VIGRA_VERSION_PATCH})
message(STATUS "Configuring VIGRA version ${vigra_version}")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${vigra_SOURCE_DIR}/config)
include(VigraSetDefaults)
include(VigraCMakeUtils)
include(VigraConfigureThreading)
INCLUDE_DIRECTORIES(${vigra_SOURCE_DIR}/include)
IF(VIGRA_STATIC_LIB)
SET(LIBTYPE STATIC)
ADD_DEFINITIONS(-DVIGRA_STATIC_LIB)
ELSE(VIGRA_STATIC_LIB)
SET(LIBTYPE SHARED)
ENDIF(VIGRA_STATIC_LIB)
IF (MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE)
ENDIF ()
IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)")
set(SUFFICIENT_TEMPLATE_DEPTH FALSE)
TRY_COMPILE(SUFFICIENT_TEMPLATE_DEPTH
${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/config/checkTemplateDepth.cxx
COMPILE_DEFINITIONS "-DDEPTH=900")
IF(SUFFICIENT_TEMPLATE_DEPTH)
MESSAGE(STATUS "Checking template recursion depth: ok")
ELSE()
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
# As of cmake 2.8.10, there is a variable CMAKE_CXX_COMPILER_VERSION.
# Emulate it by a compiler call if not present.
IF(NOT CMAKE_CXX_COMPILER_VERSION)
exec_program(${CMAKE_CXX_COMPILER}
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1.\\2"
CMAKE_CXX_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
endif()
message ("Detected GCC version ${CMAKE_CXX_COMPILER_VERSION}")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.4.0")
MESSAGE(WARNING "GNU c++ < 4.4 cannot build VIGRANumPy; disabling (found GCC ${CMAKE_CXX_COMPILER_VERSION})")
SET(WITH_VIGRANUMPY 0)
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.5.0")
# gcc 4.4.x syntax is -ftemplate-depth-900 (not =900)
SET(CMAKE_CXX_FLAGS "-ftemplate-depth-900 ${CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types" FORCE)
MESSAGE(STATUS "Checking template recursion depth: using -ftemplate-depth-900")
else()
# new syntax is =900, not -900
SET(CMAKE_CXX_FLAGS "-ftemplate-depth=900 ${CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types" FORCE)
MESSAGE(STATUS "Checking template recursion depth: using -ftemplate-depth=900")
endif()
else()
# clang uses newer gcc syntax
SET(CMAKE_CXX_FLAGS "-ftemplate-depth=900 ${CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types" FORCE)
MESSAGE(STATUS "Checking template recursion depth: using -ftemplate-depth=900")
endif()
ENDIF()
ENDIF()
##################################################
#
# search for dependencies
#
##################################################
INCLUDE(VigraFindPackage)
VIGRA_FIND_PACKAGE(ZLIB)
VIGRA_FIND_PACKAGE(TIFF NAMES libtiff_i libtiff) # prefer DLL on Windows
VIGRA_FIND_PACKAGE(JPEG NAMES libjpeg)
VIGRA_FIND_PACKAGE(PNG)
VIGRA_FIND_PACKAGE(FFTW3 NAMES libfftw3-3 libfftw-3.3)
VIGRA_FIND_PACKAGE(FFTW3F NAMES libfftw3f-3 libfftwf-3.3)
IF(WITH_OPENEXR)
VIGRA_FIND_PACKAGE(OpenEXR)
ENDIF()
IF(WITH_HDF5)
VIGRA_FIND_PACKAGE(HDF5)
ENDIF()
set(WITH_BOOST "OFF")
set(WITH_BOOST_COMPONENTS "")
IF(WITH_BOOST_GRAPH)
set(WITH_BOOST "ON")
ENDIF()
IF(WITH_VIGRANUMPY)
set(WITH_BOOST "ON")
set(WITH_BOOST_COMPONENTS ${WITH_BOOST_COMPONENTS} python)
ENDIF()
IF(WITH_BOOST_THREAD)
set(WITH_BOOST "ON")
set(WITH_BOOST_COMPONENTS ${WITH_BOOST_COMPONENTS} thread system date_time chrono)
ADD_DEFINITIONS(-DUSE_BOOST_THREAD)
ENDIF()
IF(WITH_BOOST)
VIGRA_FIND_PACKAGE( Boost 1.40.0 COMPONENTS ${WITH_BOOST_COMPONENTS})
if(Boost_FOUND AND WITH_BOOST_COMPONENTS)
# configure boost's autolink magic to use the right library name
# (default on Windows is a mangled name like 'boost_python-vc110-mt-1_51.lib')
if(("${Boost_PYTHON_LIBRARY}" MATCHES "boost_python\\.lib") OR
("${Boost_SYSTEM_LIBRARY}" MATCHES "boost_system\\.lib"))
ADD_DEFINITIONS(-DBOOST_AUTO_LINK_NOMANGLE)
endif()
endif()
ENDIF()
IF(WITH_LEMON)
VIGRA_FIND_PACKAGE(LEMON)
ENDIF()
SET(DOXYGEN_SKIP_DOT TRUE)
FIND_PACKAGE(Doxygen)
FIND_PACKAGE(PythonInterp 2)
IF(WITH_VIGRANUMPY)
FIND_PACKAGE( VIGRANUMPY_DEPENDENCIES )
ENDIF()
IF(WITH_VALGRIND)
FIND_PROGRAM(VALGRIND_EXECUTABLE valgrind)
ENDIF()
##################################################
#
# setup testing environment
#
##################################################
ADD_CUSTOM_TARGET(check)
ADD_CUSTOM_TARGET(ctest COMMAND ${CMAKE_CTEST_COMMAND})
ADD_CUSTOM_TARGET(check_cpp)
ADD_DEPENDENCIES(check check_cpp)
OPTION(CREATE_CTEST_TARGETS "Create special targets for CTest" OFF)
IF(CREATE_CTEST_TARGETS)
INCLUDE(CTest)
ENDIF()
IF(WITH_VIGRANUMPY)
ADD_CUSTOM_TARGET(check_python)
ADD_DEPENDENCIES(check check_python)
ENDIF()
ENABLE_TESTING()
##################################################
#
# setup documentation generator
#
##################################################
ADD_CUSTOM_TARGET(doc)
# Automatically push the latest documentation to github's gh-pages.
# This only works when ${DOCDIR} refers to a VIGRA repository that is
# checked out in branch 'gh-pages', and the present repository is
# in branch 'master' (these conditions are checked in the script).
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
configure_file(${PROJECT_SOURCE_DIR}/config/update-gh-pages.sh.in
${PROJECT_BINARY_DIR}/update-gh-pages.sh @ONLY)
EXECUTE_PROCESS(COMMAND chmod u+x ${PROJECT_BINARY_DIR}/update-gh-pages.sh OUTPUT_QUIET ERROR_QUIET)
ADD_CUSTOM_TARGET(gh-pages
${PROJECT_BINARY_DIR}/update-gh-pages.sh
DEPENDS doc
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Pushing documentation to github pages.")
endif()
##################################################
#
# setup private experimentation target
#
##################################################
ADD_CUSTOM_TARGET(experiments)
##################################################
#
# subdirectories
#
##################################################
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)
ADD_SUBDIRECTORY(docsrc)
IF(WITH_VIGRANUMPY)
ADD_SUBDIRECTORY(vigranumpy)
ENDIF()
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/private/CMakeLists.txt)
ADD_SUBDIRECTORY(private EXCLUDE_FROM_ALL)
ENDIF()
set(LIB_SUFFIX "" CACHE STRING "Define suffix of lib directory name (32/64)" )
##################################################
#
# global installation commands
#
##################################################
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/include/vigra
DESTINATION include)
##################################################
#
# enable CPack package generation
#
##################################################
INCLUDE(CPackConfig)
##################################################
#
# add target vigra-$version-src.tar.gz
#
##################################################
find_program(GIT_EXECUTABLE
NAMES git git.exe git.cmd
HINTS $ENV{ProgramFiles}/Git/bin
DOC "git command line client")
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/config/package-src.cmake.in
${PROJECT_BINARY_DIR}/package-src.cmake
@ONLY IMMEDIATE)
add_custom_target(PACKAGE_SRC_TAR
COMMAND ${CMAKE_COMMAND} -P package-src.cmake
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
COMMENT "Creating ${PROJECT_BINARY_DIR}/vigra-${vigra_version}-src.tar.gz")
ADD_DEPENDENCIES(PACKAGE_SRC_TAR check)
ADD_DEPENDENCIES(PACKAGE_SRC_TAR doc_cpp)
IF(WITH_VIGRANUMPY AND PYTHON_SPHINX)
ADD_DEPENDENCIES(PACKAGE_SRC_TAR doc_python)
ENDIF()
##################################################
#
# enable other non-CMake projects to find Vigra
#
##################################################
IF(NOT WIN32)
# vigra-config script for (non-CMake-based) third party packages
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/config/vigra-config.in
${PROJECT_BINARY_DIR}/bin/vigra-config
@ONLY IMMEDIATE)
INSTALL(FILES ${PROJECT_BINARY_DIR}/bin/vigra-config
DESTINATION bin
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
ENDIF(NOT WIN32)
##################################################
#
# enable other CMake projects to find Vigra
#
##################################################
# config file for CMake FIND_PACKAGE command (for using the build tree)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/config/VigraConfigBuild.cmake.in
${PROJECT_BINARY_DIR}/VigraConfig.cmake
@ONLY IMMEDIATE)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/config/VigraConfigVersion.cmake.in
${PROJECT_BINARY_DIR}/VigraConfigVersion.cmake
@ONLY IMMEDIATE)
# config file for CMake FIND_PACKAGE command
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/config/VigraConfig.cmake.in
${PROJECT_BINARY_DIR}/lib/vigra/CMake/VigraConfig.cmake
@ONLY IMMEDIATE)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/config/VigraConfigVersion.cmake.in
${PROJECT_BINARY_DIR}/lib/vigra/CMake/VigraConfigVersion.cmake
@ONLY IMMEDIATE)
# export targets:
INSTALL(EXPORT vigra-targets
DESTINATION lib${LIB_SUFFIX}/vigra)
INSTALL(FILES ${PROJECT_BINARY_DIR}/lib/vigra/CMake/VigraConfig.cmake
${PROJECT_BINARY_DIR}/lib/vigra/CMake/VigraConfigVersion.cmake
DESTINATION lib${LIB_SUFFIX}/vigra)
EXPORT(TARGETS vigraimpex FILE vigra-targets.cmake)
##################################################
#
# status output
#
##################################################
MESSAGE( STATUS "---------------------------------------------------------" )
MESSAGE( STATUS "VIGRA configuration information:" )
MESSAGE( STATUS "---------------------------------------------------------" )
IF(ZLIB_FOUND)
MESSAGE( STATUS " Using ZLIB libraries: ${ZLIB_LIBRARIES}" )
ELSE()
MESSAGE( STATUS " ZLIB libraries not found (ZLIB support disabled)" )
ENDIF()
IF(PNG_FOUND)
MESSAGE( STATUS " Using PNG libraries: ${PNG_LIBRARIES}" )
ELSE()
MESSAGE( STATUS " PNG libraries not found (PNG support disabled)" )
ENDIF()
IF(TIFF_FOUND)
MESSAGE( STATUS " Using TIFF libraries: ${TIFF_LIBRARIES}" )
ELSE()
MESSAGE( STATUS " TIFF libraries not found (TIFF support disabled)" )
ENDIF()
IF(JPEG_FOUND)
MESSAGE( STATUS " Using JPEG libraries: ${JPEG_LIBRARIES}" )
ELSE()
MESSAGE( STATUS " JPEG libraries not found (JPEG support disabled)" )
ENDIF()
IF(OPENEXR_FOUND)
MESSAGE( STATUS " Using OpenEXR libraries: ${OPENEXR_LIBRARIES}" )
ELSEIF(NOT WITH_OPENEXR)
MESSAGE( STATUS " OpenEXR disabled by user (WITH_OPENEXR=0)" )
ELSE()
MESSAGE( STATUS " OpenEXR libraries not found (OpenEXR support disabled)" )
ENDIF()
IF(FFTW3_FOUND)
MESSAGE( STATUS " Using FFTW libraries: ${FFTW3_LIBRARIES}" )
ELSE()
MESSAGE( STATUS " FFTW libraries not found (FFTW support disabled)" )
ENDIF()
IF(HDF5_FOUND)
MESSAGE( STATUS " Using HDF5 libraries: ${HDF5_LIBRARIES}" )
ELSEIF(NOT WITH_HDF5)
MESSAGE( STATUS " HDF5 disabled by user (WITH_HDF5=0)" )
ELSE()
MESSAGE( STATUS " HDF5 libraries not found (HDF5 support disabled)" )
ENDIF()
IF(Boost_FOUND)
MESSAGE( STATUS " Using Boost Graph Library: ${Boost_INCLUDE_DIR}/boost/graph" )
ELSEIF(NOT WITH_BOOST_GRAPH)
MESSAGE( STATUS " Boost Graph Library disabled by user (WITH_BOOST_GRAPH=0)" )
ELSE()
MESSAGE( STATUS " Boost Graph Library not found (support disabled)" )
ENDIF()
IF(LEMON_FOUND)
MESSAGE( STATUS " Using LEMON graph library: ${LEMON_LIBRARY}" )
ELSEIF(NOT WITH_LEMON)
MESSAGE( STATUS " LEMON graph library disabled by user (WITH_LEMON=0)" )
ELSE()
MESSAGE( STATUS " LEMON graph library not found (support disabled)" )
ENDIF()
IF(WITH_VIGRANUMPY)
IF(VIGRANUMPY_DEPENDENCIES_FOUND)
MESSAGE( STATUS " Using Python libraries: ${VIGRANUMPY_LIBRARIES}" )
MESSAGE( STATUS " Using Numpy includes: ${PYTHON_NUMPY_INCLUDE_DIR}" )
ELSE()
MESSAGE( STATUS " Vigranumpy dependencies not found (vigranumpy disabled)" )
ENDIF()
ELSE()
MESSAGE( STATUS " Vigranumpy disabled by user (WITH_VIGRANUMPY=0)" )
ENDIF()
MESSAGE( STATUS "---------------------------------------------------------" )
IF(VIGRA_STATIC_LIB)
MESSAGE( STATUS " building static lib" )
ELSE()
MESSAGE( STATUS " building shared lib" )
ENDIF()
MESSAGE( STATUS " binaries will be generated in: ${CMAKE_CURRENT_BINARY_DIR}")
IF(DOXYGEN_FOUND AND PYTHONINTERP_FOUND)
MESSAGE( STATUS " manuals will be generated in: ${DOCDIR}")
ENDIF()
MESSAGE( STATUS "---------------------------------------------------------" )
MESSAGE( STATUS " includes will be installed at: ${CMAKE_INSTALL_PREFIX}/include")
MESSAGE( STATUS " libraries will be installed at: ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
IF (MSVC)
MESSAGE( STATUS " binaries and DLLs will be installed at: ${CMAKE_INSTALL_PREFIX}/bin")
else()
MESSAGE( STATUS " binaries will be installed at: ${CMAKE_INSTALL_PREFIX}/bin")
endif()
IF(DOXYGEN_FOUND AND PYTHONINTERP_FOUND)
MESSAGE( STATUS " vigra manuals will be installed at: "
"${CMAKE_INSTALL_PREFIX}/${DOCINSTALL}/vigra/index.html")
ELSE()
MESSAGE( STATUS " vigra manuals cannot be generated (Doxygen or Python not found)")
ENDIF()
IF(WITH_VIGRANUMPY AND VIGRANUMPY_DEPENDENCIES_FOUND)
MESSAGE( STATUS " vigranumpy will be installed at ${CMAKE_INSTALL_PREFIX}/${VIGRANUMPY_INSTALL_DIR}" )
IF(PYTHON_SPHINX)
MESSAGE( STATUS " vigranumpy manuals will be installed at: "
"${CMAKE_INSTALL_PREFIX}/${DOCINSTALL}/vigranumpy/html/index.html")
ELSE(PYTHON_SPHINX)
MESSAGE( STATUS " vigranumpy manuals cannot be generated "
"(Sphinx missing)")
ENDIF(PYTHON_SPHINX)
ELSE()
MESSAGE( STATUS " vigranumpy will NOT be installed" )
ENDIF()
IF(NOT TIFF_FOUND OR NOT JPEG_FOUND OR NOT PNG_FOUND OR NOT FFTW3_FOUND OR
NOT HDF5_FOUND OR NOT VIGRANUMPY_DEPENDENCIES_FOUND)
MESSAGE( STATUS "" )
MESSAGE( STATUS "Consider setting DEPENDENCY_SEARCH_PREFIX to find missing libraries" )
ENDIF()
MESSAGE( STATUS "---------------------------------------------------------" )