Merge branch 'release-3.31'
[kiteware-cmake.git] / CMakeCPack.cmake
bloba0c0e54ffa39b26d5595b323071f302d9823f498
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 option(CMAKE_INSTALL_DEBUG_LIBRARIES
5   "Install Microsoft runtime debug libraries with CMake." FALSE)
6 mark_as_advanced(CMAKE_INSTALL_DEBUG_LIBRARIES)
8 # By default, do not warn when built on machines using only VS Express:
9 if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
10   set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
11 endif()
13 if(CMake_INSTALL_DEPENDENCIES)
14   include(${CMake_SOURCE_DIR}/Modules/InstallRequiredSystemLibraries.cmake)
15 endif()
17 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "CMake is a build tool")
18 set(CPACK_PACKAGE_VENDOR "Kitware")
19 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
20 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
21 set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
22 set(CPACK_PACKAGE_VERSION "${CMake_VERSION}")
23 set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
24 set(CPACK_SOURCE_PACKAGE_FILE_NAME "cmake-${CMake_VERSION}")
25 set(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE OFF)
27 # Installers for 32- vs. 64-bit CMake:
28 #  - Root install directory (displayed to end user at installer-run time)
29 #  - "NSIS package/display name" (text used in the installer GUI)
30 #  - Registry key used to store info about the installation
31 if(CMAKE_CL_64)
32   set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
33   set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION} (Win64)")
34 else()
35   set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
36   set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
37 endif()
38 set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_NSIS_PACKAGE_NAME}")
40 if(NOT DEFINED CPACK_SYSTEM_NAME)
41   # make sure package is not Cygwin-unknown, for Cygwin just
42   # cygwin is good for the system name
43   if("x${CMAKE_SYSTEM_NAME}" STREQUAL "xCYGWIN")
44     set(CPACK_SYSTEM_NAME Cygwin)
45   else()
46     set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR})
47   endif()
48 endif()
49 if(${CPACK_SYSTEM_NAME} MATCHES Windows)
50   if(CMAKE_CL_64)
51     set(CPACK_SYSTEM_NAME win64-x64)
52     set(CPACK_IFW_TARGET_DIRECTORY "@RootDir@/Program Files/${CMAKE_PROJECT_NAME}")
53   else()
54     set(CPACK_SYSTEM_NAME win32-x86)
55   endif()
56 endif()
58 # Command for configure IFW script templates
59 include(${CMake_SOURCE_DIR}/Modules/CPackIFWConfigureFile.cmake)
61 # Advanced IFW configuration
62 set(_cpifwrc CPACK_IFW_COMPONENT_GROUP_CMAKE_)
63 set(_cpifwrcconf _CPACK_IFW_COMPONENT_GROUP_CMAKE)
64 set(${_cpifwrcconf} "# CMake IFW configuration\n")
65 macro(_cmifwarg DESCRIPTION TYPE NAME DEFAULT)
66   set(_var CMake_IFW_ROOT_COMPONENT_${NAME})
67   if(DEFINED ${_var})
68     set(${_var} ${${_var}} CACHE ${TYPE} ${DESCRIPTION})
69     mark_as_advanced(${_var})
70   elseif(NOT "${DEFAULT}" STREQUAL "")
71     set(${_var} ${DEFAULT})
72   endif()
73   if(DEFINED ${_var})
74     set(${_cpifwrcconf}
75       "${${_cpifwrcconf}}  set(${_cpifwrc}${NAME}\n    \"${${_var}}\")\n")
76   endif()
77 endmacro()
79 _cmifwarg("Package <Name> tag (domen-like)"
80   STRING NAME "")
81 _cmifwarg("Package <DisplayName> tag"
82   STRING DISPLAY_NAME "")
83 _cmifwarg("Package <Description> tag"
84   STRING DESCRIPTION "")
85 _cmifwarg("Package <ReleaseDate> tag (keep empty to auto generate)"
86   STRING RELEASE_DATE "")
87 _cmifwarg("Package <Default> tag (values: TRUE, FALSE, SCRIPT)"
88   STRING DEFAULT "")
89 _cmifwarg("Package <Version> tag"
90   STRING VERSION
91   "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
92 _cmifwarg("Package <SortingPriority> tag"
93   STRING PRIORITY "100")
94 _cmifwarg("Package <ForsedInstallation> tag"
95   STRING FORCED_INSTALLATION "")
97 set(${_cpifwrc}LICENSES_DEFAULT
98   "${CPACK_PACKAGE_NAME} Copyright;${CPACK_RESOURCE_FILE_LICENSE}")
100 # Components
101 if(CMake_INSTALL_COMPONENTS)
102   set(_CPACK_IFW_COMPONENTS_ALL cmake ctest cpack)
103   if(WIN32 AND NOT CYGWIN)
104       list(APPEND _CPACK_IFW_COMPONENTS_ALL cmcldeps)
105   endif()
106   if(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
107     set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME
108       ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
109   else()
110     set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME Unspecified)
111   endif()
112   list(APPEND _CPACK_IFW_COMPONENTS_ALL ${_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME})
113   string(TOUPPER "${_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME}"
114     _CPACK_IFW_COMPONENT_UNSPECIFIED_UNAME)
115   if(BUILD_CursesDialog)
116     list(APPEND _CPACK_IFW_COMPONENTS_ALL ccmake)
117   endif()
118   if(BUILD_QtDialog)
119     list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-gui)
120     if(USE_LGPL)
121       set(_CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES "set(CPACK_IFW_COMPONENT_CMAKE-GUI_LICENSES
122   \"LGPLv${USE_LGPL}\" \"${CMake_SOURCE_DIR}/Licenses/LGPLv${USE_LGPL}.txt\")")
123     endif()
124   endif()
125   if(SPHINX_MAN)
126     list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-man)
127   endif()
128   if(SPHINX_HTML)
129     list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-html)
130   endif()
131   if(SPHINX_SINGLEHTML)
132     list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-singlehtml)
133   endif()
134   if(SPHINX_QTHELP)
135     list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-qthelp)
136   endif()
137   if(SPHINX_LATEXPDF)
138     list(APPEND _CPACK_IFW_COMPONENTS_ALL sphinx-latexpdf)
139   endif()
140   if(CMake_BUILD_DEVELOPER_REFERENCE)
141     if(CMake_BUILD_DEVELOPER_REFERENCE_HTML)
142       list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-developer-reference-html)
143     endif()
144     if(CMake_BUILD_DEVELOPER_REFERENCE_QTHELP)
145       list(APPEND _CPACK_IFW_COMPONENTS_ALL cmake-developer-reference-qthelp)
146     endif()
147   endif()
148   set(_CPACK_IFW_COMPONENTS_CONFIGURATION "
149   # Components
150   set(CPACK_COMPONENTS_ALL \"${_CPACK_IFW_COMPONENTS_ALL}\")
151   set(CPACK_COMPONENTS_GROUPING IGNORE)
152   ")
153   _cmifwarg("Package <Script> template"
154     FILEPATH SCRIPT_TEMPLATE "${CMake_SOURCE_DIR}/Source/QtIFW/CMake.qs.in")
155 else()
156   if(BUILD_QtDialog AND USE_LGPL)
157     set(${_cpifwrc}LICENSES_DEFAULT
158       "${${_cpifwrc}LICENSES_DEFAULT};LGPLv${USE_LGPL};${CMake_SOURCE_DIR}/Licenses/LGPLv${USE_LGPL}.txt")
159   endif()
160   _cmifwarg("Package <Script> template"
161     FILEPATH SCRIPT_TEMPLATE "${CMake_SOURCE_DIR}/Source/QtIFW/installscript.qs.in")
162 endif()
163 _cmifwarg("Package <Script> generated"
164   FILEPATH SCRIPT_GENERATED "${CMake_BINARY_DIR}/CMake.qs")
166 _cmifwarg("Package <Licenses> tag (pairs of <display_name> <file_path>)"
167   STRING LICENSES "${${_cpifwrc}LICENSES_DEFAULT}")
169 if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
170   set(_CPACK_IFW_PACKAGE_ICON
171       "set(CPACK_IFW_PACKAGE_ICON \"${CMake_SOURCE_DIR}/Source/QtDialog/CMakeSetup.ico\")")
172   if(BUILD_QtDialog)
173     set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/bin/cmake-gui.exe\", \"@StartMenuDir@/CMake (cmake-gui).lnk\");\n")
174   endif()
175   if(SPHINX_HTML)
176     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")
177   endif()
178   if(CMake_BUILD_DEVELOPER_REFERENCE)
179     if(CMake_BUILD_DEVELOPER_REFERENCE_HTML)
180     set(_CPACK_IFW_SHORTCUT_OPTIONAL "${_CPACK_IFW_SHORTCUT_OPTIONAL}component.addOperation(\"CreateShortcut\", \"@TargetDir@/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/developer-reference/html/index.html\", \"@StartMenuDir@/CMake Developer Reference.lnk\");\n")
181     endif()
182   endif()
183   install(FILES "${CMake_SOURCE_DIR}/Source/QtIFW/cmake.org.html"
184     DESTINATION "${CMAKE_DOC_DIR}"
185   )
186 endif()
188 if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
189   set(CPACK_IFW_TARGET_DIRECTORY "@HomeDir@/${CMAKE_PROJECT_NAME}")
190   set(CPACK_IFW_ADMIN_TARGET_DIRECTORY "@ApplicationsDir@/${CMAKE_PROJECT_NAME}")
191 endif()
193 # Components scripts configuration
194 if((EXISTS "${CMake_IFW_ROOT_COMPONENT_SCRIPT_TEMPLATE}")
195   AND (NOT "${CMake_IFW_ROOT_COMPONENT_SCRIPT_GENERATED}" STREQUAL "")
196   AND (NOT "${CMake_IFW_ROOT_COMPONENT_SCRIPT}"))
197   cpack_ifw_configure_file("${CMake_IFW_ROOT_COMPONENT_SCRIPT_TEMPLATE}"
198     "${CMake_IFW_ROOT_COMPONENT_SCRIPT_GENERATED}")
199   _cmifwarg("Package <Script> tag"
200     FILEPATH SCRIPT "${CMake_IFW_ROOT_COMPONENT_SCRIPT_GENERATED}")
201 endif()
202 foreach(_script
203   CMake.Dialogs.QtGUI
204   CMake.Documentation.SphinxHTML
205   CMake.DeveloperReference.HTML)
206   cpack_ifw_configure_file("${CMake_SOURCE_DIR}/Source/QtIFW/${_script}.qs.in"
207     "${CMake_BINARY_DIR}/${_script}.qs")
208 endforeach()
210 if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
211   # if the CPACK_PACKAGE_FILE_NAME is not defined by the cache
212   # default to source package - system, on cygwin system is not
213   # needed
214   if(CYGWIN)
215     set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
216   else()
217     set(CPACK_PACKAGE_FILE_NAME
218       "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}")
219   endif()
220 endif()
222 set(CPACK_PACKAGE_CONTACT "cmake+development@discourse.cmake.org")
224 if(UNIX)
225   set(CPACK_STRIP_FILES "${CMAKE_BIN_DIR}/ccmake;${CMAKE_BIN_DIR}/cmake;${CMAKE_BIN_DIR}/cpack;${CMAKE_BIN_DIR}/ctest")
226   set(CPACK_SOURCE_STRIP_FILES "")
227   set(CPACK_PACKAGE_EXECUTABLES "ccmake" "CMake")
228 endif()
230 set(CPACK_WIX_UPGRADE_GUID "8ffd1d72-b7f1-11e2-8ee5-00238bca4991")
232 if(CMake_BUILD_WIX_CUSTOM_ACTION)
233   if(CMAKE_CONFIGURATION_TYPES)
234     set(CMake_BUILD_WIX_CUSTOM_ACTION_MULTI_CONFIG TRUE)
235   else()
236     set(CMake_BUILD_WIX_CUSTOM_ACTION_MULTI_CONFIG FALSE)
237   endif()
238 endif()
240 # Set the options file that needs to be included inside CMakeCPackOptions.cmake
241 set(QT_DIALOG_CPACK_OPTIONS_FILE ${CMake_BINARY_DIR}/Source/QtDialog/QtDialogCPack.cmake)
242 configure_file("${CMake_SOURCE_DIR}/CMakeCPackOptions.cmake.in"
243   "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY)
244 set(CPACK_PROJECT_CONFIG_FILE "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake")
246 set(CPACK_SOURCE_IGNORE_FILES
247   # Files specific to version control.
248   "/\\\\.git/"
249   "/\\\\.gitattributes$"
250   "/\\\\.github/"
251   "/\\\\.gitignore$"
252   "/\\\\.hooks-config$"
254   # Cygwin package build.
255   "/\\\\.build/"
257   # Temporary files.
258   "\\\\.swp$"
259   "\\\\.#"
260   "/#"
261   "~$"
262   )
264 if(CMake_CPACK_CUSTOM_SCRIPT)
265   include(${CMake_CPACK_CUSTOM_SCRIPT})
266 endif()
268 # include CPack model once all variables are set
269 include(CPack)