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 # system libraries
00039 # ============================================================================
00040
00041 # find required runtime libraries
00042 set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
00043 include (InstallRequiredSystemLibraries)
00044
00045 # include system runtime libraries in the installation
00046 if (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
00047 if (WIN32)
00048 install (
00049 PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
00050 DESTINATION ${INSTALL_RUNTIME_DIR}
00051 )
00052 else ()
00053 install (
00054 PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
00055 DESTINATION ${INSTALL_LIBRARY_DIR}
00056 )
00057 endif ()
00058 endif ()
00059
00060 # ============================================================================
00061 # package information
00062 # ============================================================================
00063
00064 # general information
00065 set (CPACK_PACKAGE_NAME "${PROJECT_NAME}")
00066 set (CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
00067 set (CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
00068 set (CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
00069 set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
00070 set (CPACK_PACKAGE_VENDOR "${PROJECT_PACKAGE_VENDOR}")
00071 set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
00072 set (CPACK_RESOURCE_FILE_README "${PROJECT_README_FILE}")
00073 set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_COPYING_FILE}")
00074
00075 if (PROJECT_INSTALL_FILE)
00076 set (CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_INSTALL_FILE}")
00077 endif ()
00078
00079 if (PROJECT_WELCOME_FILE)
00080 set (CPACK_RESOURCE_FILE_WELCOME "${PROJECT_WELCOME_FILE}")
00081 endif ()
00082
00083 set (CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
00084 set (CPACK_PACKAGE_RELOCATABLE "true")
00085
00086 # system name
00087 string (TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME)
00088 if (${CPACK_SYSTEM_NAME} MATCHES "windows")
00089 if (CMAKE_CL_64)
00090 set (CPACK_SYSTEM_NAME "win64")
00091 else ()
00092 set (CPACK_SYSTEM_NAME "win32")
00093 endif ()
00094 endif ()
00095
00096 # binary package
00097 set (CPACK_GENERATOR "TGZ")
00098 set (CPACK_INCLUDE_TOPLEVEL_DIRECTORY "1")
00099 set (CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
00100 set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME_LOWER}-${PROJECT_VERSION}-${CPACK_SYSTEM_NAME}")
00101 if (CMAKE_SYSTEM_PROCESSOR)
00102 set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
00103 endif ()
00104
00105 # source package
00106 set (CPACK_SOURCE_GENERATOR "TGZ")
00107 set (CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-source")
00108 set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME_LOWER}-${PROJECT_VERSION}-source")
00109
00110 # ----------------------------------------------------------------------------
00111 # @todo The proper values for the following options still need to be
00112 # figured. For the moment, just ignore these settings. NSIS might
00113 # anyways not be supported in the near future.
00114 # ----------------------------------------------------------------------------
00115
00116 if (WIN32 AND NOT UNIX)
00117 # There is a bug in NSI that does not handle full unix paths properly. Make
00118 # sure there is at least one set of four (4) backlasshes.
00119 # set (CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
00120 # set (CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
00121 # set (CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
00122 # set (CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.my-project-home-page.org")
00123 # set (CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.my-personal-home-page.com")
00124 set (CPACK_NSIS_CONTACT "sbia-software at uphs.upenn.edu")
00125 set (CPACK_NSIS_MODIFY_PATH "ON")
00126 else ()
00127 # set (CPACK_STRIP_FILES "bin/MyExecutable")
00128 # set (CPACK_SOURCE_STRIP_FILES "")
00129 endif ()
00130
00131 # ============================================================================
00132 # source package
00133 # ============================================================================
00134
00135 ## @brief Patterns to be ignored when creating source package.
00136 # @ingroup BasisSettings
00137 set (
00138 CPACK_SOURCE_IGNORE_FILES
00139 ${CPACK_SOURCE_IGNORE_FILES}
00140 "/CVS/"
00141 "/\\\\.svn/"
00142 "/\\\\.git/"
00143 "\\\\.swp$"
00144 "\\\\.#"
00145 "/#"
00146 "\\\\.*~"
00147 "cscope\\\\.*"
00148 "[b|B]uild"
00149 )
00150
00151 # exclude diabled modules from source package
00152 if (PROJECT_MODULES_DISABLED)
00153 set (P)
00154 foreach (M ${PROJECT_MODULES_DISABLED})
00155 list (APPEND P "/${M}/")
00156 endforeach ()
00157 set (CPACK_SOURCE_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}" "${P}")
00158 unset (P)
00159 endif ()
00160
00161 # ============================================================================
00162 # include project package information
00163 # ============================================================================
00164
00165 if (EXISTS "${PROJECT_CONFIG_DIR}/Package.cmake.in")
00166 configure_file ("${PROJECT_CONFIG_DIR}/Package.cmake.in"
00167 "${PROJECT_BINARY_DIR}/Package.cmake" @ONLY)
00168 include ("${PROJECT_BINARY_DIR}/Package.cmake")
00169 elseif (EXISTS "${PROJECT_CONFIG_DIR}/Package.cmake")
00170 include ("${PROJECT_CONFIG_DIR}/Package.cmake")
00171 endif ()
00172
00173 # ============================================================================
00174 # build package
00175 # ============================================================================
00176
00177 include (CPack)
00178
00179 # ============================================================================
00180 # components
00181 # ============================================================================
00182
00183 # ----------------------------------------------------------------------------
00184 # utilities
00185 # ----------------------------------------------------------------------------
00186
00187 ## @addtogroup CMakeAPI
00188 # @{
00189
00190
00191 # ----------------------------------------------------------------------------
00192 ## @brief Add component group.
00193 #
00194 # @attention This functionality is not yet entirely implemented.
00195 # @todo Come up and implement components concept which fits into superproject concept.
00196 #
00197 # @param [in] GRPNAME Name of the component group.
00198 # @param [in] ARGN Further arguments passed to cpack_add_component_group().
00199 #
00200 # @returns Adds the component group @p GRPNAME.
00201 #
00202 # @sa http://www.cmake.org/pipermail/cmake/2008-August/023336.html
00203 # @sa cpack_add_component_group()
00204 function (basis_add_component_group GRPNAME)
00205 set (OPTION_NAME)
00206 set (PARENT_GROUP)
00207
00208 foreach (ARG ${ARGN})
00209 if (OPTION_NAME)
00210 set (${OPTION_NAME} "${ARG}")
00211 set (OPTION_NAME)
00212 break ()
00213 else ()
00214 if (ARG MATCHES "^PARENT_GROUP$")
00215 set (OPTION_NAME "PARENT_GROUP")
00216 endif ()
00217 endif ()
00218 endforeach ()
00219
00220 cpack_add_component_group (${GRPNAME} ${ARGN})
00221
00222 add_custom_target (install_${GRPNAME})
00223
00224 if (PARENT_GROUP)
00225 add_dependencies (install_${PARENT_GROUP} install_${GRPNAME})
00226 endif ()
00227 endfunction ()
00228
00229 # ----------------------------------------------------------------------------
00230 ## @brief Add component.
00231 #
00232 # @attention This functionality is not yet entirely implemented.
00233 # @todo Come up and implement components concept which fits into superproject concept.
00234 #
00235 # @param [in] COMPNAME Name of the component.
00236 # @param [in] ARGN Further arguments passed to cpack_add_component().
00237 #
00238 # @returns Adds the component named @p COMPNAME.
00239 #
00240 # @sa http://www.cmake.org/pipermail/cmake/2008-August/023336.html
00241 # @sa cpack_add_component()
00242 function (basis_add_component COMPNAME)
00243 set (OPTION_NAME)
00244 set (GROUP)
00245
00246 foreach (ARG ${ARGN})
00247 if (OPTION_NAME)
00248 set (${OPTION_NAME} "${ARG}")
00249 set (OPTION_NAME)
00250 break ()
00251 else ()
00252 if (ARG MATCHES "^GROUP$")
00253 set (OPTION_NAME "GROUP")
00254 endif ()
00255 endif ()
00256 endforeach ()
00257
00258 cpack_add_component (${COMPNAME} ${ARGN})
00259
00260 add_custom_target (
00261 install_${COMPNAME}
00262 COMMAND "${CMAKE_COMMAND}" -DCOMPONENT=${COMPNAME}
00263 -P "${PROJECT_BINARY_DIR}/cmake_install.cmake"
00264 )
00265
00266 if (GROUP)
00267 add_dependencies (install_${GROUP} install_${COMPNAME})
00268 endif ()
00269 endfunction ()
00270
00271 # ----------------------------------------------------------------------------
00272 ## @brief Add pre-configured install type.
00273 #
00274 # @param [in] ARGN Arguments for cpack_add_install_type().
00275 #
00276 # @returns Adds a pre-configured installation type.
00277 #
00278 # @sa CPack.cmake
00279 # @sa cpack_add_install_type ()
00280 function (basis_add_install_type)
00281 cpack_add_install_type (${ARGN})
00282 endfunction ()
00283
00284 # ----------------------------------------------------------------------------
00285 ## @brief Configure installation-time downloads of selected components.
00286 #
00287 # @param [in] ARGN Arguments for cpack_configure_downloads().
00288 #
00289 # @returns Nothing.
00290 #
00291 # @sa CPack.cmake
00292 # @sa cpack_configure_downloads()
00293 function (basis_configure_downloads)
00294 cpack_configure_downloads (${ARGN})
00295 endfunction ()
00296
00297
00298 ## @}
00299 # end of Doxygen group
00300
00301
00302 # ----------------------------------------------------------------------------
00303 # include components definition
00304 # ----------------------------------------------------------------------------
00305
00306 if (EXISTS "${PROJECT_CONFIG_DIR}/Components.cmake.in")
00307 configure_file ("${PROJECT_CONFIG_DIR}/Components.cmake.in"
00308 "${PROJECT_BINARY_DIR}/Components.cmake" @ONLY)
00309 include ("${PROJECT_BINARY_DIR}/Components.cmake")
00310 elseif (EXISTS "${PROJECT_CONFIG_DIR}/Components.cmake")
00311 include ("${PROJECT_CONFIG_DIR}/Components.cmake")
00312 endif ()
00313