forked from BIC-MNI/minc-toolkit-v2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
642 lines (515 loc) · 20.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
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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_FOUND})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_FOUND})
endif(CCACHE_FOUND)
project(minc-toolkit-v2 )
enable_language(C)
enable_language(CXX)
#enable_language(Fortran)
#Turn on PIC (and PIE if supported)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
cmake_minimum_required(VERSION 3.6.1)
IF(COMMAND CMAKE_POLICY)
IF(POLICY CMP0026)
CMAKE_POLICY(SET CMP0026 NEW)
ENDIF(POLICY CMP0026)
IF(POLICY CMP0046)
CMAKE_POLICY(SET CMP0046 OLD)
ENDIF(POLICY CMP0046)
if(POLICY CMP0083)
cmake_policy(SET CMP0083 NEW)
endif()
ENDIF(COMMAND CMAKE_POLICY)
SET(MINC_TOOLKIT_PACKAGE_VERSION_MAJOR 1)
SET(MINC_TOOLKIT_PACKAGE_VERSION_MINOR 9)
SET(MINC_TOOLKIT_PACKAGE_VERSION_PATCH 18)
SET(MINC_TOOLKIT_RELEASE_DATE "20201015")
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_GENERATOR DEB)
SET(CPACK_PACKAGE_NAME "minc-toolkit-v2")
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 )
message("Build type is not set, setting to Release!")
SET( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE )
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-v2)
# a hack to disable internal man pages per project
SET(DISABLE_MAN_PAGES_INSTALL ON)
INCLUDE(InstallManPages)
INCLUDE(DownloadPackage)
# 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)
# MAC OS X magick
SET(MACOSX_RPATH ON)
SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
SET(CMAKE_SKIP_RPATH OFF)
SET(CMAKE_SKIP_INSTALL_RPATH OFF)
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_NIFTI "Use System NIFTI " OFF)
#OPTION(USE_SYSTEM_GIFTI "Use System GIfTI" OFF)
OPTION(USE_SYSTEM_NETCDF "Use System NETCDF > 3.6.3" 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_FFTW3D "Use System FFTW3D " OFF)
OPTION(USE_SYSTEM_GLUT "Use System GLUT " ON)
OPTION(USE_SYSTEM_OPENJPEG "Use System OpenJPEG " OFF)
OPTION(USE_SYSTEM_JPEG "Use System JPEG " OFF)
OPTION(MT_BUILD_ITK_TOOLS "Build ITK-based tools" ON)
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" OFF)
OPTION(MT_BUILD_IM "Build ImageMagick and dependent libraries" OFF)
OPTION(MT_BUILD_OPENBLAS "Build OpenBLAS: will require fortran" OFF)
#OPTION(MT_USE_OPENMP_BLAS "Use Build OpenBLAS with OpenMP support" OFF) # TODO: finish this to compile on some platforms
SET(MT_PACKAGES_PATH "${CMAKE_BINARY_DIR}/cache" CACHE PATH "Directory containing 3rd party packages")
IF(MT_BUILD_LITE)
SET(MT_BUILD_ITK_TOOLS OFF)
SET(MT_BUILD_VISUAL_TOOLS OFF)
SET(MT_BUILD_ANTS OFF)
SET(MT_BUILD_C3D OFF)
SET(MT_BUILD_ELASTIX 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
# for superbuild
SET(USE_SUPERBUILD ON)
INCLUDE(ExternalProject)
INCLUDE(ConfigureExternalProjects)
SET(SUPERBUILD_STAGING_PREFIX ${CMAKE_BINARY_DIR}/external)
# Fix missing share directory
file(MAKE_DIRECTORY ${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/share)
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:${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/bin:$ENV{PATH}"
)
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:${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}:${CMAKE_CURRENT_BINARY_DIR}/libminc/ezminc:$ENV{DYLD_LIBRARY_PATH}")
ELSE(APLLE)
LIST(APPEND MINC_TEST_ENVIRONMENT "LD_LIBRARY_PATH=${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}:${CMAKE_CURRENT_BINARY_DIR}/libminc:${CMAKE_CURRENT_BINARY_DIR}/libminc/ezminc:$ENV{LD_LIBRARY_PATH}")
ENDIF(APPLE)
# required packages
FIND_PACKAGE( Perl REQUIRED )
# required for minc
IF(USE_SYSTEM_ZLIB)
FIND_PACKAGE( ZLIB REQUIRED )
ELSE()
INCLUDE(BuildZLIB)
build_zlib( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
# we should have ZLIB at this point
SET(HAVE_ZLIB ON)
ENDIF()
IF(USE_SYSTEM_NETCDF)
FIND_PACKAGE( NETCDF REQUIRED )
ELSE()
INCLUDE(BuildNETCDF)
build_netcdf( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF()
IF(USE_SYSTEM_HDF5)
IF(MT_BUILD_ITK_TOOLS)
# need to find more
FIND_PACKAGE(HDF5 REQUIRED COMPONENTS C CXX HL)
ELSE()
FIND_PACKAGE(HDF5 REQUIRED )
ENDIF()
#HACK to make FIND_PACKAGE adn build_hdf5 compatible
IF(NOT HDF5_LIBRARIES AND HDF5_LIBRARY)
SET(HDF5_LIBRARIES ${HDF5_LIBRARY})
ENDIF()
ELSE()
INCLUDE(BuildHDF5)
build_hdf5( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
IF(NOT USE_SYSTEM_ZLIB)
add_dependencies(HDF5 ZLIB)
ENDIF()
ENDIF()
IF(USE_SYSTEM_NIFTI)
FIND_PACKAGE(NIFTI REQUIRED)
ELSE()
INCLUDE(BuildNIFTI)
build_nifti( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
IF(NOT USE_SYSTEM_ZLIB)
add_dependencies(NIFTI ZLIB)
ENDIF()
ENDIF()
# 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)
# for minctools (dcm2mnc)
IF(USE_SYSTEM_OPENJPEG)
FIND_PACKAGE( OpenJPEG )
ELSE()
INCLUDE(BuildOpenJPEG)
build_openjpeg( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF()
IF(USE_SYSTEM_JPEG)
FIND_PACKAGE( JPEG )
ELSE()
INCLUDE(BuildJPEG)
build_jpeg( ${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF()
#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()
INCLUDE(BuildPCRE)
build_pcre(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF()
# required for mni_autoreg
INCLUDE(BuildLIBLBFGS)
build_liblbfgs(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
SET(MINC_TOOLKIT_BUILD ON)
SET(MINC_TOOLKIT_BUILD_DIR ${CMAKE_BINARY_DIR})
SET(MINC_TOOLKIT_INSTALL_DIR ${CMAKE_INSTALL_PREFIX})
#setup parameters
SET(LIBMINC_BUILD_V2 ON)
SET(LIBMINC_MINC1_SUPPORT ON)
SET(LIBMINC_NIFTI_SUPPORT OFF)
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)
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 AND MINC2_deps)
ADD_DEPENDENCIES(minc2_static ${MINC2_deps})
ENDIF(MT_BUILD_SHARED_LIBS AND MINC2_deps)
# 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)
IF(NOT USE_SYSTEM_OPENJPEG)
ADD_DEPENDENCIES(dcm2mnc OPENJPEG)
ENDIF(NOT USE_SYSTEM_OPENJPEG)
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)
IF( NOT USE_SYSTEM_PCRE)
ADD_DEPENDENCIES(oobicpl PCRE)
ENDIF( NOT USE_SYSTEM_PCRE)
#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_DEPENDENCIES(minctracc LIBLBFGS)
ADD_DEPENDENCIES(mni_autoreg LIBLBFGS)
ADD_DEPENDENCIES(mni_autoreg mincresample)
ADD_SUBDIRECTORY(inormalize)
ADD_SUBDIRECTORY(mrisim)
ADD_SUBDIRECTORY(bic-pipelines)
ADD_SUBDIRECTORY(perl-modules)
ADD_SUBDIRECTORY(minc_gco)
IF(MT_BUILD_OPENBLAS)
enable_language(Fortran)
INCLUDE(BuildOpenBLAS)
build_open_blas(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${MT_USE_OPENMP})
ENDIF(MT_BUILD_OPENBLAS)
#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)
INCLUDE(FindFFTW3F)
FIND_PACKAGE(FFTW3F)
ELSE()
INCLUDE(BuildFFTW3F)
build_fftw3f(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF()
IF(USE_SYSTEM_FFTW3D)
INCLUDE(FindFFTW3)
FIND_PACKAGE(FFTW3)
ELSE(USE_SYSTEM_FFTW3D)
INCLUDE(BuildFFTW3D)
build_fftw3d(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ENDIF(USE_SYSTEM_FFTW3D)
# build tools that require ITK
IF(MT_BUILD_ITK_TOOLS)
OPTION(MT_BUILD_ANTS "Build ANTS " ON)
OPTION(MT_BUILD_C3D "Build convert3D " ON)
OPTION(MT_BUILD_ELASTIX "Build Elastix " ON)
OPTION(MT_BUILD_ABC "Build ABC " OFF)
IF(USE_SYSTEM_ITK)
FIND_PACKAGE(ITK)
ELSE(USE_SYSTEM_ITK)
OPTION(USE_SYSTEM_EXPAT_ITK "Use System expat for ITKv4 " OFF)
IF(USE_SYSTEM_EXPAT_ITK)
FIND_PACKAGE(EXPAT REQUIRED)
ENDIF()
INCLUDE(BuildITKv4)
build_itkv4(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${CMAKE_BINARY_DIR}/libminc)
# Setting dependecies
ADD_DEPENDENCIES(ITKv4 minc2 )
IF(NOT USE_SYSTEM_ZLIB)
ADD_DEPENDENCIES(ITKv4 ZLIB)
ENDIF()
IF(NOT USE_SYSTEM_FFTW3D)
ADD_DEPENDENCIES(ITKv4 FFTW3D)
ENDIF()
IF(NOT USE_SYSTEM_FFTW3F)
ADD_DEPENDENCIES(ITKv4 FFTW3F)
ENDIF()
ENDIF(USE_SYSTEM_ITK)
IF(MT_BUILD_ANTS)
INCLUDE(BuildANTS)
#INCLUDE(BuildBOOST)
#build_BOOST(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
build_ANTS(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${ITK_DIR} ) #${BOOST_DIR}
ADD_DEPENDENCIES(ANTS ITKv4 minc2 ) #BOOST
ENDIF(MT_BUILD_ANTS)
IF(MT_BUILD_C3D)
INCLUDE(BuildC3D)
build_C3D(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${ITK_DIR})
ADD_DEPENDENCIES(C3D ITKv4 minc2)
ENDIF(MT_BUILD_C3D)
IF(MT_BUILD_ELASTIX)
INCLUDE(BuildElastix)
build_Elastix(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${ITK_DIR})
ADD_DEPENDENCIES(Elastix ITKv4 minc2)
ENDIF(MT_BUILD_ELASTIX)
INCLUDE(BuildEZMINC)
build_EZMINC(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${CMAKE_BINARY_DIR}/libminc ${CMAKE_BINARY_DIR}/bicpl ${ITK_DIR})
ADD_DEPENDENCIES(EZMINC ITKv4 GSL minc2 minc_io bicpl)
INCLUDE(BuildPatchMorphology)
build_PatchMorphology(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${ITK_DIR})
ADD_DEPENDENCIES(patch_morphology ITKv4 minc_io)
IF(MT_BUILD_OPENBLAS)
ADD_DEPENDENCIES(patch_morphology OpenBLAS)
ENDIF(MT_BUILD_OPENBLAS)
IF(MT_BUILD_ABC)
INCLUDE(BuildABC)
build_ABC(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${ITK_DIR})
ADD_DEPENDENCIES(ABC ITKv4 minc2)
ENDIF(MT_BUILD_ABC)
ENDIF(MT_BUILD_ITK_TOOLS)
# tools requiring OpenBLAS
INCLUDE(BuildBEAST)
build_BEAST(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
ADD_DEPENDENCIES(BEAST minc_io)
IF(MT_BUILD_OPENBLAS)
ADD_DEPENDENCIES(BEAST OpenBLAS)
ELSE()
FIND_PACKAGE(OpenBLAS )
ENDIF()
# 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 build_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)
ADD_SUBDIRECTORY(ray_trace)
ADD_SUBDIRECTORY(Display)
ADD_SUBDIRECTORY(Register)
ADD_SUBDIRECTORY(ILT)
IF(NOT USE_SYSTEM_GLUT)
ADD_DEPENDENCIES(register FREEGLUT)
ADD_DEPENDENCIES(Display FREEGLUT)
ENDIF(NOT USE_SYSTEM_GLUT)
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 )
ADD_DEPENDENCIES(Display bicgl minc2 bicpl )
ADD_DEPENDENCIES(register bicgl minc2 bicpl )
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)
IF(MT_BUILD_IM)
message("Building minimal imagemagick, use with caution!")
INCLUDE(BuildJPEG)
INCLUDE(BuildPNG)
INCLUDE(BuildFREETYPE)
INCLUDE(BuildIM)
build_jpeg(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX})
build_png(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARY} ${ZLIB_DIR} )
build_freetype(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARY} ${ZLIB_DIR})
build_im(${CMAKE_INSTALL_PREFIX} ${SUPERBUILD_STAGING_PREFIX} ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARY} ${ZLIB_DIR})
ADD_DEPENDENCIES(FREETYPE PNG)
ADD_DEPENDENCIES(IM FREETYPE PNG JPEG)
ENDIF(MT_BUILD_IM)
#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 .)
# share can be created by some packages
INSTALL(DIRECTORY ${SUPERBUILD_STAGING_PREFIX}/${CMAKE_INSTALL_PREFIX}/share
DESTINATION .)
ADD_SUBDIRECTORY(man-pages)
# 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)