1 # ============================================================================ 2 # Copyright (c) 2011-2012 University of Pennsylvania 3 # Copyright (c) 2013-2016 Andreas Schuh 6 # See COPYING file for license information or visit 7 # https://cmake-basis.github.io/download.html#license 8 # ============================================================================ 10 ############################################################################## 11 # @file SlicerTools.cmake 12 # @brief Definition of tools for Slicer Extensions. 13 ############################################################################## 15 # ---------------------------------------------------------------------------- 23 # ============================================================================ 25 # ============================================================================ 27 # ---------------------------------------------------------------------------- 28 ## @brief Define project meta-data of Slicer module. 30 # This macro should be used instead of basis_project() for a Slicer module. 31 # It extends the considered meta-data by some additional variables that 32 # have to be set for a Slicer module and identifies this project as a Slicer 37 CMAKE_PARSE_ARGUMENTS (
40 "${BASIS_METADATA_LIST_SINGLE};${BASIS_SLICER_METADATA_LIST_SINGLE}
" 41 "${BASIS_METADATA_LIST_MULTI};${BASIS_SLICER_METADATA_LIST_MULTI}
" 44 foreach (_L IN LISTS BASIS_SLICER_METADATA_LIST_MULTI) 45 if (_L MATCHES "^(CATEGORY|CONTRIBUTORS)$
") 46 basis_list_to_delimited_string (PROJECT_${_L} ",
" ${PROJECT_${_L}}) 48 basis_list_to_string (PROJECT_${_L} ${PROJECT_${_L}}) 51 set (PROJECT_IS_SLICER_MODULE TRUE) 52 basis_project_check_metadata () 56 ## @addtogroup CMakeUtilities 60 # ============================================================================ 62 # ============================================================================ 64 # ---------------------------------------------------------------------------- 65 ## @brief Initialize slicer module meta-data. 67 # At the moment, only one module, most often the top-level project can be a 68 # Slicer module, i.e., call basis_slicer_module() either in the 69 # BasisProject.cmake file of the top-level project or in the corresponding file 70 # of at most one of the project modules. 71 macro (basis_slicer_module_initialize) 72 if (NOT PROJECT_IS_MODULE) 74 foreach (_M IN LISTS PROJECT_MODULES_ENABLED) 75 if (${_M}_IS_SLICER_MODULE) 76 math (EXPR _N "${_N} + 1
") 79 if (PROJECT_IS_SLICER_MODULE) 81 message (FATAL_ERROR "BASIS does not support projects with multiple Slicer modules!
") 83 set (_FIND_SLICER TRUE) 86 message (FATAL_ERROR "BASIS does not support projects with multiple Slicer modules!
") 88 set (_FIND_SLICER TRUE) 90 set (_FIND_SLICER FALSE) 92 # convert PROJECT_* or <Module>_* to MODULE_* variables 93 if (PROJECT_IS_SLICER_MODULE) 94 foreach (_D IN LISTS BASIS_SLICER_METADATA_LIST) 95 if (DEFINED PROJECT_${_D}) 96 set (MODULE_${_D} "${PROJECT_${_D}}
") 100 foreach (_M IN LISTS PROJECT_MODULES_ENABLED) 101 if (${_M}_IS_SLICER_MODULE) 102 foreach (_D IN LISTS BASIS_SLICER_METADATA_LIST) 103 if (DEFINED ${_M}_${_D}) 104 set (MODULE_${_D} "${${_M}_${_D}}
") 111 # find Slicer package 114 set (MODULE_DESCRIPTION "${PROJECT_DESCRIPTION}
") 115 set (MODULE_NAME "${PROJECT_NAME}
") 116 set (MODULE_README_FILE "${PROJECT_SOURCE_DIR}/README.txt
") 117 set (MODULE_LICENSE_FILE "${PROJECT_SOURCE_DIR}/COPYING.txt
") 118 set (MODULE_MAJOR_VERSION "${PROJECT_VERSION_MAJOR}
") 119 set (MODULE_MINOR_VERSION "${PROJECT_VERSION_MINOR}
") 120 set (MODULE_PATCH_VERSION "${PROJECT_VERSION_PATCH}
") 121 # skip project() command 122 set (Slicer_SKIP_PROJECT_COMMAND TRUE) 123 set (Slicer_SKIP_USE_FILE_INCLUDE_CHECK TRUE) 124 # work-around for bug 1901 in Slicer 4.1.0 125 set (Slicer_SKIP_SlicerBlockModuleToExtensionMetadata TRUE) 126 basis_slicer_module_to_extension_metadata () 128 basis_find_package (Slicer REQUIRED) 129 basis_use_package (Slicer REQUIRED) 137 # ============================================================================ 138 # auxiliary functions 139 # ============================================================================ 141 # ---------------------------------------------------------------------------- 142 ## @brief Copy MODULE_* metadata to EXTENSION_* metadata of Slicer Extension. 144 # This function is required to work-around bug 1901 in Slicer 4.1.0. It basically 145 # implements what the SlicerBlockModuleToExtensionMetadata.cmake module which 146 # can be found in the Extensions/CMake/ directory of the Slicer 4 source tree 147 # is implementing. The list of metadata has been copied from this particular 148 # CMake module of the 4.1.0 release of Slicer. 150 # @sa http://www.na-mic.org/Bug/view.php?id=1901 151 function (basis_slicer_module_to_extension_metadata) 152 foreach (varname IN ITEMS ${BASIS_SLICER_METADATA_LIST} DESCRIPTION) 153 if (DEFINED MODULE_${varname} AND NOT DEFINED EXTENSION_${varname}) 154 set (EXTENSION_${varname} ${MODULE_${varname}} PARENT_SCOPE) 161 # Doxygen group CMakeUtilities string PROJECT
Project name.
BASIS_METADATA_LIST_SWITCH
Names of project meta-data switches.
macro basis_slicer_module()
Define project meta-data of Slicer module.