CMakeCPack.cmake 8.95 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#=============================================================================
# CMake - Cross Platform Makefile Generator
# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================

13
# If the cmake version includes cpack, use it
14 15 16
if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
  if(EXISTS "${CMAKE_ROOT}/Modules/InstallRequiredSystemLibraries.cmake")
    option(CMAKE_INSTALL_DEBUG_LIBRARIES
17
      "Install Microsoft runtime debug libraries with CMake." FALSE)
18
    mark_as_advanced(CMAKE_INSTALL_DEBUG_LIBRARIES)
19 20

    # By default, do not warn when built on machines using only VS Express:
21 22 23
    if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
      set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
    endif()
24

25 26 27
    if(CMake_INSTALL_DEPENDENCIES)
      include(${CMake_SOURCE_DIR}/Modules/InstallRequiredSystemLibraries.cmake)
    endif()
28
  endif()
29

30 31 32 33
  set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool")
  set(CPACK_PACKAGE_VENDOR "Kitware")
  set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
  set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
34
  set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
35
  set(CPACK_PACKAGE_VERSION "${CMake_VERSION}")
36
  set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
37
  set(CPACK_SOURCE_PACKAGE_FILE_NAME "cmake-${CMake_VERSION}")
38 39 40 41 42

  # Installers for 32- vs. 64-bit CMake:
  #  - Root install directory (displayed to end user at installer-run time)
  #  - "NSIS package/display name" (text used in the installer GUI)
  #  - Registry key used to store info about the installation
43 44
  if(CMAKE_CL_64)
    set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
45
    set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (Win64)")
46 47
  else()
    set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
48
    set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
49
  endif()
50
  set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_NSIS_PACKAGE_NAME}")
51

52
  if(NOT DEFINED CPACK_SYSTEM_NAME)
53 54
    # make sure package is not Cygwin-unknown, for Cygwin just
    # cygwin is good for the system name
55
    if("x${CMAKE_SYSTEM_NAME}" STREQUAL "xCYGWIN")
56
      set(CPACK_SYSTEM_NAME Cygwin)
57
    else()
58
      set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
59 60
    endif()
  endif()
61 62 63
  if(${CPACK_SYSTEM_NAME} MATCHES Windows)
    if(CMAKE_CL_64)
      set(CPACK_SYSTEM_NAME win64-x64)
64
      set(CPACK_IFW_TARGET_DIRECTORY "@RootDir@/Program Files/${CMAKE_PROJECT_NAME}")
65
    else()
66
      set(CPACK_SYSTEM_NAME win32-x86)
67 68
    endif()
  endif()
69

70
  # Components
71 72
  if(CMake_INSTALL_COMPONENTS)
    set(_CPACK_IFW_COMPONENTS_ALL cmake ctest cpack)
73 74 75
    if(WIN32 AND NOT CYGWIN)
        list(APPEND _CPACK_IFW_COMPONENTS_ALL cmcldeps)
    endif()
76 77 78
    if(APPLE)
      list(APPEND _CPACK_IFW_COMPONENTS_ALL cmakexbuild)
    endif()
79 80 81 82 83 84 85 86 87 88 89 90 91 92
    if(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
      set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME
        ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
    else()
      set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME Unspecified)
    endif()
    list(APPEND _CPACK_IFW_COMPONENTS_ALL ${_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME})
    string(TOUPPER "${_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME}"
      _CPACK_IFW_COMPONENT_UNSPECIFIED_UNAME)
    if(BUILD_CursesDialog)
      list(APPEND _CPACK_IFW_COMPONENTS_ALL ccmake)
    endif()
    if(BUILD_QtDialog)
      list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-gui)
93 94
      set(_CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES "set(CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES
    \"LGPLv2.1\" \"${CMake_SOURCE_DIR}/Licenses/LGPLv2.1.txt\")")
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
    endif()
    if(SPHINX_MAN)
      list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-man)
    endif()
    if(SPHINX_HTML)
      list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-html)
    endif()
    if(SPHINX_SINGLEHTML)
      list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-singlehtml)
    endif()
    if(SPHINX_QTHELP)
      list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-qthelp)
    endif()
    set(_CPACK_IFW_COMPONENTS_CONFIGURATION "
  # Components
  set(CPACK_COMPONENTS_ALL \"${_CPACK_IFW_COMPONENTS_ALL}\")
  set(CPACK_COMPONENTS_GROUPING IGNORE)
")
113
  else()
114
    if(BUILD_QtDialog AND USE_LGPL)
115
      set(_CPACK_IFW_ADDITIONAL_LICENSES
116
        "\"LGPLv${USE_LGPL}\" \"${CMake_SOURCE_DIR}/Licenses/LGPLv${USE_LGPL}.txt\"")
117
    endif()
118 119 120 121 122 123 124 125 126 127
  endif()

  # Components scripts configuration
  foreach(_script
    CMake
    CMake.Documentation.SphinxHTML)
    configure_file("${CMake_SOURCE_DIR}/Source/QtIFW/${_script}.qs.in"
      "${CMake_BINARY_DIR}/${_script}.qs" @ONLY)
  endforeach()

128
  if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
129 130
    set(_CPACK_IFW_PACKAGE_ICON
        "set(CPACK_IFW_PACKAGE_ICON \"${CMake_SOURCE_DIR}/Source/QtDialog/CMakeSetup.ico\")")
131 132 133 134 135 136 137 138 139
    if(BUILD_QtDialog)
      set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/bin/cmake-gui.exe\", \"@StartMenuDir@/CMake (cmake-gui).lnk\");\n")
    endif()
    if(SPHINX_HTML)
      set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/html/index.html\", \"@StartMenuDir@/CMake Documentation.lnk\");\n")
    endif()
    configure_file("${CMake_SOURCE_DIR}/Source/QtIFW/installscript.qs.in"
      "${CMake_BINARY_DIR}/installscript.qs" @ONLY
    )
