-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
340 lines (285 loc) · 12.3 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
cmake_minimum_required(VERSION 3.5.0)
set(EXTENSION_NAME PkModeling)
set(EXTENSION_HOMEPAGE "https://www.slicer.org/wiki/Documentation/Nightly/Modules/PkModeling")
set(EXTENSION_CATEGORY "Quantification")
set(EXTENSION_CONTRIBUTORS "Yingxuan Zhu (GE), Jim Miller (GE), Andriy Fedorov (BWH), Ming-ching Chang (GE), Mahnaz Maddah (SRI)")
set(EXTENSION_DESCRIPTION "PkModeling is a Slicer4 Extension that provides pharmacokinetic modeling for dynamic contrast enhanced MRI (DCE MRI).")
set(EXTENSION_ICONURL "http://wiki.slicer.org/slicerWiki/images/3/34/PkModeling.png")
set(EXTENSION_STATUS "Beta")
set(EXTENSION_SCREENSHOTURLS " ")
set(EXTENSION_BUILD_SUBDIRECTORY "pkmodeling-build")
set(EXTENSION_ACKNOWLEDGEMENTS "This work is part of the National Alliance for Medical Image Computing (NAMIC), funded by the National Institutes of Health through the NIH Roadmap for Medical Research, Grant U54 EB005149. Information on the National Centers for Biomedical Computing can be obtained from http://nihroadmap.nih.gov/bioinformatics . This work was also funded in part by the Quantitative Imaging Network (QIN) Grant U01CA151261.")
set(CMAKE_POSITION_INDEPENDENT_CODE 1)
set(PkModeling_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
#-----------------------------------------------------------------------------
# Superbuild
#
set(CMAKE_MODULE_PATH "${PkModeling_CMAKE_DIR}" ${CMAKE_MODULE_PATH})
set(EXTERNAL_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakeExternals)
set(EXTERNAL_PROJECT_FILE_PREFIX "")
include(ExternalProject)
include(ExternalProjectDependency)
#-----------------------------------------------------------------------------
if(APPLE)
# Note: By setting CMAKE_OSX_* variables before any enable_language() or project() calls,
# we ensure that the bitness will be properly detected.
include(pkmodelingBlockSetCMakeOSXVariables)
mark_as_superbuild(
VARS CMAKE_OSX_ARCHITECTURES:STRING CMAKE_OSX_SYSROOT:PATH CMAKE_OSX_DEPLOYMENT_TARGET:STRING
ALL_PROJECTS
)
endif()
project(PkModeling)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LC)
#-----------------------------------------------------------------------------
# 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 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
mark_as_advanced(CMAKE_BUILD_TYPE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
if(NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Configuring with build type '${CMAKE_BUILD_TYPE}'")
mark_as_superbuild(VARS CMAKE_BUILD_TYPE ALL_PROJECTS)
endif()
mark_as_superbuild(
VARS
CMAKE_PREFIX_PATH:STRING
CMAKE_DEBUG_POSTFIX:STRING
ALL_PROJECTS
)
#-----------------------------------------------------------------------------
# Option default values
set(superbuild_default ON)
if(Slicer_SOURCE_DIR)
# Default values used when PkModeling is integrated into Slicer as Remote project.
set(superbuild_default OFF)
endif()
#-----------------------------------------------------------------------------
# Options
include(CMakeDependentOption)
option(PkModeling_BUILD_APPS "Build ${PROJECT_NAME} applications." ON)
mark_as_superbuild(PkModeling_BUILD_APPS)
#option(DCMQI_BUILD_DOC "Build ${PROJECT_NAME} documentation." ${build_doc_default})
#mark_as_superbuild(DCMQI_BUILD_DOC)
#-----------------------------------------------------------------------------
# Standalone vs Slicer extension option
#
# This option should be named after the project name, it corresponds to the
# option set to ON when the project is build by the Slicer Extension build
# system.
set(_default OFF)
set(_reason "PkModeling_BUILD_SLICER_EXTENSION is ON")
if(NOT DEFINED PkModeling_BUILD_SLICER_EXTENSION AND DEFINED Slicer_DIR)
set(_default ON)
set(_reason "Slicer_DIR is SET")
endif()
option(PkModeling_BUILD_SLICER_EXTENSION "Build as a Slicer Extension" ${_default})
set(_msg "Checking if building as a Slicer extension")
message(STATUS ${_msg})
if(PkModeling_BUILD_SLICER_EXTENSION)
message(STATUS "${_msg} - yes (${_reason})")
else()
message(STATUS "${_msg} - no (PkModeling_BUILD_SLICER_EXTENSION is OFF)")
endif()
#-----------------------------------------------------------------------------
# Superbuild Option - Enabled by default
#
option(PkModeling_SUPERBUILD "Build ${PROJECT_NAME} and the projects it depends on." ${superbuild_default})
mark_as_advanced(PkModeling_SUPERBUILD)
#-----------------------------------------------------------------------------
# Output directories.
#
message(STATUS "---------- SETTING OUTPUT DIRECTORIES ----------")
foreach(type LIBRARY RUNTIME ARCHIVE)
# Make sure the directory exists
if(DEFINED PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY
AND NOT EXISTS ${PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY})
message(FATAL_ERROR "PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY is set to a non-existing directory [${PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY}]")
endif()
if(PkModeling_SUPERBUILD)
set(output_dir ${PkModeling_BINARY_DIR}/bin)
if(NOT DEFINED PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY)
set(PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY ${PkModeling_BINARY_DIR}/${PROJECT_NAME_LC}-build/bin)
endif()
mark_as_superbuild(PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY:PATH)
else()
if(NOT DEFINED PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY)
set(output_dir ${PkModeling_BINARY_DIR}/bin)
else()
set(output_dir ${PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY})
endif()
endif()
set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.")
message(STATUS "PkModeling_CMAKE_" ${type} "_OUTPUT_DIRECTORY:" ${PkModeling_CMAKE_${type}_OUTPUT_DIRECTORY})
message(STATUS "CMAKE_" ${type} "_OUTPUT_DIRECTORY:" ${CMAKE_${type}_OUTPUT_DIRECTORY})
endforeach()
message(STATUS "------------------------------------------------")
#-----------------------------------------------------------------------------
# PkModeling version number
#
set(PkModeling_VERSION_MAJOR 2)
set(PkModeling_VERSION_MINOR 0)
set(PkModeling_VERSION_PATCH 0)
set(PkModeling_VERSION
"${PkModeling_VERSION_MAJOR}.${PkModeling_VERSION_MINOR}.${PkModeling_VERSION_PATCH}")
set(PkModeling_LATEST_TAG "latest")
# Append the library version information to the library target
# properties. A parent project may set its own properties and/or may
# block this.
if(NOT PkModeling_NO_LIBRARY_VERSION)
set(PkModeling_LIBRARY_PROPERTIES ${PkModeling_LIBRARY_PROPERTIES}
VERSION "${PkModeling_VERSION}"
SOVERSION "${PkModeling_VERSION_MAJOR}.${PkModeling_VERSION_MINOR}"
)
endif()
#-----------------------------------------------------------------------------
# Install directories, used for install rules.
#
if(NOT PkModeling_INSTALL_BIN_DIR)
set(PkModeling_INSTALL_BIN_DIR "bin")
endif()
if(NOT PkModeling_INSTALL_LIB_DIR)
set(PkModeling_INSTALL_LIB_DIR "lib/PkModeling-${PkModeling_VERSION_MAJOR}.${PkModeling_VERSION_MINOR}")
endif()
if(NOT PkModeling_INSTALL_CMAKE_DIR)
set(PkModeling_INSTALL_CMAKE_DIR "lib/PkModeling-${PkModeling_VERSION_MAJOR}.${PkModeling_VERSION_MINOR}/CMake")
endif()
if(NOT PkModeling_INSTALL_INCLUDE_DIR)
set(PkModeling_INSTALL_INCLUDE_DIR "include/PkModeling-${PkModeling_VERSION_MAJOR}.${PkModeling_VERSION_MINOR}")
endif()
mark_as_superbuild(
PkModeling_INSTALL_BIN_DIR:STRING
PkModeling_INSTALL_LIB_DIR:STRING
PkModeling_INSTALL_CMAKE_DIR:STRING
PkModeling_INSTALL_INCLUDE_DIR:STRING
)
#-----------------------------------------------------------------------------
# Other options
# Git protocol option
option(PkModeling_USE_GIT_PROTOCOL "If behind a firewall turn this OFF to use http instead." ON)
mark_as_advanced(PkModeling_USE_GIT_PROTOCOL)
set(git_protocol "git")
if(NOT PkModeling_USE_GIT_PROTOCOL)
set(git_protocol "http")
endif()
#-----------------------------------------------------------------------------
# Dependencies
#
# Slicer
if(PkModeling_BUILD_SLICER_EXTENSION)
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})
mark_as_superbuild(Slicer_DIR)
endif()
#-----------------------------------------------------------------------------
# Superbuild script
#
if(PkModeling_SUPERBUILD)
include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
return()
endif()
#-----------------------------------------------------------------------------
# Dependencies
#
find_package(SlicerExecutionModel REQUIRED)
include(${SlicerExecutionModel_USE_FILE})
find_package(ITK NO_MODULE REQUIRED)
include(${ITK_USE_FILE})
#-----------------------------------------------------------------------------
# Testing
#
include(CTest)
set(TEMP_DIR ${CMAKE_BINARY_DIR}/Testing/Temporary)
#-----------------------------------------------------------------------------
# PkModeling src code
#
add_subdirectory(PkSolver)
add_subdirectory(CLI)
#-----------------------------------------------------------------------------
# PkModelingTargets
#
if(NOT Slicer_DIR)
get_property(PkModeling_TARGETS GLOBAL PROPERTY PkModeling_TARGETS)
export(TARGETS ${PkModeling_TARGETS} FILE ${CMAKE_BINARY_DIR}/PkModelingTargets.cmake)
endif()
#-----------------------------------------------------------------------------
# Version information
#
# Add target extracting version information. The target configures
# 'pkmodelingCPackOptions.cmake' and 'pkmodelingVersionConfigure.h'
#
include(pkmodelingConfigureVersionTarget)
add_dependencies(PkModeling PkModelingConfigureVersion)
#-----------------------------------------------------------------------------
# PkModelingConfig
#
if(NOT Slicer_DIR)
# Configure 'pkmodelingConfig.cmake'
include(CMakePackageConfigHelpers)
# For a build tree
set(CONFIG_DIR_CONFIG ${CMAKE_BINARY_DIR})
set(DCMTK_DIR_CONFIG ${DCMTK_DIR})
set(SlicerExecutionModel_DIR_CONFIG ${SlicerExecutionModel_DIR})
set(${PROJECT_NAME}_CONFIG_CODE "####### Expanded from \@DCMQI_CONFIG_CODE\@ #######\n")
set(${PROJECT_NAME}_CONFIG_CODE "find_package(DCMTK NO_MODULE REQUIRED)\n")
set(${PROJECT_NAME}_CONFIG_CODE "${${PROJECT_NAME}_CONFIG_CODE}##################################################")
set(_config ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake)
configure_package_config_file(
CMake/pkmodelingConfig.cmake.in
${_config}
INSTALL_DESTINATION ${CMAKE_BINARY_DIR}
PATH_VARS
CONFIG_DIR_CONFIG
DCMTK_DIR_CONFIG
SlicerExecutionModel_DIR_CONFIG
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
endif()
#-----------------------------------------------------------------------------
# Packaging
#
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${PROJECT_NAME};RuntimeLibraries;/")
if(DEFINED Slicer_DIR)
include(${Slicer_EXTENSION_CPACK})
else()
if(EXISTS "${PkModeling_DIR}/cmake_install.cmake")
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${DCMTK_DIR};DCMTK;shlib;/")
endif()
if(EXISTS "${ITK_DIR}/cmake_install.cmake")
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${ITK_DIR};ITK;RuntimeLibraries;/")
endif()
set(CPACK_PACKAGE_NAME "PkModeling")
set(CPACK_PACKAGE_VENDOR "Quantitative Image Informatics for Cancer Research (QIICR)")
set(CPACK_PACKAGE_VERSION_MAJOR ${PkModeling_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PkModeling_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PkModeling_VERSION_PATCH})
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CPACK_SYSTEM_NAME "mac")
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CPACK_SYSTEM_NAME "linux")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CPACK_SYSTEM_NAME win64)
else()
set(CPACK_SYSTEM_NAME win32)
endif()
endif()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PkModeling_VERSION}-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${EXTENSION_DESCRIPTION})
if(UNIX)
set(CPACK_GENERATOR "TGZ")
elseif(WIN32)
set(CPACK_GENERATOR "ZIP")
endif()
if(NOT DEFINED PkModeling_CPACK_PROJECT_CONFIG_FILE)
message(FATAL_ERROR "PkModeling_CPACK_PROJECT_CONFIG_FILE is not defined")
endif()
set(CPACK_PROJECT_CONFIG_FILE "${PkModeling_CPACK_PROJECT_CONFIG_FILE}")
include(CPack)
endif()