forked from NIRALUser/DTIProcessToolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDTIProcess.cmake
212 lines (175 loc) · 6.04 KB
/
DTIProcess.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
if( DTIProcess_BUILD_SLICER_EXTENSION )
unsetForSlicer( NAMES QT_QMAKE_EXECUTABLE SlicerExecutionModel_DIR ITK_DIR VTK_DIR CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_CXX_FLAGS CMAKE_C_FLAGS ITK_LIBRARIES )
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})
resetForSlicer( NAMES CMAKE_C_COMPILER CMAKE_CXX_COMPILER CMAKE_CXX_FLAGS CMAKE_C_FLAGS )
SET(INSTALL_RUNTIME_DESTINATION ${Slicer_INSTALL_CLIMODULES_BIN_DIR})
SET(INSTALL_LIBRARY_DESTINATION ${Slicer_INSTALL_CLIMODULES_LIB_DIR})
SET(INSTALL_ARCHIVE_DESTINATION ${Slicer_INSTALL_CLIMODULES_LIB_DIR})
endif()
SETIFEMPTY(INSTALL_RUNTIME_DESTINATION bin)
SETIFEMPTY(INSTALL_LIBRARY_DESTINATION bin)
SETIFEMPTY(INSTALL_ARCHIVE_DESTINATION lib/static)
SETIFEMPTY(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
SETIFEMPTY(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
SETIFEMPTY(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
option(BUILD_TESTING "Build the testing tree" ON)
option(EXECUTABLES_ONLY "Build only executables (CLI)" OFF)
if( ${EXECUTABLES_ONLY} )
set( STATIC "EXECUTABLE_ONLY" )
set( STATIC_LIB "STATIC" )
else()
set( STATIC_LIB "SHARED" )
endif()
find_package(DCMTK REQUIRED)
if(NOT DCMTK_FOUND)
message(FATAL_ERROR "DCMTK Not Found")
endif()
find_package(niral_utilities)
if(niral_utilities_FOUND)
foreach(niral_utilities_lib ${niral_utilities_LIBRARIES})
get_target_property(niral_utilities_location ${niral_utilities_lib} LOCATION_RELEASE)
if(NOT EXISTS ${niral_utilities_location})
message(STATUS "skipping niral_utilities_lib install rule: [${niral_utilities_location}] does not exist")
continue()
endif()
if(EXISTS "${niral_utilities_location}.xml")
install(PROGRAMS ${niral_utilities_location}
DESTINATION ${INSTALL_RUNTIME_DESTINATION}
COMPONENT RUNTIME)
install(FILES ${niral_utilities_location}.xml
DESTINATION ${INSTALL_RUNTIME_DESTINATION}
COMPONENT RUNTIME)
else()
install(PROGRAMS ${niral_utilities_location}
DESTINATION ${INSTALL_RUNTIME_DESTINATION}/../ExternalBin
COMPONENT RUNTIME)
endif()
endforeach()
endif()
## In many cases sub-projects depending on SlicerExectuion Model
## that can be built stand alone are combined in larger packages.
## This logic will include SlicerExectionModel only if it
## has not already been included by a previous package.
find_package(SlicerExecutionModel REQUIRED GenerateCLP)
include(${SlicerExecutionModel_USE_FILE})
include(${GenerateCLP_USE_FILE})
set( LIST_ITK_COMPONENTS
ITKDiffusionTensorImage
ITKRegistrationCommon
ITKOptimizersv4
ITKConnectedComponents
ITKMathematicalMorphology
ITKBinaryMathematicalMorphology
ITKRegionGrowing
ITKMetricsv4
ITKRegistrationMethodsv4
ITKDistanceMap
ITKVTK
ITKTransform
ITKIOImageBase
ITKIOTransformBase
ITKIOTransformInsightLegacy
ITKIOTransformMatlab
ITKImageCompare
ITKTestKernel
)
# IO modules: we only load the IO modules that are available with ITK. Because the toolds compiled in this project read and write DWI and DTI,
# we leave only NRRD as the compulsory module.
set( ALL_IO
ITKIOBMP
ITKIOBioRad
ITKIOCSV
ITKIODCMTK
ITKIOGDCM
ITKIOGE
ITKIOGIPL
ITKIOHDF5
ITKIOIPL
ITKIOJPEG
ITKIOLSM
ITKIOMRC
MGHIO
ITKIOMesh
ITKIOMeta
ITKIONIFTI
ITKIOPNG
ITKIORAW
ITKIOSiemens
ITKIOSpatialObjects
ITKIOStimulate
ITKIOTIFF
ITKIOTransformHDF5
ITKIOVTK
ITKIOXML
)
list(APPEND LIST_ITK_IO_USED ITKIONRRD )
foreach( io ${ALL_IO} )
list( FIND ITK_MODULES_ENABLED ${io} position )
if( ${position} GREATER -1 ) #not found: ${position}==-1
list( APPEND LIST_ITK_IO_USED ${io} )
endif()
endforeach()
find_package(ITK COMPONENTS
${LIST_ITK_COMPONENTS} ${LIST_ITK_IO_USED}
REQUIRED
)
include(${ITK_USE_FILE})
# have to save library list because it gets clobbered by GenerateCLP, which
# calls find_package(ITK) every time it's invoked.
set(DTIProcess_ITK_LIBRARIES ${ITK_LIBRARIES})
find_package(VTK COMPONENTS
vtkIOLegacy
vtkIOXML
vtkCommonDataModel
REQUIRED)
include(${VTK_USE_FILE})
INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/Library
${PROJECT_SOURCE_DIR}/PrivateLibrary
${PROJECT_SOURCE_DIR}
)
## Replace bessel(FORTRAN) with cephes(C)
SET(BESSEL_LIB cephes)
ADD_SUBDIRECTORY(cephes)
ADD_SUBDIRECTORY(PrivateLibrary)
ADD_SUBDIRECTORY(Applications)
#-----------------------------------------------------------------------------
# Add external project CMake args
#-----------------------------------------------------------------------------
list(APPEND ${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_VARS
BUILD_TESTING:BOOL
ITK_VERSION_MAJOR:STRING
ITK_DIR:PATH
VTK_DIR:PATH
GenerateCLP_DIR:PATH
SlicerExecutionModel_DIR:PATH
)
_expand_external_project_vars()
set(COMMON_EXTERNAL_PROJECT_ARGS ${${CMAKE_PROJECT_NAME}_SUPERBUILD_EP_ARGS})
set( USE_SYSTEM_ITK ON)
set( USE_SYSTEM_VTK ON)
set( USE_SYSTEM_SlicerExecutionModel ON)
set(extProjName ${PRIMARY_PROJECT_NAME})
set(proj ${PRIMARY_PROJECT_NAME})
if( DTIProcess_BUILD_SLICER_EXTENSION )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/ImportDTIProcessExtensionExecutables.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/ImportDTIProcessExtensionExecutables.cmake)
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${EXTENSION_NAME};ALL;/")
include(${Slicer_EXTENSION_CPACK})
endif()
if(WIN32 AND NOT CYGWIN)
set(DEF_INSTALL_CMAKE_DIR CMake)
else()
set(DEF_INSTALL_CMAKE_DIR lib/CMake/DTIProcess)
endif()
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
"Installation directory for CMake files")
configure_file(CMake/DTIProcessConfig.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DTIProcessConfig.cmake" @ONLY)
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DTIProcessConfig.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
if( DTIAtlasFiberAnalyzer_BUILD_SLICER_EXTENSION )
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${EXTENSION_NAME};ALL;/")
include(${Slicer_EXTENSION_CPACK})
endif()