forked from BRAINSia/BRAINSTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BRAINSTools.cmake
212 lines (188 loc) · 8.87 KB
/
BRAINSTools.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
#-----------------------------------------------------------------------------
# Update CMake module path
#------------------------------------------------------------------------------
set(BRAINSCommonLib_BUILDSCRIPTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/BRAINSCommonLib/BuildScripts)
set(CMAKE_MODULE_PATH
${BRAINSCommonLib_BUILDSCRIPTS_DIR}
${${PROJECT_NAME}_SOURCE_DIR}/CMake
${${PROJECT_NAME}_BINARY_DIR}/CMake
${CMAKE_MODULE_PATH}
)
#-----------------------------------------------------------------------------
# Version information
include(Version.cmake)
set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}")
if(DEFINED ${PROJECT_NAME}_VERSION_PATCH)
set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION}.${${PROJECT_NAME}_VERSION_PATCH}")
if(DEFINED ${PROJECT_NAME}_VERSION_TWEAK)
set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION}.${${PROJECT_NAME}_VERSION_TWEAK}")
endif()
endif()
if(DEFINED ${PROJECT_NAME}_VERSION_RC)
set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION}${${PROJECT_NAME}_VERSION_RC}")
endif()
if(DEFINED ${PROJECT_NAME}_VERSION_POST)
set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION}.post${${PROJECT_NAME}_VERSION_POST}")
elseif(DEFINED ${PROJECT_NAME}_VERSION_DEV)
set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION}.dev${${PROJECT_NAME}_VERSION_DEV}")
endif()
option( ${PROJECT_NAME}_BUILD_DISTRIBUTE "Remove '-g#####' from version. ( for official distribution only )" OFF )
mark_as_advanced( ${PROJECT_NAME}_BUILD_DISTRIBUTE )
if( NOT ${PROJECT_NAME}_BUILD_DISTRIBUTE )
set(${PROJECT_NAME}_VERSION "${${PROJECT_NAME}_VERSION}-g${${PROJECT_NAME}_VERSION_HASH}")
endif()
message(STATUS "${PROJECT_NAME}_VERSION_MAJOR ${${PROJECT_NAME}_VERSION_MAJOR}")
message(STATUS "${PROJECT_NAME}_VERSION_MINOR ${${PROJECT_NAME}_VERSION_MINOR}")
message(STATUS "${PROJECT_NAME}_VERSION_PATCH ${${PROJECT_NAME}_VERSION_PATCH}")
message(STATUS "${PROJECT_NAME}_VERSION_TWEAK ${${PROJECT_NAME}_VERSION_TWEAK}")
message(STATUS "${PROJECT_NAME}_VERSION_RC ${${PROJECT_NAME}_VERSION_RC}")
message(STATUS "${PROJECT_NAME}_VERSION_HASH ${${PROJECT_NAME}_VERSION_HASH}")
message(STATUS "${PROJECT_NAME}_VERSION_POST ${${PROJECT_NAME}_VERSION_POST}")
message(STATUS "${PROJECT_NAME}_VERSION_DEV ${${PROJECT_NAME}_VERSION_DEV}")
message(STATUS "Building ${PROJECT_NAME} version \"${${PROJECT_NAME}_VERSION}\"")
include(FindITKUtil)
include(FindVTKUtil)
# #-----------------------------------------------------------------------------
# if(BRAINSTools_REQUIRES_VTK)
# # message("VTK_DIR:${VTK_DIR}")
# find_package(VTK REQUIRED)
# if(VTK_FOUND)
# include(${VTK_USE_FILE})
# endif()
# # message("VTK_USE_FILE:${VTK_USE_FILE}")
# # message("VTK_INCLUDE_DIRS:${VTK_INCLUDE_DIRS}")
# include_directories(${VTK_INCLUDE_DIRS})
# endif()
#-----------------------------------------------------------------------------
find_package(SlicerExecutionModel REQUIRED GenerateCLP)
include(${GenerateCLP_USE_FILE})
include(${SlicerExecutionModel_USE_FILE})
include(${SlicerExecutionModel_CMAKE_DIR}/SEMMacroBuildCLI.cmake)
if(USE_ANTS)
# find ANTS includes
message("ANTs_SOURCE_DIR=${ANTs_SOURCE_DIR}")
include_directories(${BOOST_INCLUDE_DIR})
include_directories(${ANTs_SOURCE_DIR}/Temporary)
include_directories(${ANTs_SOURCE_DIR}/Tensor)
include_directories(${ANTs_SOURCE_DIR}/Utilities)
include_directories(${ANTs_SOURCE_DIR}/Examples)
include_directories(${ANTs_SOURCE_DIR}/ImageRegistration)
link_directories(${BRAINSTools_LIBRARY_PATH} ${BRAINSTools_CLI_ARCHIVE_OUTPUT_DIRECTORY} ${ANTs_LIBRARY_DIR})
set(ANTS_LIBS antsUtilities)
endif()
# Define the atlas subdirectory in one place
if(USE_ReferenceAtlas)
set(ReferenceAtlas_XML_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(ATLAS_VERSION 20131115)
set(ATLAS_NAME Atlas/Atlas_${ATLAS_VERSION})
set(ATLAS_INSTALL_DIRECTORY ${ReferenceAtlas_XML_DIR}/${ATLAS_NAME})
endif()
#-----------------------------------------------------------------------------
enable_testing()
include(CTest)
#-----------------------------------------------------------------------------
# CTestCustom
#-----------------------------------------------------------------------------
if(BUILD_TESTING AND NOT Slicer_BUILD_BRAINSTOOLS)
configure_file(
CMake/CTestCustom.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
@ONLY)
endif()
# Some test are failing due to inadequate test construction, but
# the code seems to do the correct thing on real data.
# This is also for tests that are huge, and can not be running
# a long time.
option(ENABLE_EXTENDED_TESTING "Enable tests that are long running, or where the test itself is in error." OFF)
mark_as_advanced(ENABLE_EXTENDED_TESTING)
#Set the global max TIMEOUT for CTest jobs. This is very large for the moment
#and should be revisted to reduce based on "LONG/SHORT" test times, set to 1 hr for now
set(CTEST_TEST_TIMEOUT 1800 CACHE STRING "Maximum seconds allowed before CTest will kill the test." FORCE)
set(DART_TESTING_TIMEOUT ${CTEST_TEST_TIMEOUT} CACHE STRING "Maximum seconds allowed before CTest will kill the test." FORCE)
## BRAINSTools_MAX_TEST_LEVEL adjusts how agressive the test suite is
## so that long running tests or incomplete tests can easily be
## silenced
## 1 - Run the absolute minimum very fast tests (These should always pass before any code commit)
## 3 - Run fast tests on continous builds (These need immediate attention if they begin to fail)
## 5 - Run moderate nightly tests (These need immediate attention if they begin to fail)
## 7 - Run long running extensive test that are a burden to normal development (perhaps test 1x per week)
## 8 - Run tests that fail due to incomplete test building, these are good ideas for test that we don't have time to make robust)
## 9 - Run silly tests that don't have much untility
set(BRAINSTools_MAX_TEST_LEVEL 4 CACHE STRING "Testing level for managing test burden")
#-----------------------------------------------------------------------
# Setup locations to find externally maintained test data.
#-----------------------------------------------------------------------
include(BRAINSToolsExternalData)
set(TestData_DIR ${CMAKE_CURRENT_SOURCE_DIR}/TestData)
#
# choose between using HDF5 or MAT format transform files
set(XFRM_EXT "h5" CACHE STRING "Choose the preferred transform file format")
#-----------------------------------------------------------------------------
# BRAINSCommonLib (Required)
#-----------------------------------------------------------------------------
include(CMakeBRAINS3BuildMacros)
add_subdirectory(BRAINSCommonLib)
set(BRAINSCommonLib_DIR ${CMAKE_CURRENT_BINARY_DIR}/BRAINSCommonLib)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/BRAINSCommonLib
${CMAKE_CURRENT_BINARY_DIR}/BRAINSCommonLib)
#-----------------------------------------------------------------------------
# Define list of module names
#-----------------------------------------------------------------------------
set(brains_modulenames
BRAINSFit
BRAINSLabelStats
BRAINSResample
BRAINSROIAuto
GTRACT
ImageCalculator
BRAINSCut
## Temporarily Removed Need to update OpenCV BRAINSCut
BRAINSLandmarkInitializer
BRAINSSnapShotWriter
BRAINSDemonWarp ## NOTE: This is off by default, but is valid for both ITKv3/4
## This builds just fine with ITKv3/4, but test cases need
## further review before trusting it.
##TODO: KENT: This is broken with latest builds, I think something in ITKv4 changed slightly, or VTK6 compatibility -->BRAINSSurfaceTools
BRAINSSurfaceTools
ICCDEF
BRAINSContinuousClass
BRAINSPosteriorToContinuousClass
BRAINSMush
BRAINSMultiModeSegment
BRAINSInitializedControlPoints
BRAINSTransformConvert
BRAINSTalairach
BRAINSConstellationDetector
BRAINSABC
ConvertBetweenFileFormats
DWIConvert
BRAINSCreateLabelMapFromProbabilityMaps
BRAINSMultiSTAPLE
BRAINSStripRotation
AutoWorkup
BRAINSDWICleanup
ReferenceAtlas
)
if(USE_DebugImageViewer)
list(APPEND brains_modulenames
DebugImageViewer)
endif()
## HACK: This is needed to get DWIConvert to build in installed tree
## KENT: Please remove this line and make DWIConvert build by fixing ITK install of DCMTK
include_directories(${ITK_INSTALL_PREFIX}/install)
#-----------------------------------------------------------------------------
# Add module sub-directory if USE_<MODULENAME> is both defined and true
#-----------------------------------------------------------------------------
set(BRAINSToolsModules "")
foreach(modulename ${brains_modulenames})
# message("DEFINED USE_${modulename} AND ${USE_${modulename}}")
if(DEFINED USE_${modulename} AND USE_${modulename})
# message("Adding ${modulename}")
add_subdirectory(${modulename})
list(APPEND BRAINSToolsModules ${modulename})
#else()
# message("USE_${modulename} = ${USE_${modulename}}")
endif()
endforeach()
ExternalData_Add_Target( ${PROJECT_NAME}FetchData ) # Name of data management target