CPack.cmake 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. CPack
  5. -----
  6. Configure generators for binary installers and source packages.
  7. Introduction
  8. ^^^^^^^^^^^^
  9. The CPack module generates the configuration files ``CPackConfig.cmake``
  10. and ``CPackSourceConfig.cmake``. They are intended for use in a subsequent
  11. run of the :manual:`cpack <cpack(1)>` program where they steer the generation
  12. of installers or/and source packages.
  13. Depending on the CMake generator, the CPack module may also add two new build
  14. targets, ``package`` and ``package_source``. See the `packaging targets`_
  15. section below for details.
  16. The generated binary installers will contain all files that have been installed
  17. via CMake's :command:`install` command (and the deprecated commands
  18. :command:`install_files`, :command:`install_programs`, and
  19. :command:`install_targets`). Note that the ``DESTINATION`` option of the
  20. :command:`install` command must be a relative path; otherwise installed files
  21. are ignored by CPack.
  22. Certain kinds of binary installers can be configured such that users can select
  23. individual application components to install. See the :module:`CPackComponent`
  24. module for further details.
  25. Source packages (configured through ``CPackSourceConfig.cmake`` and generated
  26. by the :cpack_gen:`CPack Archive Generator`) will contain all source files in
  27. the project directory except those specified in
  28. :variable:`CPACK_SOURCE_IGNORE_FILES`.
  29. CPack Generators
  30. ^^^^^^^^^^^^^^^^
  31. The :variable:`CPACK_GENERATOR` variable has different meanings in different
  32. contexts. In a ``CMakeLists.txt`` file, :variable:`CPACK_GENERATOR` is a
  33. *list of generators*: and when :manual:`cpack <cpack(1)>` is run with no other
  34. arguments, it will iterate over that list and produce one package for each
  35. generator. In a :variable:`CPACK_PROJECT_CONFIG_FILE`,
  36. :variable:`CPACK_GENERATOR` is a *string naming a single generator*. If you
  37. need per-cpack-generator logic to control *other* cpack settings, then you
  38. need a :variable:`CPACK_PROJECT_CONFIG_FILE`.
  39. If set, the :variable:`CPACK_PROJECT_CONFIG_FILE` is included automatically
  40. on a per-generator basis. It only need contain overrides.
  41. Here's how it works:
  42. * :manual:`cpack <cpack(1)>` runs
  43. * it includes ``CPackConfig.cmake``
  44. * it iterates over the generators given by the :option:`-G <cpack -G>` command
  45. line option, or if no such option was specified, over the list of generators
  46. given by the :variable:`CPACK_GENERATOR` variable set in the ``CPackConfig.cmake``
  47. input file.
  48. * foreach generator, it then
  49. - sets :variable:`CPACK_GENERATOR` to the one currently being iterated
  50. - includes the :variable:`CPACK_PROJECT_CONFIG_FILE`
  51. - produces the package for that generator
  52. This is the key: For each generator listed in :variable:`CPACK_GENERATOR` in
  53. ``CPackConfig.cmake``, cpack will *reset* :variable:`CPACK_GENERATOR`
  54. internally to *the one currently being used* and then include the
  55. :variable:`CPACK_PROJECT_CONFIG_FILE`.
  56. For a list of available generators, see :manual:`cpack-generators(7)`.
  57. .. _`packaging targets`:
  58. Targets package and package_source
  59. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  60. If CMake is run with the Makefile, Ninja, or Xcode generator, then
  61. ``include(CPack)`` generates a target ``package``. This makes it possible
  62. to build a binary installer from CMake, Make, or Ninja: Instead of ``cpack``,
  63. one may call ``cmake --build . --target package`` or ``make package`` or
  64. ``ninja package``. The VS generator creates an uppercase target ``PACKAGE``.
  65. If CMake is run with the Makefile or Ninja generator, then ``include(CPack)``
  66. also generates a target ``package_source``. To build a source package,
  67. instead of ``cpack -G TGZ --config CPackSourceConfig.cmake`` one may call
  68. ``cmake --build . --target package_source``, ``make package_source``,
  69. or ``ninja package_source``.
  70. Variables common to all CPack Generators
  71. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  72. Before including this CPack module in your ``CMakeLists.txt`` file, there
  73. are a variety of variables that can be set to customize the resulting
  74. installers. The most commonly-used variables are:
  75. .. variable:: CPACK_PACKAGE_NAME
  76. The name of the package (or application). If not specified, it defaults to
  77. the project name.
  78. .. variable:: CPACK_PACKAGE_VENDOR
  79. The name of the package vendor. (e.g., "Kitware"). The default is "Humanity".
  80. .. variable:: CPACK_PACKAGE_DIRECTORY
  81. The directory in which CPack is doing its packaging. If it is not set
  82. then this will default (internally) to the build dir. This variable may
  83. be defined in a CPack config file or from the :manual:`cpack <cpack(1)>`
  84. command line option ``-B``. If set, the command line option overrides the
  85. value found in the config file.
  86. .. variable:: CPACK_PACKAGE_VERSION_MAJOR
  87. Package major version. This variable will always be set, but its default
  88. value depends on whether or not version details were given to the
  89. :command:`project` command in the top level CMakeLists.txt file. If version
  90. details were given, the default value will be
  91. :variable:`CMAKE_PROJECT_VERSION_MAJOR`. If no version details were given,
  92. a default version of 0.1.1 will be assumed, leading to
  93. ``CPACK_PACKAGE_VERSION_MAJOR`` having a default value of 0.
  94. .. variable:: CPACK_PACKAGE_VERSION_MINOR
  95. Package minor version. The default value is determined based on whether or
  96. not version details were given to the :command:`project` command in the top
  97. level CMakeLists.txt file. If version details were given, the default
  98. value will be :variable:`CMAKE_PROJECT_VERSION_MINOR`, but if no minor
  99. version component was specified then ``CPACK_PACKAGE_VERSION_MINOR`` will be
  100. left unset. If no project version was given at all, a default version of
  101. 0.1.1 will be assumed, leading to ``CPACK_PACKAGE_VERSION_MINOR`` having a
  102. default value of 1.
  103. .. variable:: CPACK_PACKAGE_VERSION_PATCH
  104. Package patch version. The default value is determined based on whether or
  105. not version details were given to the :command:`project` command in the top
  106. level CMakeLists.txt file. If version details were given, the default
  107. value will be :variable:`CMAKE_PROJECT_VERSION_PATCH`, but if no patch
  108. version component was specified then ``CPACK_PACKAGE_VERSION_PATCH`` will be
  109. left unset. If no project version was given at all, a default version of
  110. 0.1.1 will be assumed, leading to ``CPACK_PACKAGE_VERSION_PATCH`` having a
  111. default value of 1.
  112. .. variable:: CPACK_PACKAGE_DESCRIPTION
  113. A description of the project, used in places such as the introduction
  114. screen of CPack-generated Windows installers. If not set, the value of
  115. this variable is populated from the file named by
  116. :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`.
  117. .. variable:: CPACK_PACKAGE_DESCRIPTION_FILE
  118. A text file used to describe the project when
  119. :variable:`CPACK_PACKAGE_DESCRIPTION` is not explicitly set. The default
  120. value for ``CPACK_PACKAGE_DESCRIPTION_FILE`` points to a built-in template
  121. file ``Templates/CPack.GenericDescription.txt``.
  122. .. variable:: CPACK_PACKAGE_DESCRIPTION_SUMMARY
  123. Short description of the project (only a few words). If the
  124. :variable:`CMAKE_PROJECT_DESCRIPTION` variable is set, it is used as the
  125. default value, otherwise the default will be a string generated by CMake
  126. based on :variable:`CMAKE_PROJECT_NAME`.
  127. .. variable:: CPACK_PACKAGE_HOMEPAGE_URL
  128. Project homepage URL. The default value is taken from the
  129. :variable:`CMAKE_PROJECT_HOMEPAGE_URL` variable, which is set by the top
  130. level :command:`project` command, or else the default will be empty if no
  131. URL was provided to :command:`project`.
  132. .. variable:: CPACK_PACKAGE_FILE_NAME
  133. The name of the package file to generate, not including the
  134. extension. For example, ``cmake-2.6.1-Linux-i686``. The default value
  135. is::
  136. ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}
  137. .. variable:: CPACK_PACKAGE_INSTALL_DIRECTORY
  138. Installation directory on the target system. This may be used by some
  139. CPack generators like NSIS to create an installation directory e.g.,
  140. "CMake 2.5" below the installation prefix. All installed elements will be
  141. put inside this directory.
  142. .. variable:: CPACK_PACKAGE_ICON
  143. A branding image that will be displayed inside the installer (used by GUI
  144. installers).
  145. .. variable:: CPACK_PACKAGE_CHECKSUM
  146. .. versionadded:: 3.7
  147. An algorithm that will be used to generate an additional file with the
  148. checksum of the package. The output file name will be::
  149. ${CPACK_PACKAGE_FILE_NAME}.${CPACK_PACKAGE_CHECKSUM}
  150. Supported algorithms are those listed by the
  151. :ref:`string(\<HASH\>) <Supported Hash Algorithms>` command.
  152. .. variable:: CPACK_PROJECT_CONFIG_FILE
  153. CPack-time project CPack configuration file. This file is included at cpack
  154. time, once per generator after CPack has set :variable:`CPACK_GENERATOR`
  155. to the actual generator being used. It allows per-generator setting of
  156. ``CPACK_*`` variables at cpack time.
  157. .. variable:: CPACK_RESOURCE_FILE_LICENSE
  158. License to be embedded in the installer. It will typically be displayed
  159. to the user by the produced installer (often with an explicit "Accept"
  160. button, for graphical installers) prior to installation. This license
  161. file is NOT added to the installed files but is used by some CPack generators
  162. like NSIS. If you want to use UTF-8 characters, the file needs to be encoded
  163. in UTF-8 BOM. If you want to install a license file (may be the same as this
  164. one) along with your project, you must add an appropriate CMake
  165. :command:`install` command in your ``CMakeLists.txt``.
  166. .. variable:: CPACK_RESOURCE_FILE_README
  167. ReadMe file to be embedded in the installer. It typically describes in
  168. some detail the purpose of the project during the installation. Not all
  169. CPack generators use this file.
  170. .. variable:: CPACK_RESOURCE_FILE_WELCOME
  171. Welcome file to be embedded in the installer. It welcomes users to this
  172. installer. Typically used in the graphical installers on Windows and Mac
  173. OS X.
  174. .. variable:: CPACK_MONOLITHIC_INSTALL
  175. Disables the component-based installation mechanism. When set, the
  176. component specification is ignored and all installed items are put in a
  177. single "MONOLITHIC" package. Some CPack generators do monolithic
  178. packaging by default and may be asked to do component packaging by
  179. setting ``CPACK_<GENNAME>_COMPONENT_INSTALL`` to ``TRUE``.
  180. .. variable:: CPACK_GENERATOR
  181. List of CPack generators to use. If not specified, CPack will create a
  182. set of options following the naming pattern
  183. :variable:`CPACK_BINARY_<GENNAME>` (e.g. ``CPACK_BINARY_NSIS``) allowing
  184. the user to enable/disable individual generators. If the :option:`-G <cpack -G>`
  185. option is given on the :manual:`cpack <cpack(1)>` command line, it will override
  186. this variable and any ``CPACK_BINARY_<GENNAME>`` options.
  187. .. variable:: CPACK_OUTPUT_CONFIG_FILE
  188. The name of the CPack binary configuration file. This file is the CPack
  189. configuration generated by the CPack module for binary installers.
  190. Defaults to ``CPackConfig.cmake``.
  191. .. variable:: CPACK_PACKAGE_EXECUTABLES
  192. Lists each of the executables and associated text label to be used to
  193. create Start Menu shortcuts. For example, setting this to the list
  194. ``ccmake;CMake`` will create a shortcut named "CMake" that will execute the
  195. installed executable :program:`ccmake`. Not all CPack generators use it (at least
  196. NSIS, Inno Setup and WIX do).
  197. .. variable:: CPACK_STRIP_FILES
  198. List of files to be stripped. Starting with CMake 2.6.0,
  199. ``CPACK_STRIP_FILES`` will be a boolean variable which enables
  200. stripping of all files (a list of files evaluates to ``TRUE`` in CMake,
  201. so this change is compatible).
  202. .. variable:: CPACK_VERBATIM_VARIABLES
  203. .. versionadded:: 3.4
  204. If set to ``TRUE``, values of variables prefixed with ``CPACK_`` will be
  205. escaped before being written to the configuration files, so that the cpack
  206. program receives them exactly as they were specified. If not, characters
  207. like quotes and backslashes can cause parsing errors or alter the value
  208. received by the cpack program. Defaults to ``FALSE`` for backwards
  209. compatibility.
  210. .. variable:: CPACK_THREADS
  211. .. versionadded:: 3.20
  212. Number of threads to use when performing parallelized operations, such
  213. as compressing the installer package.
  214. Some compression methods used by CPack generators such as Debian or Archive
  215. may take advantage of multiple CPU cores to speed up compression.
  216. ``CPACK_THREADS`` can be set to specify how many threads will be
  217. used for compression.
  218. A positive integer can be used to specify an exact desired thread count.
  219. When given a negative integer CPack will use the absolute value
  220. as the upper limit but may choose a lower value based on
  221. the available hardware concurrency.
  222. Given 0 CPack will try to use all available CPU cores.
  223. By default ``CPACK_THREADS`` is set to ``1``.
  224. The following compression methods may take advantage of multiple cores:
  225. ``xz``
  226. Supported if CMake is built with a ``liblzma`` that supports
  227. parallel compression.
  228. .. versionadded:: 3.21
  229. Official CMake binaries available on ``cmake.org`` now ship
  230. with a ``liblzma`` that supports parallel compression.
  231. Older versions did not.
  232. ``zstd``
  233. .. versionadded:: 3.24
  234. Supported if CMake is built with libarchive 3.6 or higher.
  235. Official CMake binaries available on ``cmake.org`` support it.
  236. Other compression methods ignore this value and use only one thread.
  237. Variables for Source Package Generators
  238. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  239. The following CPack variables are specific to source packages, and
  240. will not affect binary packages:
  241. .. variable:: CPACK_SOURCE_PACKAGE_FILE_NAME
  242. The name of the source package. For example ``cmake-2.6.1``.
  243. .. variable:: CPACK_SOURCE_STRIP_FILES
  244. List of files in the source tree that will be stripped. Starting with
  245. CMake 2.6.0, ``CPACK_SOURCE_STRIP_FILES`` will be a boolean
  246. variable which enables stripping of all files (a list of files evaluates
  247. to ``TRUE`` in CMake, so this change is compatible).
  248. .. variable:: CPACK_SOURCE_GENERATOR
  249. List of generators used for the source packages. As with
  250. :variable:`CPACK_GENERATOR`, if this is not specified then CPack will
  251. create a set of options (e.g. ``CPACK_SOURCE_ZIP``) allowing
  252. users to select which packages will be generated.
  253. .. variable:: CPACK_SOURCE_OUTPUT_CONFIG_FILE
  254. The name of the CPack source configuration file. This file is the CPack
  255. configuration generated by the CPack module for source installers.
  256. Defaults to ``CPackSourceConfig.cmake``.
  257. .. variable:: CPACK_SOURCE_IGNORE_FILES
  258. Pattern of files in the source tree that won't be packaged when building
  259. a source package. This is a list of regular expression patterns (that
  260. must be properly escaped), e.g.,
  261. ``/CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.*``
  262. Variables for Advanced Use
  263. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  264. The following variables are for advanced uses of CPack:
  265. .. variable:: CPACK_CMAKE_GENERATOR
  266. What CMake generator should be used if the project is a CMake
  267. project. Defaults to the value of :variable:`CMAKE_GENERATOR`. Few users
  268. will want to change this setting.
  269. .. variable:: CPACK_INSTALL_CMAKE_PROJECTS
  270. List of four values that specify what project to install. The four values
  271. are: Build directory, Project Name, Project Component, Directory. If
  272. omitted, CPack will build an installer that installs everything.
  273. .. variable:: CPACK_SYSTEM_NAME
  274. System name, defaults to the value of :variable:`CMAKE_SYSTEM_NAME`,
  275. except on Windows where it will be ``win32`` or ``win64``.
  276. .. variable:: CPACK_PACKAGE_VERSION
  277. Package full version, used internally. By default, this is built from
  278. :variable:`CPACK_PACKAGE_VERSION_MAJOR`,
  279. :variable:`CPACK_PACKAGE_VERSION_MINOR`, and
  280. :variable:`CPACK_PACKAGE_VERSION_PATCH`.
  281. .. variable:: CPACK_TOPLEVEL_TAG
  282. Directory for the installed files.
  283. .. variable:: CPACK_INSTALL_COMMANDS
  284. Extra commands to install components. The environment variable
  285. ``CMAKE_INSTALL_PREFIX`` is set to the temporary install directory
  286. during execution.
  287. .. variable:: CPACK_INSTALL_SCRIPTS
  288. .. versionadded:: 3.16
  289. Extra CMake scripts executed by CPack during its local staging
  290. installation. They are executed before installing the files to be packaged.
  291. The scripts are not called by a standalone install (e.g.: ``make install``).
  292. For every script, the following variables will be set:
  293. :variable:`CMAKE_CURRENT_SOURCE_DIR`, :variable:`CMAKE_CURRENT_BINARY_DIR`
  294. and :variable:`CMAKE_INSTALL_PREFIX` (which is set to the staging install
  295. directory). The singular form ``CMAKE_INSTALL_SCRIPT`` is supported as
  296. an alternative variable for historical reasons, but its value is ignored if
  297. ``CMAKE_INSTALL_SCRIPTS`` is set and a warning will be issued.
  298. See also :variable:`CPACK_PRE_BUILD_SCRIPTS` and
  299. :variable:`CPACK_POST_BUILD_SCRIPTS` which can be used to specify scripts
  300. to be executed later in the packaging process.
  301. .. variable:: CPACK_PRE_BUILD_SCRIPTS
  302. .. versionadded:: 3.19
  303. List of CMake scripts to execute after CPack has installed the files to
  304. be packaged into a staging directory and before producing the package(s)
  305. from those files. See also :variable:`CPACK_INSTALL_SCRIPTS` and
  306. :variable:`CPACK_POST_BUILD_SCRIPTS`.
  307. .. variable:: CPACK_POST_BUILD_SCRIPTS
  308. .. versionadded:: 3.19
  309. List of CMake scripts to execute after CPack has produced the resultant
  310. packages and before copying them back to the build directory.
  311. See also :variable:`CPACK_INSTALL_SCRIPTS`,
  312. :variable:`CPACK_PRE_BUILD_SCRIPTS` and :variable:`CPACK_PACKAGE_FILES`.
  313. .. variable:: CPACK_PACKAGE_FILES
  314. .. versionadded:: 3.19
  315. List of package files created in the staging directory, with each file
  316. provided as a full absolute path. This variable is populated by CPack
  317. just before invoking the post-build scripts listed in
  318. :variable:`CPACK_POST_BUILD_SCRIPTS`. It is the preferred way for the
  319. post-build scripts to know the set of package files to operate on.
  320. Projects should not try to set this variable themselves.
  321. .. variable:: CPACK_INSTALLED_DIRECTORIES
  322. Extra directories to install.
  323. .. variable:: CPACK_PACKAGE_INSTALL_REGISTRY_KEY
  324. Registry key used when installing this project. This is only used by
  325. installers for Windows. The default value is based on the installation
  326. directory.
  327. .. variable:: CPACK_CREATE_DESKTOP_LINKS
  328. List of desktop links to create. Each desktop link requires a
  329. corresponding start menu shortcut as created by
  330. :variable:`CPACK_PACKAGE_EXECUTABLES`.
  331. .. variable:: CPACK_BINARY_<GENNAME>
  332. CPack generated options for binary generators. The ``CPack.cmake`` module
  333. generates (when :variable:`CPACK_GENERATOR` is not set) a set of CMake
  334. options (see CMake :command:`option` command) which may then be used to
  335. select the CPack generator(s) to be used when building the ``package``
  336. target or when running :manual:`cpack <cpack(1)>` without the
  337. :option:`-G <cpack -G>` option.
  338. .. variable:: CPACK_READELF_EXECUTABLE
  339. .. versionadded:: 3.25
  340. Specify the ``readelf`` executable path used by CPack.
  341. The default value will be taken from the ``CMAKE_READELF`` variable, if set,
  342. which may be populated by an internal CMake module. If ``CMAKE_READELF``
  343. is not set, CPack will use :command:`find_program` to determine the
  344. ``readelf`` path when needed.
  345. .. variable:: CPACK_OBJCOPY_EXECUTABLE
  346. .. versionadded:: 3.25
  347. Specify the ``objcopy`` executable path used by CPack.
  348. The default value will be taken from the ``CMAKE_OBJCOPY`` variable, if set,
  349. which may be populated by an internal CMake module. If ``CMAKE_OBJCOPY``
  350. is not set, CPack will use :command:`find_program` to determine the
  351. ``objcopy`` path when needed.
  352. .. variable:: CPACK_OBJDUMP_EXECUTABLE
  353. .. versionadded:: 3.25
  354. Specify the ``objdump`` executable path used by CPack.
  355. The default value will be taken from the ``CMAKE_OBJDUMP`` variable, if set,
  356. which may be populated by an internal CMake module. If ``CMAKE_OBJDUMP``
  357. is not set, CPack will use :command:`find_program` to determine the
  358. ``objdump`` path when needed.
  359. #]=======================================================================]
  360. # Define this var in order to avoid (or warn) concerning multiple inclusion
  361. if(CPack_CMake_INCLUDED)
  362. message(WARNING "CPack.cmake has already been included!!")
  363. else()
  364. set(CPack_CMake_INCLUDED 1)
  365. endif()
  366. # Pick a configuration file
  367. set(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
  368. if(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  369. set(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  370. endif()
  371. set(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
  372. if(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  373. set(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  374. endif()
  375. # Backward compatibility
  376. # Include CPackComponent macros if it has not already been included before.
  377. include(CPackComponent)
  378. # Macro for setting values if a user did not overwrite them
  379. # Mangles CMake-special characters. Only kept for backwards compatibility.
  380. macro(cpack_set_if_not_set name value)
  381. message(DEPRECATION "cpack_set_if_not_set is obsolete; do not use.")
  382. _cpack_set_default("${name}" "${value}")
  383. endmacro()
  384. # cpack_encode_variables - Function to encode variables for the configuration file
  385. # find any variable that starts with CPACK and create a variable
  386. # _CPACK_OTHER_VARIABLES_ that contains SET commands for
  387. # each cpack variable. _CPACK_OTHER_VARIABLES_ is then
  388. # used as an @ replacement in configure_file for the CPackConfig.
  389. function(cpack_encode_variables)
  390. set(commands "")
  391. get_cmake_property(res VARIABLES)
  392. foreach(var ${res})
  393. if(var MATCHES "^CPACK")
  394. if(CPACK_VERBATIM_VARIABLES)
  395. _cpack_escape_for_cmake(value "${${var}}")
  396. else()
  397. set(value "${${var}}")
  398. endif()
  399. string(APPEND commands "\nset(${var} \"${value}\")")
  400. endif()
  401. endforeach()
  402. set(_CPACK_OTHER_VARIABLES_ "${commands}" PARENT_SCOPE)
  403. endfunction()
  404. # Internal use functions
  405. function(_cpack_set_default name value)
  406. if(NOT DEFINED "${name}")
  407. set("${name}" "${value}" PARENT_SCOPE)
  408. endif()
  409. endfunction()
  410. function(_cpack_escape_for_cmake var value)
  411. string(REGEX REPLACE "([\\\$\"])" "\\\\\\1" escaped "${value}")
  412. set("${var}" "${escaped}" PARENT_SCOPE)
  413. endfunction()
  414. # Set the package name
  415. _cpack_set_default(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
  416. # Set the package version
  417. if(CMAKE_PROJECT_VERSION_MAJOR GREATER_EQUAL 0)
  418. _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_PROJECT_VERSION_MAJOR}")
  419. if(CMAKE_PROJECT_VERSION_MINOR GREATER_EQUAL 0)
  420. _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_PROJECT_VERSION_MINOR}")
  421. if(CMAKE_PROJECT_VERSION_PATCH GREATER_EQUAL 0)
  422. _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "${CMAKE_PROJECT_VERSION_PATCH}")
  423. endif()
  424. endif()
  425. else()
  426. _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0")
  427. _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1")
  428. _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1")
  429. endif()
  430. if(NOT DEFINED CPACK_PACKAGE_VERSION)
  431. set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}")
  432. if(CPACK_PACKAGE_VERSION_MINOR GREATER_EQUAL 0)
  433. string(APPEND CPACK_PACKAGE_VERSION ".${CPACK_PACKAGE_VERSION_MINOR}")
  434. if(CPACK_PACKAGE_VERSION_PATCH GREATER_EQUAL 0)
  435. string(APPEND CPACK_PACKAGE_VERSION ".${CPACK_PACKAGE_VERSION_PATCH}")
  436. endif()
  437. endif()
  438. endif()
  439. _cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity")
  440. set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY "${CMAKE_PROJECT_NAME} built using CMake")
  441. if(CMAKE_PROJECT_DESCRIPTION)
  442. _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
  443. "${CMAKE_PROJECT_DESCRIPTION}")
  444. else()
  445. _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
  446. "${CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY}")
  447. endif()
  448. if(CMAKE_PROJECT_HOMEPAGE_URL)
  449. _cpack_set_default(CPACK_PACKAGE_HOMEPAGE_URL
  450. "${CMAKE_PROJECT_HOMEPAGE_URL}")
  451. endif()
  452. set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE
  453. "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
  454. _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE
  455. "${CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE}")
  456. _cpack_set_default(CPACK_RESOURCE_FILE_LICENSE
  457. "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
  458. _cpack_set_default(CPACK_RESOURCE_FILE_README
  459. "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
  460. _cpack_set_default(CPACK_RESOURCE_FILE_WELCOME
  461. "${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt")
  462. _cpack_set_default(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
  463. if(CMAKE_READELF)
  464. _cpack_set_default(CPACK_READELF_EXECUTABLE "${CMAKE_READELF}")
  465. endif()
  466. if(CMAKE_OBJCOPY)
  467. _cpack_set_default(CPACK_OBJCOPY_EXECUTABLE "${CMAKE_OBJCOPY}")
  468. endif()
  469. if(CMAKE_OBJDUMP)
  470. _cpack_set_default(CPACK_OBJDUMP_EXECUTABLE "${CMAKE_OBJDUMP}")
  471. endif()
  472. # Set default directory creation permissions mode
  473. if(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS)
  474. _cpack_set_default(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
  475. "${CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS}")
  476. endif()
  477. if(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
  478. set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
  479. endif()
  480. if(CPACK_NSIS_MODIFY_PATH)
  481. set(CPACK_NSIS_MODIFY_PATH ON)
  482. endif()
  483. set(__cpack_system_name ${CMAKE_SYSTEM_NAME})
  484. if(__cpack_system_name MATCHES "Windows")
  485. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  486. set(__cpack_system_name win64)
  487. else()
  488. set(__cpack_system_name win32)
  489. endif()
  490. endif()
  491. _cpack_set_default(CPACK_SYSTEM_NAME "${__cpack_system_name}")
  492. # Root dir: default value should be the string literal "$PROGRAMFILES"
  493. # for backwards compatibility. Projects may set this value to anything.
  494. # When creating 64 bit binaries we set the default value to "$PROGRAMFILES64"
  495. if("x${__cpack_system_name}" STREQUAL "xwin64")
  496. set(__cpack_root_default "$PROGRAMFILES64")
  497. else()
  498. set(__cpack_root_default "$PROGRAMFILES")
  499. endif()
  500. _cpack_set_default(CPACK_NSIS_INSTALL_ROOT "${__cpack_root_default}")
  501. # <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
  502. _cpack_set_default(CPACK_PACKAGE_FILE_NAME
  503. "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
  504. _cpack_set_default(CPACK_PACKAGE_INSTALL_DIRECTORY
  505. "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
  506. _cpack_set_default(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
  507. "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  508. _cpack_set_default(CPACK_PACKAGE_DEFAULT_LOCATION "/")
  509. _cpack_set_default(CPACK_PACKAGE_RELOCATABLE "true")
  510. # always force to exactly "true" or "false" for CPack.Info.plist.in:
  511. if(CPACK_PACKAGE_RELOCATABLE)
  512. set(CPACK_PACKAGE_RELOCATABLE "true")
  513. else()
  514. set(CPACK_PACKAGE_RELOCATABLE "false")
  515. endif()
  516. macro(cpack_check_file_exists file description)
  517. if(NOT EXISTS "${file}")
  518. message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
  519. endif()
  520. endmacro()
  521. cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description")
  522. cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource")
  523. cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}" "readme resource")
  524. cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource")
  525. macro(cpack_optional_append _list _cond _item)
  526. if(${_cond})
  527. set(${_list} ${${_list}} ${_item})
  528. endif()
  529. endmacro()
  530. # Provide options to choose generators we might check here if the required
  531. # tools for the generators exist and set the defaults according to the
  532. # results.
  533. if(NOT CPACK_GENERATOR)
  534. if(UNIX)
  535. if(CYGWIN)
  536. option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON)
  537. else()
  538. if(APPLE)
  539. option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF)
  540. option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF)
  541. option(CPACK_BINARY_PRODUCTBUILD "Enable to build productbuild packages" OFF)
  542. mark_as_advanced(
  543. CPACK_BINARY_BUNDLE
  544. CPACK_BINARY_DRAGNDROP
  545. CPACK_BINARY_PRODUCTBUILD
  546. )
  547. else()
  548. option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
  549. mark_as_advanced(CPACK_BINARY_TZ)
  550. endif()
  551. option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF)
  552. option(CPACK_BINARY_FREEBSD "Enable to build FreeBSD packages" OFF)
  553. option(CPACK_BINARY_NSIS "Enable to build NSIS packages" OFF)
  554. option(CPACK_BINARY_RPM "Enable to build RPM packages" OFF)
  555. option(CPACK_BINARY_STGZ "Enable to build STGZ packages" ON)
  556. option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages" OFF)
  557. option(CPACK_BINARY_TGZ "Enable to build TGZ packages" ON)
  558. option(CPACK_BINARY_TXZ "Enable to build TXZ packages" OFF)
  559. mark_as_advanced(
  560. CPACK_BINARY_DEB
  561. CPACK_BINARY_FREEBSD
  562. CPACK_BINARY_NSIS
  563. CPACK_BINARY_RPM
  564. CPACK_BINARY_STGZ
  565. CPACK_BINARY_TBZ2
  566. CPACK_BINARY_TGZ
  567. CPACK_BINARY_TXZ
  568. )
  569. endif()
  570. else()
  571. option(CPACK_BINARY_7Z "Enable to build 7-Zip packages" OFF)
  572. option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON)
  573. option(CPACK_BINARY_INNOSETUP "Enable to build Inno Setup packages" OFF)
  574. option(CPACK_BINARY_NUGET "Enable to build NuGet packages" OFF)
  575. option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF)
  576. option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF)
  577. mark_as_advanced(
  578. CPACK_BINARY_7Z
  579. CPACK_BINARY_NSIS
  580. CPACK_BINARY_INNOSETUP
  581. CPACK_BINARY_NUGET
  582. CPACK_BINARY_WIX
  583. CPACK_BINARY_ZIP
  584. )
  585. endif()
  586. option(CPACK_BINARY_IFW "Enable to build IFW packages" OFF)
  587. mark_as_advanced(CPACK_BINARY_IFW)
  588. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_7Z 7Z)
  589. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle)
  590. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary)
  591. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DEB DEB)
  592. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DRAGNDROP DragNDrop)
  593. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_FREEBSD FREEBSD)
  594. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_IFW IFW)
  595. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS)
  596. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_INNOSETUP INNOSETUP)
  597. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NUGET NuGet)
  598. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PRODUCTBUILD productbuild)
  599. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM)
  600. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_STGZ STGZ)
  601. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2)
  602. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TGZ TGZ)
  603. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TXZ TXZ)
  604. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TZ TZ)
  605. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_WIX WIX)
  606. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_ZIP ZIP)
  607. endif()
  608. # Provide options to choose source generators
  609. if(NOT CPACK_SOURCE_GENERATOR)
  610. if(UNIX)
  611. if(CYGWIN)
  612. option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
  613. mark_as_advanced(CPACK_SOURCE_CYGWIN)
  614. else()
  615. option(CPACK_SOURCE_RPM "Enable to build RPM source packages" OFF)
  616. option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
  617. option(CPACK_SOURCE_TGZ "Enable to build TGZ source packages" ON)
  618. option(CPACK_SOURCE_TXZ "Enable to build TXZ source packages" ON)
  619. option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON)
  620. option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF)
  621. mark_as_advanced(
  622. CPACK_SOURCE_RPM
  623. CPACK_SOURCE_TBZ2
  624. CPACK_SOURCE_TGZ
  625. CPACK_SOURCE_TXZ
  626. CPACK_SOURCE_TZ
  627. CPACK_SOURCE_ZIP
  628. )
  629. endif()
  630. else()
  631. option(CPACK_SOURCE_7Z "Enable to build 7-Zip source packages" ON)
  632. option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
  633. mark_as_advanced(
  634. CPACK_SOURCE_7Z
  635. CPACK_SOURCE_ZIP
  636. )
  637. endif()
  638. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_7Z 7Z)
  639. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_CYGWIN CygwinSource)
  640. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_RPM RPM)
  641. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TBZ2 TBZ2)
  642. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TGZ TGZ)
  643. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TXZ TXZ)
  644. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TZ TZ)
  645. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP)
  646. endif()
  647. # Set some other variables
  648. _cpack_set_default(CPACK_INSTALL_CMAKE_PROJECTS
  649. "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
  650. _cpack_set_default(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
  651. _cpack_set_default(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
  652. _cpack_set_default(CPACK_THREADS 1)
  653. # if the user has set CPACK_NSIS_DISPLAY_NAME remember it
  654. if(DEFINED CPACK_NSIS_DISPLAY_NAME)
  655. set(CPACK_NSIS_DISPLAY_NAME_SET TRUE)
  656. endif()
  657. # if the user has set CPACK_NSIS_DISPLAY
  658. # explicitly, then use that as the default
  659. # value of CPACK_NSIS_PACKAGE_NAME instead
  660. # of CPACK_PACKAGE_INSTALL_DIRECTORY
  661. _cpack_set_default(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  662. # Specify the name of the Uninstall file in NSIS
  663. _cpack_set_default(CPACK_NSIS_UNINSTALL_NAME "Uninstall")
  664. if(CPACK_NSIS_DISPLAY_NAME_SET)
  665. _cpack_set_default(CPACK_NSIS_PACKAGE_NAME "${CPACK_NSIS_DISPLAY_NAME}")
  666. else()
  667. _cpack_set_default(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  668. endif()
  669. _cpack_set_default(CPACK_OUTPUT_CONFIG_FILE
  670. "${CMAKE_BINARY_DIR}/CPackConfig.cmake")
  671. _cpack_set_default(CPACK_SOURCE_OUTPUT_CONFIG_FILE
  672. "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")
  673. _cpack_set_default(CPACK_SET_DESTDIR OFF)
  674. _cpack_set_default(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
  675. _cpack_set_default(CPACK_NSIS_INSTALLER_ICON_CODE "")
  676. _cpack_set_default(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
  677. # DragNDrop specific variables
  678. if(NOT DEFINED CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE
  679. AND CPACK_RESOURCE_FILE_LICENSE AND NOT CPACK_RESOURCE_FILE_LICENSE STREQUAL "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
  680. cmake_policy(GET CMP0133 _CPack_CMP0133)
  681. if(NOT "x${_CPack_CMP0133}x" STREQUAL "xNEWx")
  682. if(NOT "x${_CPack_CMP0133}x" STREQUAL "xOLDx" AND CMAKE_POLICY_WARNING_CMP0133)
  683. cmake_policy(GET_WARNING CMP0133 _CMP0133_warning)
  684. message(AUTHOR_WARNING
  685. "${_CMP0133_warning}\n"
  686. "For compatibility, CMake will enable the SLA in the CPack DragNDrop Generator."
  687. )
  688. unset(_CMP0133_warning)
  689. endif()
  690. _cpack_set_default(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE ON)
  691. endif()
  692. unset(_CPack_CMP0133)
  693. endif()
  694. # Inno Setup specific variables
  695. if(CMAKE_SIZEOF_VOID_P EQUAL 4)
  696. _cpack_set_default(CPACK_INNOSETUP_ARCHITECTURE "x86")
  697. elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
  698. _cpack_set_default(CPACK_INNOSETUP_ARCHITECTURE "x64")
  699. endif()
  700. # WiX specific variables
  701. _cpack_set_default(CPACK_WIX_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
  702. if(NOT DEFINED CPACK_WIX_INSTALL_SCOPE)
  703. cmake_policy(GET CMP0172 _CPack_CMP0172)
  704. if("x${_CPack_CMP0172}x" STREQUAL "xNEWx")
  705. _cpack_set_default(CPACK_WIX_INSTALL_SCOPE perMachine)
  706. elseif(NOT "x${_CPack_CMP0172}x" STREQUAL "xOLDx" AND CMAKE_POLICY_WARNING_CMP0172)
  707. cmake_policy(GET_WARNING CMP0172 _CMP0172_warning)
  708. message(AUTHOR_WARNING
  709. "${_CMP0172_warning}\n"
  710. "For compatibility, CMake will not enable per-machine installation by default in the CPack WIX Generator."
  711. )
  712. unset(_CMP0172_warning)
  713. endif()
  714. unset(_CPack_CMP0172)
  715. endif()
  716. # productbuild specific variables
  717. cmake_policy(GET CMP0161 _CPack_CMP0161)
  718. if("x${_CPack_CMP0161}x" STREQUAL "xNEWx")
  719. _cpack_set_default(CPACK_PRODUCTBUILD_DOMAINS ON)
  720. elseif(APPLE AND CPACK_BINARY_PRODUCTBUILD AND
  721. NOT DEFINED CPACK_PRODUCTBUILD_DOMAINS AND
  722. NOT "x${_CPack_CMP0161}x" STREQUAL "xOLDx")
  723. cmake_policy(GET_WARNING CMP0161 _CMP0161_warning)
  724. message(AUTHOR_WARNING
  725. "${_CMP0161_warning}\n"
  726. "For compatibility, CPACK_PRODUCTBUILD_DOMAINS will remain unset. "
  727. "Explicitly setting CPACK_PRODUCTBUILD_DOMAINS or setting policy CMP0161 "
  728. "to NEW will prevent this warning."
  729. )
  730. unset(_CMP0161_warning)
  731. endif()
  732. unset(_CPack_CMP0161)
  733. # set sysroot so SDK tools can be used
  734. if(CMAKE_OSX_SYSROOT)
  735. _cpack_set_default(CPACK_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
  736. endif()
  737. _cpack_set_default(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR};${CMAKE_BINARY_DIR}")
  738. if(DEFINED CPACK_COMPONENTS_ALL)
  739. if(CPACK_MONOLITHIC_INSTALL)
  740. message("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.")
  741. set(CPACK_COMPONENTS_ALL)
  742. else()
  743. # The user has provided the set of components to be installed as
  744. # part of a component-based installation; trust her.
  745. set(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE)
  746. endif()
  747. else()
  748. # If the user has not specifically requested a monolithic installer
  749. # but has specified components in various "install" commands, tell
  750. # CPack about those components.
  751. if(NOT CPACK_MONOLITHIC_INSTALL)
  752. get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
  753. list(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN)
  754. if(CPACK_COMPONENTS_LEN EQUAL 1)
  755. # Only one component: this is not a component-based installation
  756. # (at least, it isn't a component-based installation, but may
  757. # become one later if the user uses the cpack_add_* commands).
  758. set(CPACK_COMPONENTS_ALL)
  759. endif()
  760. set(CPACK_COMPONENTS_LEN)
  761. endif()
  762. endif()
  763. # CMake always generates a component named "Unspecified", which is
  764. # used to install everything that doesn't have an explicitly-provided
  765. # component. Since these files should always be installed, we'll make
  766. # them hidden and required.
  767. set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE)
  768. set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE)
  769. cpack_encode_variables()
  770. configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY)
  771. # Generate source file
  772. _cpack_set_default(CPACK_SOURCE_INSTALLED_DIRECTORIES
  773. "${CMAKE_SOURCE_DIR};/")
  774. _cpack_set_default(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-Source")
  775. _cpack_set_default(CPACK_SOURCE_PACKAGE_FILE_NAME
  776. "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
  777. set(__cpack_source_ignore_files_default
  778. "/CVS/;/\\.svn/;/\\.bzr/;/\\.hg/;/\\.git/;\\.swp$;\\.#;/#")
  779. if(NOT CPACK_VERBATIM_VARIABLES)
  780. _cpack_escape_for_cmake(__cpack_source_ignore_files_default
  781. "${__cpack_source_ignore_files_default}")
  782. endif()
  783. _cpack_set_default(CPACK_SOURCE_IGNORE_FILES "${__cpack_source_ignore_files_default}")
  784. set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
  785. set(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
  786. set(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
  787. set(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}")
  788. set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
  789. set(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
  790. set(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
  791. set(CPACK_RPM_PACKAGE_SOURCES "ON")
  792. cpack_encode_variables()
  793. configure_file("${cpack_source_input_file}"
  794. "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY)