-
Notifications
You must be signed in to change notification settings - Fork 21
/
SPHARM-PDM.cmake
105 lines (91 loc) · 4.61 KB
/
SPHARM-PDM.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
#-----------------------------------------------------------------------------
find_package(ITK 4 REQUIRED)
include(${ITK_USE_FILE})
find_package(SlicerExecutionModel REQUIRED)
include(${SlicerExecutionModel_USE_FILE})
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
# --------------------------------------------------------------------------
# Bundle extensions adding source directories.
# --------------------------------------------------------------------------
#
# Support for bundling "SuperBuild-type" extension:
#
# * An extension is considered to be of type "SuperBuild" if a directory
# "<extension_dir>/SuperBuild" or "<extension_dir>/Superbuild" exists.
# Corresponding directory is appended to EXTERNAL_PROJECT_ADDITIONAL_DIRS.
#
# * If variable "<extension_name>_EXTERNAL_PROJECT_EXCLUDE_ALL" is set to TRUE, corresponding SuperBuild directory
# is not appended to EXTERNAL_PROJECT_ADDITIONAL_DIRS.
#
# * Associated external projects are globbed using expression of the form
# "<extension_dir>/(SuperBuild|Superbuild)/External_*.cmake".
#
# * List of external project names is extracted from the "External_<projectName>.cmake"
# files and appended to Slicer_DEPENDENCIES. This ensures they are build before Slicer inner build.
# Setting variable "<extension_name>_EXTERNAL_PROJECT_DEPENDENCIES" to a list of <projectName> allows
# to override the list of <projectName> appended to Slicer_DEPENDENCIES.
#
# * Variable Slicer_BUNDLED_EXTENSION_NAMES is updated with the names of external project
# and passed to Slicer inner build. It is then used in SlicerCPack. to package associated
# external projects if the cache variable <extensionName>_CPACK_INSTALL_CMAKE_PROJECTS
# was defined in the extension sources.
#
# Corresponding logic is implemented in SuperBuild.cmake
#
set(extensions_build_dir "${CMAKE_BINARY_DIR}/E")
function(_add_extension_source_dir extension_source_dir what)
get_filename_component(extension_source_dir ${extension_source_dir} REALPATH)
get_filename_component(extension_source_dirname ${extension_source_dir} NAME_WE)
message(STATUS "--------------------------------------------------")
message(STATUS "Configuring ${what}: ${extension_source_dirname}")
set(ExternalData_SOURCE_ROOT ${extension_source_dir})
set(${extension_source_dirname}_SOURCE_DIR ${extension_source_dir})
set(${extension_source_dirname}_BINARY_DIR ${extensions_build_dir}/${extension_source_dirname})
add_subdirectory(
${${extension_source_dirname}_SOURCE_DIR}
${${extension_source_dirname}_BINARY_DIR}
)
endfunction()
if(NOT Slicer_SOURCE_DIR)
foreach(extension_source_dir ${Slicer_EXTENSION_SOURCE_DIRS})
_add_extension_source_dir(${extension_source_dir} "extension directory")
endforeach()
endif()
#-----------------------------------------------------------------------------
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
add_subdirectory(Libraries)
add_subdirectory(Modules)
if (${LOCAL_PROJECT_NAME}_BUILD_SLICER_EXTENSION)
add_subdirectory(CommandLineTool)
endif()
#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
if(SPHARM-PDM_BUILD_TESTING)
include(CTest)
add_subdirectory(Testing)
endif()
#-----------------------------------------------------------------------------
# Packaging
#-----------------------------------------------------------------------------
set(EXTENSION_CPACK_INSTALL_CMAKE_PROJECTS)
if(NOT Slicer_SOURCE_DIR)
foreach(extension_item IN LISTS Slicer_BUNDLED_EXTENSION_NAMES)
list(APPEND EXTENSION_CPACK_INSTALL_CMAKE_PROJECTS ${${EXTENSION_NAME}_CPACK_INSTALL_CMAKE_PROJECTS})
endforeach()
endif()
set(${EXTENSION_NAME}_CPACK_INSTALL_CMAKE_PROJECTS "${EXTENSION_CPACK_INSTALL_CMAKE_PROJECTS}" CACHE STRING "List of external projects to install" FORCE)
#-----------------------------------------------------------------------------
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${EXTENSION_NAME};Runtime;/")
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${EXTENSION_NAME};RuntimeLibraries;/")
if(${LOCAL_PROJECT_NAME}_INSTALL_DEVELOPMENT)
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${CMAKE_BINARY_DIR};${EXTENSION_NAME};Development;/")
endif()
list(APPEND CPACK_INSTALL_CMAKE_PROJECTS "${${EXTENSION_NAME}_CPACK_INSTALL_CMAKE_PROJECTS}")
#-----------------------------------------------------------------------------
if(DEFINED Slicer_DIR)
include(${Slicer_EXTENSION_GENERATE_CONFIG})
include(${Slicer_EXTENSION_CPACK})
endif()