BasisPack.cmake
Go to the documentation of this file.
00001 ############################################################################## 00002 # @file BasisPack.cmake 00003 # @brief CPack configuration. Include this module instead of CPack. 00004 # 00005 # @note This module is included by basis_project_finalize(). 00006 # 00007 # This module implements the packaging of BASIS projects. 00008 # 00009 # Overwrite the package information set by this module either in a file 00010 # Package.cmake or a file Package.cmake.in located in the directory 00011 # specified by PROJECT_CONFIG_DIR. The latter is configured and copied to the 00012 # binary tree before included by this module. Further, to enable a 00013 # component-based installation, provide either a file Components.cmake or 00014 # Components.cmake.in again in the directory specified by PROJECT_CONFIG_DIR. 00015 # Also in this case, the latter is configured via CMake's configure_file() 00016 # before use. This file is referred to as components definition (file). 00017 # 00018 # Components can be added in the components definition using the command 00019 # basis_add_component(). Several components can be grouped together and a 00020 # group description be added using the command basis_add_component_group(). 00021 # Different pre-configured install types which define a certain selection of 00022 # components to install can be added using basis_add_install_type(). 00023 # Note that all these BASIS functions are wrappers around the corresponding 00024 # CPack functions. 00025 # 00026 # @sa CPack.cmake 00027 # @sa http://www.vtk.org/Wiki/CMake:Component_Install_With_CPack#Component-Based_Installers_with_CPack 00028 # 00029 # Copyright (c) 2011-2012 Univeristy of Pennsylvania. All rights reserved.<br /> 00030 # See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file. 00031 # 00032 # Contact: SBIA Group <sbia-software at uphs.upenn.edu> 00033 # 00034 # @ingroup CMakeAPI 00035 ############################################################################## 00036 00037 # ============================================================================ 00038 # local variables 00039 # ============================================================================ 00040 00041 basis_get_relative_path (_TEST_DIR "${PROJECT_SOURCE_DIR}" "${PROJECT_TESTING_DIR}") 00042 basis_get_relative_path (_MODULES_DIR "${PROJECT_SOURCE_DIR}" "${PROJECT_MODULES_DIR}") 00043 00044 # ============================================================================ 00045 # system libraries 00046 # ============================================================================ 00047 00048 # find required runtime libraries 00049 set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) 00050 include (InstallRequiredSystemLibraries) 00051 00052 # include system runtime libraries in the installation 00053 if (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) 00054 if (WIN32) 00055 install ( 00056 PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} 00057 DESTINATION ${INSTALL_RUNTIME_DIR} 00058 ) 00059 else () 00060 install ( 00061 PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} 00062 DESTINATION ${INSTALL_LIBRARY_DIR} 00063 ) 00064 endif () 00065 endif () 00066 00067 # ============================================================================ 00068 # package information 00069 # ============================================================================ 00070 00071 # general information 00072 set (CPACK_PACKAGE_NAME "${PROJECT_PACKAGE}") 00073 set (CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") 00074 set (CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") 00075 set (CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") 00076 set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") 00077 set (CPACK_PACKAGE_VENDOR "${PROJECT_PACKAGE_VENDOR}") 00078 set (CPACK_PACKAGE_CONTACT "${PROJECT_CONTACT}") 00079 set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}") 00080 set (CPACK_RESOURCE_FILE_README "${PROJECT_README_FILE}") 00081 set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_COPYING_FILE}") 00082 00083 if (PROJECT_INSTALL_FILE) 00084 set (CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_INSTALL_FILE}") 00085 endif () 00086 00087 if (PROJECT_WELCOME_FILE) 00088 set (CPACK_RESOURCE_FILE_WELCOME "${PROJECT_WELCOME_FILE}") 00089 endif () 00090 00091 set (CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") 00092 set (CPACK_PACKAGE_RELOCATABLE "true") 00093 00094 # system name 00095 string (TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME) 00096 if (${CPACK_SYSTEM_NAME} MATCHES "windows") 00097 if (CMAKE_CL_64) 00098 set (CPACK_SYSTEM_NAME "win64") 00099 else () 00100 set (CPACK_SYSTEM_NAME "win32") 00101 endif () 00102 endif () 00103 00104 # binary package 00105 set (CPACK_GENERATOR "TGZ") 00106 set (CPACK_INCLUDE_TOPLEVEL_DIRECTORY "1") 00107 set (CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}") 00108 set (CPACK_PACKAGE_FILE_NAME "${PROJECT_PACKAGE_L}-${PROJECT_VERSION}-${CPACK_SYSTEM_NAME}") 00109 if (CMAKE_SYSTEM_PROCESSOR) 00110 set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CMAKE_SYSTEM_PROCESSOR}") 00111 endif () 00112 00113 # source package 00114 set (CPACK_SOURCE_GENERATOR "TGZ") 00115 set (CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-source") 00116 set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_PACKAGE_L}-${PROJECT_VERSION}-source") 00117 00118 # ---------------------------------------------------------------------------- 00119 # TODO The proper values for the following options still need to be 00120 # figured. For the moment, just ignore these settings. NSIS might 00121 # anyways not be supported in the near future. 00122 # ---------------------------------------------------------------------------- 00123 00124 if (WIN32 AND NOT UNIX) 00125 # There is a bug in NSI that does not handle full unix paths properly. Make 00126 # sure there is at least one set of four (4) backlasshes. 00127 # set (CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp") 00128 # set (CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe") 00129 # set (CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}") 00130 # set (CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.my-project-home-page.org") 00131 # set (CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.my-personal-home-page.com") 00132 set (CPACK_NSIS_CONTACT "sbia-software at uphs.upenn.edu") 00133 set (CPACK_NSIS_MODIFY_PATH "ON") 00134 else () 00135 # set (CPACK_STRIP_FILES "bin/MyExecutable") 00136 # set (CPACK_SOURCE_STRIP_FILES "") 00137 endif () 00138 00139 # ============================================================================ 00140 # source package 00141 # ============================================================================ 00142 00143 ## @brief Patterns to be ignored when creating source package. 00144 # @ingroup BasisSettings 00145 list (APPEND CPACK_SOURCE_IGNORE_FILES 00146 "/CVS/" 00147 "/\\\\.svn/" 00148 "/\\\\.git/" 00149 "\\\\.swp$" 00150 "\\\\.#" 00151 "/#" 00152 "\\\\.*~" 00153 "cscope\\\\.*" 00154 "/${_TEST_DIR}/internal/" 00155 ) 00156 00157 # exclude disabled modules from source package 00158 if (PROJECT_MODULES_DISABLED) 00159 foreach (_M ${PROJECT_MODULES_DISABLED}) 00160 list (APPEND CPACK_SOURCE_IGNORE_FILES "/${_MODULES_DIR}/${_M}/") 00161 endforeach () 00162 endif () 00163 00164 # ============================================================================ 00165 # include project package information 00166 # ============================================================================ 00167 00168 if (EXISTS "${PROJECT_CONFIG_DIR}/Package.cmake.in") 00169 configure_file ("${PROJECT_CONFIG_DIR}/Package.cmake.in" 00170 "${PROJECT_BINARY_DIR}/Package.cmake" @ONLY) 00171 include ("${PROJECT_BINARY_DIR}/Package.cmake") 00172 elseif (EXISTS "${PROJECT_CONFIG_DIR}/Package.cmake") 00173 include ("${PROJECT_CONFIG_DIR}/Package.cmake") 00174 endif () 00175 00176 # ============================================================================ 00177 # build package 00178 # ============================================================================ 00179 00180 include (CPack) 00181 00182 # ============================================================================ 00183 # components 00184 # ============================================================================ 00185 00186 # ---------------------------------------------------------------------------- 00187 # utilities 00188 # ---------------------------------------------------------------------------- 00189 00190 ## @addtogroup CMakeAPI 00191 # @{ 00192 00193 00194 # ---------------------------------------------------------------------------- 00195 ## @brief Add component group. 00196 # 00197 # @attention This functionality is not yet entirely implemented. 00198 # @todo Come up and implement components concept which fits into superproject concept. 00199 # 00200 # @param [in] GRPNAME Name of the component group. 00201 # @param [in] ARGN Further arguments passed to cpack_add_component_group(). 00202 # 00203 # @returns Adds the component group @p GRPNAME. 00204 # 00205 # @sa http://www.cmake.org/pipermail/cmake/2008-August/023336.html 00206 # @sa cpack_add_component_group() 00207 function (basis_add_component_group GRPNAME) 00208 set (OPTION_NAME) 00209 set (PARENT_GROUP) 00210 00211 foreach (ARG ${ARGN}) 00212 if (OPTION_NAME) 00213 set (${OPTION_NAME} "${ARG}") 00214 set (OPTION_NAME) 00215 break () 00216 else () 00217 if (ARG MATCHES "^PARENT_GROUP$") 00218 set (OPTION_NAME "PARENT_GROUP") 00219 endif () 00220 endif () 00221 endforeach () 00222 00223 cpack_add_component_group (${GRPNAME} ${ARGN}) 00224 00225 add_custom_target (install_${GRPNAME}) 00226 00227 if (PARENT_GROUP) 00228 add_dependencies (install_${PARENT_GROUP} install_${GRPNAME}) 00229 endif () 00230 endfunction () 00231 00232 # ---------------------------------------------------------------------------- 00233 ## @brief Add component. 00234 # 00235 # @attention This functionality is not yet entirely implemented. 00236 # @todo Come up and implement components concept which fits into superproject concept. 00237 # 00238 # @param [in] COMPNAME Name of the component. 00239 # @param [in] ARGN Further arguments passed to cpack_add_component(). 00240 # 00241 # @returns Adds the component named @p COMPNAME. 00242 # 00243 # @sa http://www.cmake.org/pipermail/cmake/2008-August/023336.html 00244 # @sa cpack_add_component() 00245 function (basis_add_component COMPNAME) 00246 set (OPTION_NAME) 00247 set (GROUP) 00248 00249 foreach (ARG ${ARGN}) 00250 if (OPTION_NAME) 00251 set (${OPTION_NAME} "${ARG}") 00252 set (OPTION_NAME) 00253 break () 00254 else () 00255 if (ARG MATCHES "^GROUP$") 00256 set (OPTION_NAME "GROUP") 00257 endif () 00258 endif () 00259 endforeach () 00260 00261 cpack_add_component (${COMPNAME} ${ARGN}) 00262 00263 add_custom_target ( 00264 install_${COMPNAME} 00265 COMMAND "${CMAKE_COMMAND}" -DCOMPONENT=${COMPNAME} 00266 -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" 00267 ) 00268 00269 if (GROUP) 00270 add_dependencies (install_${GROUP} install_${COMPNAME}) 00271 endif () 00272 endfunction () 00273 00274 # ---------------------------------------------------------------------------- 00275 ## @brief Add pre-configured install type. 00276 # 00277 # @param [in] ARGN Arguments for cpack_add_install_type(). 00278 # 00279 # @returns Adds a pre-configured installation type. 00280 # 00281 # @sa CPack.cmake 00282 # @sa cpack_add_install_type () 00283 function (basis_add_install_type) 00284 cpack_add_install_type (${ARGN}) 00285 endfunction () 00286 00287 # ---------------------------------------------------------------------------- 00288 ## @brief Configure installation-time downloads of selected components. 00289 # 00290 # @param [in] ARGN Arguments for cpack_configure_downloads(). 00291 # 00292 # @returns Nothing. 00293 # 00294 # @sa CPack.cmake 00295 # @sa cpack_configure_downloads() 00296 function (basis_configure_downloads) 00297 cpack_configure_downloads (${ARGN}) 00298 endfunction () 00299 00300 00301 ## @} 00302 # end of Doxygen group 00303 00304 00305 # ---------------------------------------------------------------------------- 00306 # include components definition 00307 # ---------------------------------------------------------------------------- 00308 00309 if (EXISTS "${PROJECT_CONFIG_DIR}/Components.cmake.in") 00310 configure_file ("${PROJECT_CONFIG_DIR}/Components.cmake.in" 00311 "${PROJECT_BINARY_DIR}/Components.cmake" @ONLY) 00312 include ("${PROJECT_BINARY_DIR}/Components.cmake") 00313 elseif (EXISTS "${PROJECT_CONFIG_DIR}/Components.cmake") 00314 include ("${PROJECT_CONFIG_DIR}/Components.cmake") 00315 endif () 00316 00317 # ============================================================================ 00318 # clean up 00319 # ============================================================================ 00320 00321 unset (_M) 00322 unset (_TEST_DIR) 00323 unset (_MODULES_DIR)