forked from InsightSoftwareConsortium/ITK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
629 lines (535 loc) · 23.2 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
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
if(WIN32 OR NOT EXISTS /dev/urandom)
cmake_minimum_required(VERSION 2.8.5)
endif()
project(ITK)
if( WIN32 )
string( LENGTH "${CMAKE_CURRENT_SOURCE_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"ITK source code directory path length is too long (${n} > 50)."
"Please move the ITK source code directory to a directory with a shorter path."
)
endif()
string( LENGTH "${CMAKE_CURRENT_BINARY_DIR}" n )
if( n GREATER 50 )
message(
FATAL_ERROR
"ITK build directory path length is too long (${n} > 50)."
"Please set the ITK build directory to a directory with a shorter path."
)
endif()
endif()
set(CMAKE_MODULE_PATH ${ITK_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH})
include(PreventInSourceBuilds)
include(PreventInBuildInstalls)
include(ITKModuleMacros)
include(ITKExternalData)
include(itkCheckSourceTree)
set(main_project_name ${_ITKModuleMacros_DEFAULT_LABEL})
#-----------------------------------------------------------------------------
# ITK version number.
set(ITK_VERSION_MAJOR "4")
set(ITK_VERSION_MINOR "1")
set(ITK_VERSION_PATCH "0")
if(NOT ITK_INSTALL_RUNTIME_DIR)
set(ITK_INSTALL_RUNTIME_DIR bin)
endif()
if(NOT ITK_INSTALL_LIBRARY_DIR)
set(ITK_INSTALL_LIBRARY_DIR lib)
endif()
if(NOT ITK_INSTALL_ARCHIVE_DIR)
set(ITK_INSTALL_ARCHIVE_DIR lib)
endif()
if(NOT ITK_INSTALL_INCLUDE_DIR)
set(ITK_INSTALL_INCLUDE_DIR include/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR})
endif()
if(NOT ITK_INSTALL_DATA_DIR)
set(ITK_INSTALL_DATA_DIR share/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR})
endif()
if(NOT ITK_INSTALL_DOC_DIR)
set(ITK_INSTALL_DOC_DIR share/doc/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR})
endif()
if(NOT ITK_INSTALL_PACKAGE_DIR)
set(ITK_INSTALL_PACKAGE_DIR "lib/cmake/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}")
endif()
# Override CMake's built-in add_* commands: assign LABELS to tests and targets
# automatically. Depends on the CMake variable itk-module being set to the
# "current" module when add_* is called.
macro(verify_itk_module_is_set)
if("" STREQUAL "${itk-module}")
message(FATAL_ERROR "CMake variable itk-module is not set")
endif()
endmacro()
#-----------------------------------------------------------------------------
# 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' as 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()
#-----------------------------------------------------------------------------
# Enable runinng cppcheck for each module on its source and test directories.
option(ITK_CPPCHECK_TEST "Run cppcheck for static code analysis" OFF)
mark_as_advanced(ITK_CPPCHECK_TEST)
#-----------------------------------------------------------------------------
# Default values for CMake options may vary based on whether it's a
# dashboard build or not:
#
if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "")
# developer build
set(ITK_BUILD_ALL_MODULES_DEFAULT ON)
set(BUILD_EXAMPLES_DEFAULT ON)
else()
# dashboard build
set(ITK_BUILD_ALL_MODULES_DEFAULT ON)
set(BUILD_EXAMPLES_DEFAULT ON)
endif()
#-----------------------------------------------------------------------------
# Enable the download and use of BrainWeb datasets.
# When this data is available, additional 3D tests are enabled.
option(ITK_USE_BRAINWEB_DATA "Download and use BrainWeb data for advanced testing" OFF)
mark_as_advanced(ITK_USE_BRAINWEB_DATA)
#-----------------------------------------------------------------------------
# ITK wrapper for add_test that automatically sets the test's LABELS property
# to the value of its containing module.
#
function(itk_add_test)
# Add tests with data in the ITKData group.
ExternalData_add_test(ITKData ${ARGN})
if("NAME" STREQUAL "${ARGV0}")
set(_iat_testname ${ARGV1})
else()
set(_iat_testname ${ARGV0})
endif()
if(itk-module)
set(_label ${itk-module})
if(TARGET ${itk-module}-all AND "${ARGN}" MATCHES "DATA{")
add_dependencies(${itk-module}-all ITKData)
endif()
else()
set(_label ${main_project_name})
endif()
set_property(TEST ${_iat_testname} PROPERTY LABELS ${_label})
endfunction()
#-----------------------------------------------------------------------------
# ITK build configuration options.
option(BUILD_SHARED_LIBS "Build ITK with shared libraries." OFF)
set(ITK_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
include(ITKSetStandardCompilerFlags)
#---------------------------------------------------------------
# run try compiles and tests for ITK
include(itkTestFriendTemplatedFunction)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ITK_REQUIRED_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ITK_REQUIRED_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ITK_REQUIRED_LINK_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${ITK_REQUIRED_LINK_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${ITK_REQUIRED_LINK_FLAGS}")
include(CTest)
include( CppcheckTargets )
# Setup build locations.
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ITK_BINARY_DIR}/bin)
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ITK_BINARY_DIR}/lib)
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ITK_BINARY_DIR}/lib)
endif()
set(ITK_MODULES_DIR "${ITK_BINARY_DIR}/${ITK_INSTALL_PACKAGE_DIR}/Modules")
#-----------------------------------------------------------------------------
# Provide compatibility options.
option(ITKV3_COMPATIBILITY "Enable compatibility with ITK3.x when possible." OFF)
option(ITK_LEGACY_REMOVE "Remove all legacy code completely." OFF)
option(ITK_LEGACY_SILENT "Silence all legacy code messages." OFF)
mark_as_advanced(ITK_LEGACY_REMOVE ITK_LEGACY_SILENT ITK_V3_COMPATIBILITY)
#-----------------------------------------------------------------------------
# ITK build classes that are in the review process
option(ITK_USE_REVIEW "Build algorithms that are candidates to be included in the Toolkit. This classes are not covered by the Backward Compatibility Policy, no
r the Copyright Policy of ITK." OFF)
mark_as_advanced(ITK_USE_REVIEW)
if (ITK_USE_REVIEW)
set(Module_ITKReview ON)
endif(ITK_USE_REVIEW)
#-----------------------------------------------------------------------------
# ITK uses KWStyle for checking the coding style
INCLUDE(${ITK_SOURCE_DIR}/Utilities/KWStyle/KWStyle.cmake)
#-----------------------------------------------------------------------------
# ITK build the Examples that are illustrated in the Software Guide
option(BUILD_EXAMPLES "Build the Examples directory."
${BUILD_EXAMPLES_DEFAULT})
#-----------------------------------------------------------------------------
# Enable GPU support. Requires OpenCL to be installed
option(ITK_USE_GPU "GPU acceleration via OpenCL" OFF)
mark_as_advanced(ITK_USE_GPU)
# Manage FFT v3 Options
#
# USE_FFTWD -- use double precision fftw
option(USE_FFTWD "Use double precision fftw if found" OFF)
mark_as_advanced(USE_FFTWD)
#
# USE_FFTWF -- use single precision fftw
option(USE_FFTWF "Use single precision fftw if found" OFF)
mark_as_advanced(USE_FFTWF)
# USE_SYSTEM_FFTW -- locate a readybuilt fftw installation
option(USE_SYSTEM_FFTW "Use an installed version of fftw" OFF)
mark_as_advanced(USE_SYSTEM_FFTW)
if( USE_FFTWD OR USE_FFTWF )
#
# use ExternalProject
include(ExternalProject)
include(itkExternal_FFTW)
endif( USE_FFTWD OR USE_FFTWF )
if(NOT ITKV3_COMPATIBILITY)
option(ITK_USE_64BITS_IDS "When ON, ITK will use 64 bits integers to index pixels. This is needed for managing images larger than 4Gb in some platforms." OFF)
mark_as_advanced(ITK_USE_64BITS_IDS)
endif()
# ITK turn on concept checking
option(ITK_USE_CONCEPT_CHECKING "Turn on concept checking to give helpful errors at compile time if a type cannot be used as a template parameter." ON)
mark_as_advanced(ITK_USE_CONCEPT_CHECKING)
option(ITK_USE_STRICT_CONCEPT_CHECKING "Turn on Strict concept checking to give more stringent errors at compile time if a type cannot be used as a template parameter." OFF)
mark_as_advanced(ITK_USE_STRICT_CONCEPT_CHECKING)
#----------------------------------------------------------------------------
set(ITK_TEST_OUTPUT_DIR "${ITK_BINARY_DIR}/Testing/Temporary")
# Configure the default ITK_DATA_ROOT for the location of ITK Data.
set(ITK_DATA_ROOT ${ITK_SOURCE_DIR}/Testing/Data)
# Location of ITK Example Data.
set(ITK_EXAMPLE_DATA_ROOT "${ITK_SOURCE_DIR}/Examples/Data")
#This flag is used in particular, to enable some tests that require large memory to run.
# This probably can be discovered at configuration time by CMake. (Check with CMake developers).
set(ITK_COMPUTER_MEMORY_SIZE 1 CACHE STRING "Provide here the size of your RAM Memory in GigaBytes")
mark_as_advanced(ITK_COMPUTER_MEMORY_SIZE)
#----------------------------------------------------------------------
# Load the module DAG.
set(ITK_MODULES_ALL)
file(GLOB meta RELATIVE "${ITK_SOURCE_DIR}"
"${ITK_SOURCE_DIR}/*/*/*/itk-module.cmake" # grouped modules
)
foreach(f ${meta})
include(${ITK_SOURCE_DIR}/${f})
list(APPEND ITK_MODULES_ALL ${itk-module})
get_filename_component(${itk-module}_BASE ${f} PATH)
set(${itk-module}_SOURCE_DIR ${ITK_SOURCE_DIR}/${${itk-module}_BASE})
set(${itk-module}_BINARY_DIR ${ITK_BINARY_DIR}/${${itk-module}_BASE})
if(BUILD_TESTING AND EXISTS ${${itk-module}_SOURCE_DIR}/test)
list(APPEND ITK_MODULES_ALL ${itk-module-test})
set(${itk-module-test}_SOURCE_DIR ${${itk-module}_SOURCE_DIR}/test)
set(${itk-module-test}_BINARY_DIR ${${itk-module}_BINARY_DIR}/test)
set(${itk-module-test}_IS_TEST 1)
set(${itk-module}_TESTED_BY ${itk-module-test})
set(${itk-module-test}_TESTS_FOR ${itk-module})
endif()
# Reject bad dependencies.
string(REGEX MATCHALL ";(ITKDeprecated|ITKReview|ITKIntegratedTest);"
_bad_deps ";${ITK_MODULE_${itk-module}_DEPENDS};${ITK_MODULE_${itk-module-test}_DEPENDS};")
foreach(dep ${_bad_deps})
if(NOT "${itk-module}" MATCHES "^(${dep}|ITKIntegratedTest)$")
message(FATAL_ERROR
"Module \"${itk-module}\" loaded from\n"
" ${${itk-module}_BASE}/itk-module.cmake\n"
"may not depend on module \"${dep}\".")
endif()
endforeach()
endforeach()
# Clear variables set later in each module.
unset(itk-module)
unset(itk-module-test)
# Validate the module DAG.
macro(itk_module_check itk-module _needed_by stack)
if(NOT ITK_MODULE_${itk-module}_DECLARED)
message(FATAL_ERROR "No such module \"${itk-module}\" needed by \"${_needed_by}\"")
endif()
if(check_started_${itk-module} AND NOT check_finished_${itk-module})
# We reached a module while traversing its own dependencies recursively.
set(msg "")
foreach(entry ${stack})
set(msg " ${entry} =>${msg}")
if("${entry}" STREQUAL "${itk-module}")
break()
endif()
endforeach()
message(FATAL_ERROR "Module dependency cycle detected:\n ${msg} ${itk-module}")
elseif(NOT check_started_${itk-module})
# Traverse dependencies of this module. Mark the start and finish.
set(check_started_${itk-module} 1)
foreach(dep IN LISTS ITK_MODULE_${itk-module}_DEPENDS)
itk_module_check(${dep} ${itk-module} "${itk-module};${stack}")
endforeach()
set(check_finished_${itk-module} 1)
endif()
endmacro()
foreach(itk-module ${ITK_MODULES_ALL})
itk_module_check("${itk-module}" "" "")
endforeach()
#----------------------------------------------------------------------
# Provide an option for all modules.
option(ITK_BUILD_ALL_MODULES "Request to build all modules"
${ITK_BUILD_ALL_MODULES_DEFAULT})
# Provide module selections by groups
include(${ITK_SOURCE_DIR}/CMake/ITKGroups.cmake)
# Provide an option for each module.
foreach(itk-module ${ITK_MODULES_ALL})
if(NOT ${itk-module}_IS_TEST)
option(Module_${itk-module} "Request building ${itk-module}" OFF)
mark_as_advanced(Module_${itk-module})
if(ITK_MODULE_${itk-module}_EXCLUDE_FROM_ALL)
set(ITK_MODULE_${itk-module}_IN_ALL 0)
else()
set(ITK_MODULE_${itk-module}_IN_ALL ${ITK_BUILD_ALL_MODULES})
endif()
endif()
endforeach()
# Follow dependencies.
macro(itk_module_enable itk-module _needed_by)
if(NOT Module_${itk-module})
if(NOT ${itk-module}_TESTED_BY OR
NOT "x${_needed_by}" STREQUAL "x${${itk-module}_TESTED_BY}")
list(APPEND ITK_MODULE_${itk-module}_NEEDED_BY ${_needed_by})
endif()
endif()
if(NOT ${itk-module}_ENABLED)
set(${itk-module}_ENABLED 1)
foreach(dep IN LISTS ITK_MODULE_${itk-module}_DEPENDS)
itk_module_enable(${dep} ${itk-module})
endforeach()
if(${itk-module}_TESTED_BY)
itk_module_enable(${${itk-module}_TESTED_BY} "")
endif()
endif()
endmacro()
foreach(itk-module ${ITK_MODULES_ALL})
if(Module_${itk-module} OR ITK_MODULE_${itk-module}_IN_ALL)
itk_module_enable("${itk-module}" "")
elseif(ITK_MODULE_${itk-module}_REQUEST_BY)
itk_module_enable("${itk-module}" "${ITK_MODULE_${itk-module}_REQUEST_BY}")
endif()
endforeach()
# Build final list of enabled modules.
set(ITK_MODULES_ENABLED "")
set(ITK_MODULES_DISABLED "")
foreach(itk-module ${ITK_MODULES_ALL})
if(${itk-module}_ENABLED)
list(APPEND ITK_MODULES_ENABLED ${itk-module})
else()
list(APPEND ITK_MODULES_DISABLED ${itk-module})
endif()
endforeach()
list(SORT ITK_MODULES_ENABLED) # Deterministic order.
list(SORT ITK_MODULES_DISABLED) # Deterministic order.
# Order list to satisfy dependencies.
include(CMake/TopologicalSort.cmake)
topological_sort(ITK_MODULES_ENABLED ITK_MODULE_ _DEPENDS)
set(ITK_MODULES_DISABLED_CPACK )
foreach(m ${ITK_MODULES_DISABLED})
list(APPEND ITK_MODULES_DISABLED_CPACK "/${m}/")
endforeach()
set(CPACK_SOURCE_IGNORE_FILES
"${ITK_MODULES_DISABLED_CPACK};/\\\\.git")
include(CPack)
# Report what will be built.
foreach(itk-module ${ITK_MODULES_ENABLED})
if(NOT ${itk-module}_IS_TEST)
if(Module_${itk-module})
set(_reason ", requested by Module_${itk-module}")
elseif(ITK_MODULE_${itk-module}_IN_ALL)
set(_reason ", requested by ITK_BUILD_ALL_MODULES")
else()
set(_reason ", needed by [${ITK_MODULE_${itk-module}_NEEDED_BY}]")
endif()
message(STATUS "Enabled ${itk-module}${_reason}.")
endif()
endforeach()
# Hide options for modules that will build anyway.
foreach(itk-module ${ITK_MODULES_ALL})
if(NOT ${itk-module}_IS_TEST)
if(ITK_MODULE_${itk-module}_IN_ALL OR ITK_MODULE_${itk-module}_NEEDED_BY)
set_property(CACHE Module_${itk-module} PROPERTY TYPE INTERNAL)
else()
set_property(CACHE Module_${itk-module} PROPERTY TYPE BOOL)
endif()
endif()
endforeach()
#-----------------------------------------------------------------------------
# Construct an in-build-order list of "CDash subproject" modules from the
# list of enabled modules:
set(ITK_CDASH_SUBPROJECT_MODULES)
if(ITK_GENERATE_PROJECT_XML OR ITK_GENERATE_SUBPROJECTS_CMAKE)
# Since a "CDash subproject" for ITK logically contains both a non-test
# module and its corresponding test module, the subproject order must take
# both modules into account. The subprojects in this list are named after
# the non-test modules in the enabled modules list. But the ordering of
# these subprojects use the dependencies of the modules *and* their test
# modules
foreach(module ${ITK_MODULES_ENABLED})
if(${module}_TESTED_BY)
# module that HAS a test module: skip for now... will be added as a
# subproject later, in the slot when its corresponding "-test" module
# is encountered
elseif(${module}_TESTS_FOR)
# this is a test module... *now* list the module which it tests as
# the subproject name:
list(APPEND ITK_CDASH_SUBPROJECT_MODULES ${${module}_TESTS_FOR})
else()
# a module that is not a test module, and has no tested by...
# is just a module-only subproject with no test module:
list(APPEND ITK_CDASH_SUBPROJECT_MODULES ${module})
endif()
endforeach()
endif()
#-----------------------------------------------------------------------------
# Write a Project.xml file to send the description of the submodules and
# their dependencies up to CDash:
if(ITK_GENERATE_PROJECT_XML)
set(filename "${ITK_BINARY_DIR}/${main_project_name}.Project.xml")
set(xml "<?xml version='1.0' encoding='UTF-8'?>\n")
set(xml "${xml}<Project name='${main_project_name}'>\n")
foreach(module ${ITK_CDASH_SUBPROJECT_MODULES})
if(${module}_IS_TEST)
message(FATAL_ERROR "unexpected: subproject names should not be test modules module='${module}' tests_for='${${module}_TESTS_FOR}'")
endif()
set(xml "${xml} <SubProject name='${module}'>\n")
set(deps "")
set(dep_list ${ITK_MODULE_${module}_DEPENDS})
if(${module}_TESTED_BY)
list(APPEND dep_list ${ITK_MODULE_${${module}_TESTED_BY}_DEPENDS})
if(dep_list)
list(SORT dep_list)
endif()
endif()
foreach(dep ${dep_list})
if(NOT ${dep}_IS_TEST AND NOT "${module}" STREQUAL "${dep}")
set(xml "${xml} <Dependency name='${dep}'/>\n")
endif()
endforeach()
set(xml "${xml} </SubProject>\n")
endforeach()
set(xml "${xml}</Project>\n")
# Always write out "${filename}.in":
file(WRITE ${filename}.in "${xml}")
# Use configure_file so "${filename}" only changes when its content changes:
configure_file(${filename}.in ${filename} COPYONLY)
endif()
#-----------------------------------------------------------------------------
# Write the list of enabled modules out for ctest scripts to use as an
# in-order subproject list:
if(ITK_GENERATE_SUBPROJECTS_CMAKE)
set(filename "${ITK_BINARY_DIR}/${main_project_name}.SubProjects.cmake")
set(s "# Generated by CMake, do not edit!\n")
set(s "${s}set(itk_subprojects\n")
foreach(itk-module ${ITK_CDASH_SUBPROJECT_MODULES})
if(${itk-module}_IS_TEST)
message(FATAL_ERROR "unexpected: subproject names should not be test modules itk-module='${itk-module}' tests_for='${${itk-module}_TESTS_FOR}'")
endif()
set(s "${s} \"${itk-module}\"\n")
endforeach()
set(s "${s})\n")
# Always write out "${filename}.in":
file(WRITE ${filename}.in "${s}")
# Use configure_file so "${filename}" only changes when its content changes:
configure_file(${filename}.in ${filename} COPYONLY)
endif()
#-----------------------------------------------------------------------------
if(NOT ITK_MODULES_ENABLED)
message(WARNING "No modules enabled!")
file(REMOVE "${ITK_BINARY_DIR}/ITKTargets.cmake")
return()
endif()
file(WRITE "${ITK_BINARY_DIR}/ITKTargets.cmake"
"# Generated by CMake, do not edit!")
macro(init_module_vars)
verify_itk_module_is_set()
set(${itk-module}-targets ITKTargets)
set(${itk-module}-targets-install "${ITK_INSTALL_PACKAGE_DIR}/ITKTargets.cmake")
set(${itk-module}-targets-build "${ITK_BINARY_DIR}/ITKTargets.cmake")
endmacro()
# Build all modules.
foreach(itk-module ${ITK_MODULES_ENABLED})
if(NOT ${itk-module}_IS_TEST)
init_module_vars()
endif()
include("${${itk-module}_SOURCE_DIR}/itk-module-init.cmake" OPTIONAL)
add_subdirectory("${${itk-module}_SOURCE_DIR}" "${${itk-module}_BINARY_DIR}")
endforeach()
#----------------------------------------------------------------------------
configure_file(CMake/CTestCustom.cmake.in CTestCustom.cmake @ONLY)
#-----------------------------------------------------------------------------
# Create list of available modules and libraries.
set(ITK_CONFIG_MODULES_ENABLED "")
foreach(itk-module ${ITK_MODULES_ENABLED})
if(NOT ${itk-module}_IS_TEST)
list(APPEND ITK_CONFIG_MODULES_ENABLED ${itk-module})
endif()
endforeach()
# Generate ITKConfig.cmake for the build tree.
set(ITK_CONFIG_CODE "
set(ITK_MODULES_DIR \"${ITK_MODULES_DIR}\")")
set(ITK_USE_FILE "${ITK_SOURCE_DIR}/CMake/UseITK.cmake")
set(ITK_CONFIG_TARGETS_CONDITION " AND NOT ITK_BINARY_DIR")
set(ITK_CONFIG_TARGETS_FILE "${ITK_BINARY_DIR}/ITKTargets.cmake")
set(ITK_CONFIG_MODULE_API_FILE "${ITK_SOURCE_DIR}/CMake/ITKModuleAPI.cmake")
configure_file(CMake/ITKConfig.cmake.in ITKConfig.cmake @ONLY)
# Generate ITKConfig.cmake for the install tree.
set(ITK_CONFIG_CODE "
# Compute the installation prefix from this ITKConfig.cmake file location.
get_filename_component(ITK_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
# Construct the proper number of get_filename_component(... PATH)
# calls to compute the installation prefix.
string(REGEX REPLACE "/" ";" _count "${ITK_INSTALL_PACKAGE_DIR}")
foreach(p ${_count})
set(ITK_CONFIG_CODE "${ITK_CONFIG_CODE}
get_filename_component(ITK_INSTALL_PREFIX \"\${ITK_INSTALL_PREFIX}\" PATH)")
endforeach(p)
set(ITK_CONFIG_CODE "${ITK_CONFIG_CODE}
set(ITK_MODULES_DIR \"\${ITK_INSTALL_PREFIX}/${ITK_INSTALL_PACKAGE_DIR}/Modules\")")
set(ITK_USE_FILE "\${ITK_INSTALL_PREFIX}/${ITK_INSTALL_PACKAGE_DIR}/UseITK.cmake")
set(ITK_CONFIG_TARGETS_CONDITION "")
set(ITK_CONFIG_TARGETS_FILE "\${ITK_INSTALL_PREFIX}/${ITK_INSTALL_PACKAGE_DIR}/ITKTargets.cmake")
set(ITK_CONFIG_MODULE_API_FILE "\${ITK_INSTALL_PREFIX}/${ITK_INSTALL_PACKAGE_DIR}/ITKModuleAPI.cmake")
configure_file(CMake/ITKConfig.cmake.in CMakeFiles/ITKConfig.cmake @ONLY)
#----------------------------------------------------------------------------
# Configure maintenance scripts
configure_file(Utilities/Maintenance/doSingleKWStyleUncrustifyFix.sh.in
Utilities/Maintenance/doSingleKWStyleUncrustifyFix.sh @ONLY)
#-----------------------------------------------------------------------------
configure_file(CMake/ITKConfigVersion.cmake.in ITKConfigVersion.cmake @ONLY)
install(FILES ${ITK_BINARY_DIR}/CMakeFiles/ITKConfig.cmake
${ITK_BINARY_DIR}/ITKConfigVersion.cmake
CMake/ITKModuleAPI.cmake
CMake/UseITK.cmake
CMake/itkImageIOFactoryRegisterManager.h.in
CMake/itkTransformIOFactoryRegisterManager.h.in
DESTINATION ${ITK_INSTALL_PACKAGE_DIR})
get_property(ITKTargets_MODULES GLOBAL PROPERTY ITKTargets_MODULES)
if(ITKTargets_MODULES)
install(EXPORT ITKTargets DESTINATION ${ITK_INSTALL_PACKAGE_DIR})
else()
set(CMAKE_CONFIGURABLE_FILE_CONTENT "# No targets!")
configure_file(${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in
${ITK_BINARY_DIR}/CMakeFiles/ITKTargets.cmake @ONLY)
install(FILES ${ITK_BINARY_DIR}/CMakeFiles/ITKTargets.cmake
DESTINATION ${ITK_INSTALL_PACKAGE_DIR})
endif()
install(FILES "LICENSE" "NOTICE" "README.txt" DESTINATION ${ITK_INSTALL_DOC_DIR})
if(BUILD_TESTING)
add_subdirectory(Utilities/InstallTest)
endif()
#-----------------------------------------------------------------------------
# The subdirectories added below this line should use only the public
# interface with find_package(ITK). Set ITK_DIR to use this ITK build.
set(ITK_DIR "${ITK_BINARY_DIR}")
include(Wrapping/itkWrapSetup.cmake)
if(ITK_WRAPPING)
add_subdirectory(Wrapping)
endif(ITK_WRAPPING)
if(BUILD_EXAMPLES)
add_subdirectory(Examples)
endif()
#----------------------------------------------------------------------
# Provide an option for generating documentation.
add_subdirectory(Utilities/Doxygen)
# Create target to download data from the ITKData group. This must come after
# all tests have been added that reference the group, so we put it last.
ExternalData_Add_Target(ITKData)