-
-
Notifications
You must be signed in to change notification settings - Fork 381
/
External_ITKv5.cmake
198 lines (177 loc) · 7.54 KB
/
External_ITKv5.cmake
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
# Make sure this file is included only once by creating globally unique varibles
# based on the name of this included file.
get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE)
if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED)
return()
endif()
set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1)
## External_${extProjName}.cmake files can be recurisvely included,
## and cmake variables are global, so when including sub projects it
## is important make the extProjName and proj variables
## appear to stay constant in one of these files.
## Store global variables before overwriting (then restore at end of this file.)
ProjectDependancyPush(CACHED_extProjName ${extProjName})
ProjectDependancyPush(CACHED_proj ${proj})
# Make sure that the ExtProjName/IntProjName variables are unique globally
# even if other External_${ExtProjName}.cmake files are sourced by
# SlicerMacroCheckExternalProjectDependency
set(extProjName ITK) #The find_package known name
set(proj ITKv5) #This local name
set(${extProjName}_REQUIRED_VERSION ${${extProjName}_VERSION_MAJOR}) #If a required version is necessary, then set this, else leave blank
#if(${USE_SYSTEM_${extProjName}})
# unset(${extProjName}_DIR CACHE)
#endif()
# Sanity checks
if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR})
message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})")
endif()
# Set dependency list
set(${proj}_DEPENDENCIES "")
if(${PROJECT_NAME}_BUILD_DICOM_SUPPORT)
list(APPEND ${proj}_DEPENDENCIES DCMTK JPEG TIFF)
endif()
# Include dependent projects if any
SlicerMacroCheckExternalProjectDependency(${proj})
if(NOT DEFINED ${extProjName}_DIR AND NOT ${USE_SYSTEM_${extProjName}})
#message(STATUS "${__indent}Adding project ${proj}")
# Set CMake OSX variable to pass down the external project
set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS)
if(APPLE)
list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
endif()
### --- Project specific additions here
set(${proj}_DCMTK_ARGS)
if(${PROJECT_NAME}_BUILD_DICOM_SUPPORT)
set(${proj}_DCMTK_ARGS
-DITK_USE_SYSTEM_DCMTK:BOOL=ON
-DDCMTK_DIR:PATH=${DCMTK_DIR}
-DModule_ITKDCMTK:BOOL=ON
-DModule_ITKIODCMTK:BOOL=ON
)
endif()
if(${PROJECT_NAME}_BUILD_FFTWF_SUPPORT)
set(${proj}_FFTWF_ARGS
-DITK_USE_FFTWF:BOOL=ON
)
endif()
if(${PROJECT_NAME}_BUILD_FFTWD_SUPPORT)
set(${proj}_FFTWD_ARGS
-DITK_USE_FFTWD:BOOL=ON
)
endif()
if(${extProjName}_BUILD_MINC_SUPPORT)
set(${proj}_MINC_ARGS
-DModule_ITKIOMINC:BOOL=ON
-DModule_ITKIOTransformMINC:BOOL=ON
-DModule_ITKMINC:BOOL=ON
)
endif()
set(${proj}_WRAP_ARGS)
#if(foo)
#set(${proj}_WRAP_ARGS
# -DINSTALL_WRAP_ITK_COMPATIBILITY:BOOL=OFF
# -DWRAP_float:BOOL=ON
# -DWRAP_unsigned_char:BOOL=ON
# -DWRAP_signed_short:BOOL=ON
# -DWRAP_unsigned_short:BOOL=ON
# -DWRAP_complex_float:BOOL=ON
# -DWRAP_vector_float:BOOL=ON
# -DWRAP_covariant_vector_float:BOOL=ON
# -DWRAP_rgb_signed_short:BOOL=ON
# -DWRAP_rgb_unsigned_char:BOOL=ON
# -DWRAP_rgb_unsigned_short:BOOL=ON
# -DWRAP_ITK_TCL:BOOL=OFF
# -DWRAP_ITK_JAVA:BOOL=OFF
# -DWRAP_ITK_PYTHON:BOOL=ON
# -DPYTHON_EXECUTABLE:PATH=${${CMAKE_PROJECT_NAME}_PYTHON_EXECUTABLE}
# -DPYTHON_INCLUDE_DIR:PATH=${${CMAKE_PROJECT_NAME}_PYTHON_INCLUDE}
# -DPYTHON_LIBRARY:FILEPATH=${${CMAKE_PROJECT_NAME}_PYTHON_LIBRARY}
# )
#endif()
# HACK This code fixes a loony problem with HDF5 -- it doesn't
# link properly if -fopenmp is used.
string(REPLACE "-fopenmp" "" ITK_CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-fopenmp" "" ITK_CMAKE_CXX_FLAGS "${CMAKE_CX_FLAGS}")
find_package(ZLIB REQUIRED)
set(${proj}_CMAKE_OPTIONS
-DBUILD_TESTING:BOOL=OFF
-DBUILD_EXAMPLES:BOOL=OFF
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/staging
-DITK_LEGACY_REMOVE:BOOL=OFF # <--- NEEDED TEMPORARILY until fixes for enum-class and ITK 5.1 release are required
-DITK_FUTURE_LEGACY_REMOVE:BOOL=ON
-DITKV3_COMPATIBILITY:BOOL=OFF
-DITK_BUILD_DEFAULT_MODULES:BOOL=ON
-DITK_USE_SYSTEM_PNG=${ITK_USE_SYSTEM_PNG}
# -DITK_MODULE_Core:BOOL=ON
# -DITK_MODULE_IO:BOOL=ON
# -DITK_MODULE_Filtering:BOOL=ON
# -DITK_MODULE_Registration:BOOL=ON
#-DITK_INSTALL_NO_DEVELOPMENT:BOOL=ON
-DKWSYS_USE_MD5:BOOL=ON # Required by SlicerExecutionModel
-DITK_WRAPPING:BOOL=OFF #${BUILD_SHARED_LIBS} ## HACK: QUICK CHANGE
-DModule_MGHIO:BOOL=ON
-DModule_ITKReview:BOOL=ON
-DModule_GenericLabelInterpolator:BOOL=ON
-DModule_AdaptiveDenoising:BOOL=ON
${${proj}_DCMTK_ARGS}
${${proj}_WRAP_ARGS}
${${proj}_FFTWF_ARGS}
${${proj}_FFTWD_ARGS}
${${proj}_MINC_ARGS}
)
if( USE_VTK STREQUAL "ON" )
list(APPEND ${proj}_CMAKE_OPTIONS -DModule_ITKVtkGlue:BOOL=ON)
if( USE_SYSTEM_VTK STREQUAL "OFF" )
list(INSERT CMAKE_PREFIX_PATH 0 ${CMAKE_BINARY_DIR}/staging)
list(APPEND ${proj}_CMAKE_OPTIONS -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH})
endif()
list(APPEND ${proj}_DEPENDENCIES VTK)
else()
list(APPEND ${proj}_CMAKE_OPTIONS -DModule_ITKVtkGlue:BOOL=OFF)
endif()
### --- End Project specific additions
set(${proj}_REPOSITORY ${git_protocol}://github.com/InsightSoftwareConsortium/ITK.git)
# set(${proj}_REPOSITORY ${git_protocol}://github.com/stnava/ITK.git)
set(${proj}_GIT_TAG v5.3rc03) # Official ITK release version 5.3.0 rc 03 # Many modern code updates for performance
set(ITK_VERSION_ID ITK-5.3) ### NOTE: When updating GIT_TAG, also update ITK_VERSION_ID
ExternalProject_Add(${proj}
GIT_REPOSITORY ${${proj}_REPOSITORY}
GIT_TAG ${${proj}_GIT_TAG}
SOURCE_DIR ${proj}
BINARY_DIR ${proj}-build
LOG_CONFIGURE 0 # Wrap configure in script to ignore log output from dashboards
LOG_BUILD 0 # Wrap build in script to to ignore log output from dashboards
LOG_TEST 0 # Wrap test in script to to ignore log output from dashboards
LOG_INSTALL 0 # Wrap install in script to to ignore log output from dashboards
${cmakeversion_external_update} "${cmakeversion_external_update_value}"
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
-Wno-dev
--no-warn-unused-cli
${CMAKE_OSX_EXTERNAL_PROJECT_ARGS}
${COMMON_EXTERNAL_PROJECT_ARGS}
${${proj}_CMAKE_OPTIONS}
-DCMAKE_GENERATOR_PLATFORM:STRING=${CMAKE_GENERATOR_PLATFORM}
## We really do want to install in order to limit # of include paths INSTALL_COMMAND ""
DEPENDS
${${proj}_DEPENDENCIES}
)
set(${extProjName}_DIR ${CMAKE_BINARY_DIR}/staging/lib/cmake/${ITK_VERSION_ID})
else()
if(${USE_SYSTEM_${extProjName}})
find_package(${extProjName} ${ITK_VERSION_MAJOR} REQUIRED)
if(NOT ${extProjName}_DIR)
message(FATAL_ERROR "To use the system ${extProjName}, set ${extProjName}_DIR")
endif()
message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}")
endif()
# The project is provided using ${extProjName}_DIR, nevertheless since other
# project may depend on ${extProjName}, let's add an 'empty' one
SlicerMacroEmptyExternalProject(${proj} "${${proj}_DEPENDENCIES}")
endif()
list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS ${extProjName}_DIR:PATH)
ProjectDependancyPop(CACHED_extProjName extProjName)
ProjectDependancyPop(CACHED_proj proj)