140
    install(FILES "${CMake_SOURCE_DIR}/Source/QtIFW/cmake.org.html"
141
      DESTINATION "${CMAKE_DOC_DIR}"
142
    )
143 144 145 146 147
    if(CMake_INSTALL_COMPONENTS)
      set(_CPACK_IFW_PACKAGE_SCRIPT "${CMake_BINARY_DIR}/CMake.qs")
    else()
      set(_CPACK_IFW_PACKAGE_SCRIPT "${CMake_BINARY_DIR}/installscript.qs")
    endif()
148 149 150 151 152 153 154 155 156
  endif()

  if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
    set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/${CMAKE_PROJECT_NAME}")
    set(CPACK_IFW_ADMIN_TARGET_DIRECTORY "@ApplicationsDir@/${CMAKE_PROJECT_NAME}")
  endif()

  set(_CPACK_IFW_PACKAGE_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH})

157
  if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
158
    # if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
159
    # default to source package - system, on cygwin system is not
160
    # needed
161 162
    if(CYGWIN)
      set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
163
    else()
164
      set(CPACK_PACKAGE_FILE_NAME
165
        "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
166 167
    endif()
  endif()
168

169
  set(CPACK_PACKAGE_CONTACT "cmake@cmake.org")
170

171
  if(UNIX)
172
    set(CPACK_STRIP_FILES "${CMAKE_BIN_DIR}/ccmake;${CMAKE_BIN_DIR}/cmake;${CMAKE_BIN_DIR}/cpack;${CMAKE_BIN_DIR}/ctest")
173 174
    set(CPACK_SOURCE_STRIP_FILES "")
    set(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake")
175
  endif()
176 177

  # cygwin specific packaging stuff
178
  if(CYGWIN)
179
    # setup the cygwin package name
180
    set(CPACK_PACKAGE_NAME cmake)
181
    # setup the name of the package for cygwin cmake-2.4.3
182
    set(CPACK_PACKAGE_FILE_NAME
183
      "${CPACK_PACKAGE_NAME}-${CMake_VERSION}")
184
    # the source has the same name as the binary
185
    set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
186 187
    # Create a cygwin version number in case there are changes for cygwin
    # that are not reflected upstream in CMake
188 189
    set(CPACK_CYGWIN_PATCH_NUMBER 1 CACHE STRING "patch number for CMake cygwin packages")
    mark_as_advanced(CPACK_CYGWIN_PATCH_NUMBER)
190 191
    # These files are required by the cmCPackCygwinSourceGenerator and the files
    # put into the release tar files.
192
    set(CPACK_CYGWIN_BUILD_SCRIPT
193
      "${CMake_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}-${CPACK_CYGWIN_PATCH_NUMBER}.sh")
194
    set(CPACK_CYGWIN_PATCH_FILE
195
      "${CMake_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}-${CPACK_CYGWIN_PATCH_NUMBER}.patch")
196 197 198
    # include the sub directory cmake file for cygwin that
    # configures some files and adds some install targets
    # this file uses some of the package file name variables
199
    include(Utilities/Release/Cygwin/CMakeLists.txt)
200
  endif()
201

202 203
  set(CPACK_WIX_UPGRADE_GUID "8ffd1d72-b7f1-11e2-8ee5-00238bca4991")

204 205 206 207 208 209 210 211 212 213 214
  if(MSVC AND NOT "$ENV{WIX}" STREQUAL "")
    set(WIX_CUSTOM_ACTION_ENABLED TRUE)
    if(CMAKE_CONFIGURATION_TYPES)
      set(WIX_CUSTOM_ACTION_MULTI_CONFIG TRUE)
    else()
      set(WIX_CUSTOM_ACTION_MULTI_CONFIG FALSE)
    endif()
  else()
    set(WIX_CUSTOM_ACTION_ENABLED FALSE)
  endif()

215
  # Set the options file that needs to be included inside CMakeCPackOptions.cmake
216 217
  set(QT_DIALOG_CPACK_OPTIONS_FILE ${CMake_BINARY_DIR}/Source/QtDialog/QtDialogCPack.cmake)
  configure_file("${CMake_SOURCE_DIR}/CMakeCPackOptions.cmake.in"
218
    "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY)
219
  set(CPACK_PROJECT_CONFIG_FILE "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake")
220

221
  # include CPack model once all variables are set
222
  include(CPack)
223
endif()