-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
501 lines (409 loc) · 17.1 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
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
project(minc-toolkit)
enable_language(C)
enable_language(CXX)
cmake_minimum_required(VERSION 2.8)
SET(MINC_TOOLKIT_PACKAGE_VERSION_MAJOR 1)
SET(MINC_TOOLKIT_PACKAGE_VERSION_MINOR 0)
SET(MINC_TOOLKIT_PACKAGE_VERSION_PATCH 09)
SET(MINC_TOOLKIT_RELEASE_DATE "20170529")
SET(MINC_TOOLKIT_VERSION_FULL "${MINC_TOOLKIT_PACKAGE_VERSION_MAJOR}.${MINC_TOOLKIT_PACKAGE_VERSION_MINOR}.${MINC_TOOLKIT_PACKAGE_VERSION_PATCH}-${MINC_TOOLKIT_RELEASE_DATE}")
SET(CPACK_PACKAGE_NAME "minc-toolkit")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "minc image processing toolkit")
SET(CPACK_PACKAGE_VENDOR "Brain Imaging Center, Montreal Neurological Institute, McGill University")
SET(CPACK_PACKAGE_VERSION_MAJOR ${MINC_TOOLKIT_PACKAGE_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${MINC_TOOLKIT_PACKAGE_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${MINC_TOOLKIT_PACKAGE_VERSION_PATCH})
SET(CPACK_PACKAGE_CONTACT "Vladimir Fonov <[email protected]>")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "minc-toolkit-${MINC_TOOLKIT_VERSION_FULL}")
SET(CPACK_MONOLITHIC_INSTALL ON)
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt")
SET(CPACK_PACKAGE_RELOCATABLE OFF)
#IF (CMAKE_SYSTEM_PROCESSOR MATCHES "unknown")
EXEC_PROGRAM(uname ARGS "-m" OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
#ENDIF (CMAKE_SYSTEM_PROCESSOR MATCHES "unknown")
IF(NOT DEFINED CPACK_SYSTEM_NAME)
SET(MT_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
ENDIF(NOT DEFINED CPACK_SYSTEM_NAME)
IF(${CMAKE_SYSTEM_NAME} MATCHES Windows)
IF(CMAKE_CL_64)
SET(MT_SYSTEM_NAME win64-${CMAKE_SYSTEM_PROCESSOR})
ELSE(CMAKE_CL_64)
SET(MT_SYSTEM_NAME win32-${CMAKE_SYSTEM_PROCESSOR})
ENDIF(CMAKE_CL_64)
ELSE(${CMAKE_SYSTEM_NAME} MATCHES Windows)
IF(${CMAKE_SYSTEM_NAME} MATCHES Linux )
EXEC_PROGRAM(lsb_release ARGS "-s -i" OUTPUT_VARIABLE SYSTEM_ID)
EXEC_PROGRAM(lsb_release ARGS "-s -r" OUTPUT_VARIABLE SYSTEM_RELEASE)
SET(MT_SYSTEM_NAME "${SYSTEM_ID}_${SYSTEM_RELEASE}-${CMAKE_SYSTEM_PROCESSOR}")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES Linux )
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES Windows)
IF( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Release )
ENDIF()
SET(CPACK_PACKAGE_FILE_NAME "minc-toolkit-${MINC_TOOLKIT_VERSION_FULL}-${MT_SYSTEM_NAME}")
# register local modules
SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake-modules")
INCLUDE(PreventInSourceBuilds)
AssureOutOfSourceBuilds(minc-toolkit)
INCLUDE(InstallManPages)
# default install directories
SET(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Install path prefix, prepended onto install directories.")
SET(CPACK_SET_DESTDIR ON)
SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
SET(CPACK_STRIP_FILES ON)
# RPATH magick
#SET(MACOSX_RPATH ON)
SET(CMAKE_SKIP_RPATH OFF)
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_SKIP_INSTALL_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
# superbuild options
OPTION(MT_BUILD_LITE "Build lite version of minc-toolkit, without ITK or visual tools" OFF)
OPTION(MT_BUILD_SHARED_LIBS "Build shared libraries." OFF)
OPTION(USE_SYSTEM_ZLIB "Use System ZLIB " OFF)
OPTION(USE_SYSTEM_NETCDF "Use System NETCDF > 3.6.3" OFF)
#OPTION(USE_SYSTEM_NIFTI "Use System NIfTI 1.0" OFF)
#OPTION(USE_SYSTEM_GIFTI "Use System GIfTI" OFF)
OPTION(USE_SYSTEM_HDF5 "Use System HDF5 > 1.8" OFF)
OPTION(USE_SYSTEM_PCRE "Use System PCRE " OFF)
OPTION(USE_SYSTEM_GSL "Use System GSL " OFF)
OPTION(USE_SYSTEM_FFTW3F "Use System FFTW3F " OFF)
OPTION(USE_SYSTEM_GLUT "Use System GLUT " ON)
OPTION(MT_BUILD_ITK_TOOLS "Build ITK-based tools" OFF)
OPTION(MT_BUILD_VISUAL_TOOLS "Build visual tools (Display, Register, postf, ray_trace) requires OpenGL & Glut" OFF)
OPTION(USE_SYSTEM_ITK "Use System ITK" OFF)
OPTION(MT_USE_OPENMP "Use OpenMP multi-threading, right now applies only to FFTW" OFF)
OPTION(MNI_AUTOREG_OLD_AMOEBA_INIT "Use old-style (asymmetric) amoeba init in mni_autoreg" ON)
IF(MT_BUILD_LITE)
SET(MT_BUILD_ITK_TOOLS OFF)
SET(MT_BUILD_VISUAL_TOOLS OFF)
SET(MT_BUILD_MINC_ANTS OFF)
SET(MT_BUILD_C3D OFF)
SET(CPACK_PACKAGE_FILE_NAME "minc-toolkit-${MINC_TOOLKIT_VERSION_FULL}-${MT_SYSTEM_NAME}-lite")
ENDIF(MT_BUILD_LITE)
ENABLE_TESTING()
INCLUDE(CTest)
# provide test environement
# CACHE INTERNAL FORCE
SET(MINC_TEST_ENVIRONMENT
"PATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_BINARY_DIR}/N3:${CMAKE_CURRENT_BINARY_DIR}/classify:${CMAKE_CURRENT_BINARY_DIR}/minctools/progs:${CMAKE_CURRENT_BINARY_DIR}/mni_autoreg/mincblur:${CMAKE_CURRENT_BINARY_DIR}/mni_autoreg/make_phantom:${CMAKE_CURRENT_BINARY_DIR}/mni_autoreg/minctracc:$ENV{PATH};PERL5LIB=${CMAKE_SOURCE_DIR}/mni-perllib:${CMAKE_CURRENT_BINARY_DIR}/mni-perllib/perl:${CMAKE_CURRENT_BINARY_DIR}/perl-modules:$ENV{PERL5LIB}"
)
LIST(APPEND MINC_TEST_ENVIRONMENT "PERL5LIB=${CMAKE_SOURCE_DIR}/mni-perllib:${CMAKE_CURRENT_BINARY_DIR}/mni-perllib/perl:${CMAKE_CURRENT_BINARY_DIR}/perl-modules:$ENV{PERL5LIB}")
IF(APPLE)
# LIST(APPEND MINC_TEST_ENVIRONMENT "DYLD_LIBRARY_PATH=${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}:${CMAKE_CURRENT_BINARY_DIR}/libminc:$ENV{DYLD_LIBRARY_PATH}")
ELSE(APPLE)
# LIST(APPEND MINC_TEST_ENVIRONMENT "LD_LIBRARY_PATH=${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}:${CMAKE_CURRENT_BINARY_DIR}/libminc:$ENV{DYLD_LIBRARY_PATH}")
ENDIF(APPLE)
# for superbuild
SET(USE_SUPERBUILD ON)
INCLUDE(ExternalProject)
INCLUDE(ConfigureExternalProjects)
SET(SUPERBUILD_STAGING_PREFIX ${CMAKE_BINARY_DIR}/external)
# required packages
FIND_PACKAGE( Perl REQUIRED )
# required for minc
IF(USE_SYSTEM_ZLIB)
FIND_PACKAGE( ZLIB REQUIRED )
ELSE(USE_SYSTEM_ZLIB)
INCLUDE(BuildZLIB)
build_zlib( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF(USE_SYSTEM_ZLIB)
IF(USE_SYSTEM_NETCDF)
FIND_PACKAGE( NETCDF REQUIRED )
ELSE(USE_SYSTEM_NETCDF)
INCLUDE(BuildNETCDF)
build_netcdf( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF(USE_SYSTEM_NETCDF)
IF(USE_SYSTEM_NIFTI)
FIND_PACKAGE(NIFTI OPTIONAL)
ELSE(USE_SYSTEM_NIFTI)
INCLUDE(BuildNIFTI)
build_nifti( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
IF(NOT USE_SYSTEM_ZLIB)
add_dependencies(NIFTI ZLIB)
ENDIF(NOT USE_SYSTEM_ZLIB)
ENDIF(USE_SYSTEM_NIFTI)
# IF(USE_SYSTEM_GIFTI)
# FIND_PACKAGE( GIFTI OPTIONAL )
# ELSE(USE_SYSTEM_GIFTI)
# INCLUDE(BuildGIFTI)
# build_gifti( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
# IF(NOT USE_SYSTEM_NIFTI)
# add_dependencies(GIFTI NIFTI)
# ENDIF(NOT USE_SYSTEM_NIFTI)
# ENDIF(USE_SYSTEM_GIFTI)
IF(USE_SYSTEM_HDF5)
FIND_PACKAGE( HDF5 REQUIRED )
ELSE(USE_SYSTEM_HDF5)
INCLUDE(BuildHDF5)
build_hdf5( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARY})
IF(NOT USE_SYSTEM_ZLIB)
add_dependencies(HDF5 ZLIB)
ENDIF(NOT USE_SYSTEM_ZLIB)
ENDIF(USE_SYSTEM_HDF5)
#required for some minc tools
FIND_PACKAGE( BISON )
FIND_PACKAGE( FLEX )
FIND_PACKAGE( Threads)
#required for bicpl
IF(USE_SYSTEM_NETPBM) # else we will use bundled libppm
FIND_PACKAGE( NETPBM QUIET )
ENDIF(USE_SYSTEM_NETPBM)
#required for oobicpl
IF(USE_SYSTEM_PCRE)
FIND_PACKAGE( PCRE QUIET )
ELSE(USE_SYSTEM_PCRE)
INCLUDE(BuildPCRE)
build_pcre(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF(USE_SYSTEM_PCRE)
SET(MINC_TOOLKIT_BUILD ON)
SET(MINC_TOOLKIT_BUILD_DIR ${CMAKE_BINARY_DIR})
SET(MINC_TOOLKIT_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
#setup parameters
#MINC2
SET(LIBMINC_BUILD_V2 ON)
SET(LIBMINC_MINC1_SUPPORT ON)
SET(LIBMINC_FOUND ON)
SET(LIBMINC_BUILD_TOOLS ON)
SET(LIBMINC_BUILD_CONVERTERS ON)
SET(LIBMINC_BUILD_EZMINC ON)
SET(LIBMINC_BUILD_EZMINC_EXAMPLES ON)
SET(LIBMINC_INSTALL_BIN_DIR bin)
SET(LIBMINC_INSTALL_LIB_DIR lib${LIB_SUFFIX})
SET(LIBMINC_INSTALL_INCLUDE_DIR include)
SET(LIBMINC_INSTALL_DATA_DIR share)
SET(LIBMINC_INTEGRATE_VOLUME_IO OFF)
SET(LIBMINC_EXPORTED_TARGETS "LIBMINC-targets")
# we have both MINC1 API
SET(HAVE_MINC1 ON)
# and MINC2 API
SET(HAVE_MINC2 ON)
# one way or another, we have libz, a.k.a. zlib.
SET(HAVE_ZLIB ON)
IF(MT_BUILD_SHARED_LIBS)
SET(LIBMINC_BUILD_SHARED_LIBS ON)
#EBTKS
SET(EBTKS_BUILD_SHARED_LIBS ON)
#bicpl
SET(BICPL_BUILD_SHARED_LIBS ON)
#oobicpl
SET(OOBICPL_BUILD_SHARED_LIBS ON)
#arguments
SET(ARGUMENTS_BUILD_SHARED_LIBS ON)
#bicgl
SET(BICGL_BUILD_SHARED_LIBS OFF)
ELSE(MT_BUILD_SHARED_LIBS)
SET(LIBMINC_BUILD_SHARED_LIBS OFF)
#EBTKS
SET(EBTKS_BUILD_SHARED_LIBS OFF)
#bicpl
SET(BICPL_BUILD_SHARED_LIBS OFF)
#oobicpl
SET(OOBICPL_BUILD_SHARED_LIBS OFF)
#arguments
SET(ARGUMENTS_BUILD_SHARED_LIBS OFF)
#bicgl
SET(BICGL_BUILD_SHARED_LIBS OFF)
ENDIF(MT_BUILD_SHARED_LIBS)
#EZMINC
SET(EZMINC_BUILD_MINCNLM ON)
SET(EZMINC_BUILD_DISTORTION_CORRECTION ON)
SET(EZMINC_BUILD_MRFSEG ON)
SET(EZMINC_BUILD_DD ON)
SET(EZMINC_BUILD_TOOLS ON)
ADD_SUBDIRECTORY(libminc)
SET(MINC2_deps "")
IF(NOT USE_SYSTEM_NETCDF)
SET(MINC2_deps ${MINC2_deps} NETCDF)
ENDIF(NOT USE_SYSTEM_NETCDF)
IF(NOT USE_SYSTEM_HDF5)
SET(MINC2_deps ${MINC2_deps} HDF5)
ENDIF(NOT USE_SYSTEM_HDF5)
IF(NOT USE_SYSTEM_NIFTI)
SET(MINC2_deps ${MINC2_deps} NIFTI)
ENDIF(NOT USE_SYSTEM_NIFTI)
# IF(NOT USE_SYSTEM_GIFTI)
# SET(MINC2_deps ${MINC2_deps} GIFTI)
# ENDIF(NOT USE_SYSTEM_GIFTI)
IF(MINC2_deps)
ADD_DEPENDENCIES(minc2 ${MINC2_deps})
ENDIF(MINC2_deps)
IF(MT_BUILD_SHARED_LIBS)
IF(MINC2_deps)
ADD_DEPENDENCIES(minc2_static ${MINC2_deps})
ENDIF(MINC2_deps)
ENDIF(MT_BUILD_SHARED_LIBS)
# Setup main minc variables
SET(LIBMINC_USE_FILE ${CMAKE_BINARY_DIR}/libminc/UseLIBMINC.cmake CACHE INTERNAL "LIBMINC use file")
INCLUDE(${CMAKE_BINARY_DIR}/libminc/LIBMINCConfig.cmake)
INCLUDE(${LIBMINC_USE_FILE})
ADD_SUBDIRECTORY(minctools)
ADD_SUBDIRECTORY(minc-widgets)
ADD_SUBDIRECTORY(EBTKS)
ADD_DEPENDENCIES(EBTKS minc2)
# setup EBTKS variables
SET(EBTKS_USE_FILE ${CMAKE_BINARY_DIR}/EBTKS/UseEBTKS.cmake CACHE INTERNAL "EBTKS use file")
INCLUDE(${CMAKE_BINARY_DIR}/EBTKS/EBTKSConfig.cmake)
INCLUDE(${EBTKS_USE_FILE})
ADD_SUBDIRECTORY(bicpl)
#setup bicpl variables
SET(BICPL_USE_FILE ${CMAKE_BINARY_DIR}/bicpl/UseBICPL.cmake CACHE INTERNAL "BICPL use file")
INCLUDE(${CMAKE_BINARY_DIR}/bicpl/BICPLConfig.cmake)
INCLUDE(${BICPL_USE_FILE})
ADD_DEPENDENCIES(bicpl minc2)
ADD_SUBDIRECTORY(arguments)
#setup arguments variables
SET(ARGUMENTS_USE_FILE ${CMAKE_BINARY_DIR}/bicpl/UseARGUMENTS.cmake CACHE INTERNAL "ARGUMENTS use file")
INCLUDE(${CMAKE_BINARY_DIR}/arguments/ARGUMENTSConfig.cmake)
INCLUDE(${ARGUMENTS_USE_FILE})
ADD_SUBDIRECTORY(oobicpl)
ADD_DEPENDENCIES(oobicpl minc2 bicpl arguments)
#setup oobicpl variables
SET(OOBICPL_USE_FILE ${CMAKE_BINARY_DIR}/bicpl/UseOOBICPL.cmake CACHE INTERNAL "OOBICPL use file")
INCLUDE(${CMAKE_BINARY_DIR}/oobicpl/OOBICPLConfig.cmake)
INCLUDE(${OOBICPL_USE_FILE})
ADD_SUBDIRECTORY(BEaST)
#ADD_SUBDIRECTORY(BEaST_library)
ADD_SUBDIRECTORY(conglomerate)
ADD_SUBDIRECTORY(classify)
ADD_SUBDIRECTORY(mni-perllib)
ADD_SUBDIRECTORY(N3)
ADD_SUBDIRECTORY(glim_image)
ADD_SUBDIRECTORY(mni_autoreg)
ADD_SUBDIRECTORY(inormalize)
ADD_SUBDIRECTORY(mrisim)
ADD_SUBDIRECTORY(bic-pipelines)
ADD_SUBDIRECTORY(perl-modules)
ADD_SUBDIRECTORY(ILT)
#required for EZminc
IF(USE_SYSTEM_GSL)
FIND_PACKAGE(GSL)
ELSE(USE_SYSTEM_GSL)
INCLUDE(BuildGSL)
build_gsl(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF(USE_SYSTEM_GSL)
IF(USE_SYSTEM_FFTW3F)
FIND_PACKAGE(FFTW3F)
ELSE(USE_SYSTEM_FFTW3)
INCLUDE(BuildFFTW3F)
build_fftw3f(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF(USE_SYSTEM_FFTW3F)
# build tools that require ITK
IF(MT_BUILD_ITK_TOOLS)
OPTION(MT_BUILD_MINC_ANTS "Build mincANTS " OFF)
OPTION(MT_BUILD_C3D "Build convert3D " OFF)
SET(HAVE_MINC4ITK ON)
#required for minc4itk & EZminc
IF(USE_SYSTEM_ITK)
FIND_PACKAGE(ITK )
ELSE(USE_SYSTEM_ITK)
INCLUDE(BuildITKv3)
build_itkv3(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} )
ENDIF(USE_SYSTEM_ITK)
# minc4itk integration library
ADD_SUBDIRECTORY(minc4itk)
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/minc4itk/MINC4ITKConfig.cmake)
# setup minc4itk variables
SET(MINC4ITK_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/minc4itk/include)
SET(MINC4ITK_LIBRARY_DIRS ${CMAKE_BINARY_DIR}/minc4itk/)
SET(ITKIOMINC_deps minc2)
IF(NOT USE_SYSTEM_ITK)
SET(ITKIOMINC_deps ${ITKIOMINC_deps} ITKv3)
ENDIF(NOT USE_SYSTEM_ITK)
ADD_DEPENDENCIES(ITKIOMINC ${ITKIOMINC_deps})
IF(MT_BUILD_MINC_ANTS)
INCLUDE(BuildANTS)
build_ANTS(${CMAKE_SOURCE_DIR}/mincANTS ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ADD_DEPENDENCIES(ANTS ITKv3 ITKIOMINC minc2)
ENDIF(MT_BUILD_MINC_ANTS)
IF(MT_BUILD_C3D)
#ADD_SUBDIRECTORY(c3d)
#ADD_DEPENDENCIES(c3d ITKIOMINC minc2)
#ADD_DEPENDENCIES(c2d ITKIOMINC minc2)
INCLUDE(BuildC3D)
build_C3D(${CMAKE_SOURCE_DIR}/c3d ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ADD_DEPENDENCIES(C3D ITKv3 ITKIOMINC minc2)
ENDIF(MT_BUILD_C3D)
IF(NOT USE_SYSTEM_ITK)
ADD_DEPENDENCIES(ITKIOMINC ITKv3)
ENDIF(NOT USE_SYSTEM_ITK)
ENDIF(MT_BUILD_ITK_TOOLS)
SET(minc_image_proc_deps minc2)
IF(NOT USE_SYSTEM_GSL)
SET(minc_image_proc_deps ${minc_image_proc_deps} GSL)
ENDIF(NOT USE_SYSTEM_GSL)
IF(NOT USE_SYSTEM_FFTW3F)
SET(minc_image_proc_deps ${minc_image_proc_deps} FFTW3F)
ENDIF(NOT USE_SYSTEM_FFTW3F)
ADD_SUBDIRECTORY(EZminc)
ADD_DEPENDENCIES(mincnlm minc2)
ADD_DEPENDENCIES(mrfseg minc2)
ADD_DEPENDENCIES(mrflib minc2)
ADD_DEPENDENCIES(minc_image_proc ${minc_image_proc_deps})
# build tools that require OpenGL and GLUT
IF(MT_BUILD_VISUAL_TOOLS)
FIND_PACKAGE( OpenGL REQUIRED )
FIND_PACKAGE( X11 QUIET )
IF(USE_SYSTEM_GLUT)
FIND_PACKAGE( GLUT REQUIRED )
ELSE(USE_SYSTEM_GLUT)
INCLUDE(BuildFREEGLUT) # newer version of freeglut seem to be causing problems
build_freeglut( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF(USE_SYSTEM_GLUT)
ADD_SUBDIRECTORY(bicgl)
INCLUDE(${CMAKE_BINARY_DIR}/bicgl/BICGLConfig.cmake)
#INCLUDE(BuildBICGL)
#build_bicgl( ${CMAKE_CURRENT_SOURCE_DIR}/bicgl ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ADD_SUBDIRECTORY(ray_trace)
ADD_SUBDIRECTORY(Display)
ADD_SUBDIRECTORY(Register)
IF(MT_BUILD_SHARED_LIBS)
ADD_DEPENDENCIES(ray_trace bicgl minc2_static bicpl_static)
ADD_DEPENDENCIES(Display bicgl minc2_static bicpl_static)
ADD_DEPENDENCIES(register bicgl minc2_static bicpl_static)
ELSE(MT_BUILD_SHARED_LIBS)
ADD_DEPENDENCIES(ray_trace bicgl minc2 bicpl minc2_static bicpl_static)
ADD_DEPENDENCIES(Display bicgl minc2 bicpl minc2_static bicpl_static)
ADD_DEPENDENCIES(register bicgl minc2 bicpl minc2_static bicpl_static)
ENDIF(MT_BUILD_SHARED_LIBS)
IF(X11_FOUND)
ADD_SUBDIRECTORY(postf)
ADD_DEPENDENCIES(postf minc2)
ADD_SUBDIRECTORY(xdisp)
ADD_DEPENDENCIES(xdisp minc2)
ENDIF(X11_FOUND)
ENDIF(MT_BUILD_VISUAL_TOOLS)
# DO nothing?
IF(USE_SUPERBUILD)
#install external dependencies to final destination
INSTALL(DIRECTORY ${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/bin
DESTINATION .
PATTERN *
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE )
INSTALL(DIRECTORY ${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}
DESTINATION .)
INSTALL(DIRECTORY ${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/include
DESTINATION .)
# do we really need to install share?
INSTALL(DIRECTORY ${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/share
DESTINATION .)
ENDIF(USE_SUPERBUILD)
# write configuration information
IF(UNIX)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/minc-toolkit-config.unix.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/minc-toolkit-config.sh @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/minc-toolkit-config.unix.csh.cmake ${CMAKE_CURRENT_BINARY_DIR}/minc-toolkit-config.csh @ONLY)
ENDIF(UNIX)
IF(APPLE)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/minc-toolkit-config.apple.sh.cmake ${CMAKE_CURRENT_BINARY_DIR}/minc-toolkit-config.sh @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/minc-toolkit-config.apple.csh.cmake ${CMAKE_CURRENT_BINARY_DIR}/minc-toolkit-config.csh @ONLY)
ENDIF(APPLE)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/minc-toolkit-config.sh ${CMAKE_CURRENT_BINARY_DIR}/minc-toolkit-config.csh DESTINATION .)
# setup additional variables for making Debian package
INCLUDE(DebianPackageAddons)
# setup additional variables for making RPM package
INCLUDE(RPMPackageAddons)
# according to http://www.cmake.org/pipermail/cmake/2011-November/047137.html it's better to put this in the end
INCLUDE(CPack)