CPack.cmake 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  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. #
  7. # Build binary and source package installers.
  8. #
  9. # Variables common to all CPack generators
  10. # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  11. #
  12. # The
  13. # CPack module generates binary and source installers in a variety of
  14. # formats using the cpack program. Inclusion of the CPack module adds
  15. # two new targets to the resulting makefiles, package and
  16. # package_source, which build the binary and source installers,
  17. # respectively. The generated binary installers contain everything
  18. # installed via CMake's INSTALL command (and the deprecated
  19. # INSTALL_FILES, INSTALL_PROGRAMS, and INSTALL_TARGETS commands).
  20. #
  21. # For certain kinds of binary installers (including the graphical
  22. # installers on Mac OS X and Windows), CPack generates installers that
  23. # allow users to select individual application components to install.
  24. # See CPackComponent module for that.
  25. #
  26. # The CPACK_GENERATOR variable has different meanings in different
  27. # contexts. In your CMakeLists.txt file, CPACK_GENERATOR is a *list of
  28. # generators*: when run with no other arguments, CPack will iterate over
  29. # that list and produce one package for each generator. In a
  30. # CPACK_PROJECT_CONFIG_FILE, though, CPACK_GENERATOR is a *string naming
  31. # a single generator*. If you need per-cpack- generator logic to
  32. # control *other* cpack settings, then you need a
  33. # CPACK_PROJECT_CONFIG_FILE.
  34. #
  35. # The CMake source tree itself contains a CPACK_PROJECT_CONFIG_FILE.
  36. # See the top level file CMakeCPackOptions.cmake.in for an example.
  37. #
  38. # If set, the CPACK_PROJECT_CONFIG_FILE is included automatically on a
  39. # per-generator basis. It only need contain overrides.
  40. #
  41. # Here's how it works:
  42. #
  43. # * cpack runs
  44. # * it includes CPackConfig.cmake
  45. # * it iterates over the generators given by the ``-G`` command line option,
  46. # or if no such option was specified, over the list of generators given by
  47. # the CPACK_GENERATOR variable set in the CPackConfig.cmake input file.
  48. # * foreach generator, it then
  49. #
  50. # - sets CPACK_GENERATOR to the one currently being iterated
  51. # - includes the CPACK_PROJECT_CONFIG_FILE
  52. # - produces the package for that generator
  53. #
  54. # This is the key: For each generator listed in CPACK_GENERATOR in
  55. # CPackConfig.cmake, cpack will *reset* CPACK_GENERATOR internally to
  56. # *the one currently being used* and then include the
  57. # CPACK_PROJECT_CONFIG_FILE.
  58. #
  59. # Before including this CPack module in your CMakeLists.txt file, there
  60. # are a variety of variables that can be set to customize the resulting
  61. # installers. The most commonly-used variables are:
  62. #
  63. # .. variable:: CPACK_PACKAGE_NAME
  64. #
  65. # The name of the package (or application). If not specified, defaults to
  66. # the project name.
  67. #
  68. # .. variable:: CPACK_PACKAGE_VENDOR
  69. #
  70. # The name of the package vendor. (e.g., "Kitware"). Default is "Humanity".
  71. #
  72. # .. variable:: CPACK_PACKAGE_DIRECTORY
  73. #
  74. # The directory in which CPack is doing its packaging. If it is not set
  75. # then this will default (internally) to the build dir. This variable may
  76. # be defined in CPack config file or from the cpack command line option
  77. # "-B". If set the command line option override the value found in the
  78. # config file.
  79. #
  80. # .. variable:: CPACK_PACKAGE_VERSION_MAJOR
  81. #
  82. # Package major version. This variable will always be set, but its default
  83. # value depends on whether or not version details were given to the
  84. # :command:`project` command in the top level CMakeLists.txt file. If version
  85. # details were given, the default value will be
  86. # :variable:`CMAKE_PROJECT_VERSION_MAJOR`. If no version details were given,
  87. # a default version of 0.1.1 will be assumed, leading to
  88. # ``CPACK_PACKAGE_VERSION_MAJOR`` having a default value of 0.
  89. #
  90. # .. variable:: CPACK_PACKAGE_VERSION_MINOR
  91. #
  92. # Package minor version. The default value is determined based on whether or
  93. # not version details were given to the :command:`project` command in the top
  94. # level CMakeLists.txt file. If version details were given, the default
  95. # value will be :variable:`CMAKE_PROJECT_VERSION_MINOR`, but if no minor
  96. # version component was specified then ``CPACK_PACKAGE_VERSION_MINOR`` will be
  97. # left unset. If no project version was given at all, a default version of
  98. # 0.1.1 will be assumed, leading to ``CPACK_PACKAGE_VERSION_MINOR`` having a
  99. # default value of 1.
  100. #
  101. # .. variable:: CPACK_PACKAGE_VERSION_PATCH
  102. #
  103. # Package patch version. The default value is determined based on whether or
  104. # not version details were given to the :command:`project` command in the top
  105. # level CMakeLists.txt file. If version details were given, the default
  106. # value will be :variable:`CMAKE_PROJECT_VERSION_PATCH`, but if no patch
  107. # version component was specified then ``CPACK_PACKAGE_VERSION_PATCH`` will be
  108. # left unset. If no project version was given at all, a default version of
  109. # 0.1.1 will be assumed, leading to ``CPACK_PACKAGE_VERSION_PATCH`` having a
  110. # default value of 1.
  111. #
  112. # .. variable:: CPACK_PACKAGE_DESCRIPTION_FILE
  113. #
  114. # A text file used to describe the project. Used, for example, the
  115. # introduction screen of a CPack-generated Windows installer to describe
  116. # the project.
  117. #
  118. # .. variable:: CPACK_PACKAGE_DESCRIPTION_SUMMARY
  119. #
  120. # Short description of the project (only a few words). Default value is::
  121. #
  122. # ${CMAKE_PROJECT_DESCRIPTION}
  123. #
  124. # if DESCRIPTION has given to the project() call or
  125. # CMake generated string with PROJECT_NAME otherwise.
  126. #
  127. # .. variable:: CPACK_PACKAGE_HOMEPAGE_URL
  128. #
  129. # Project homepage URL. Default value is::
  130. #
  131. # ${CMAKE_PROJECT_HOMEPAGE_URL}
  132. #
  133. # if HOMEPAGE_URL has given to the project().
  134. #
  135. # .. variable:: CPACK_PACKAGE_FILE_NAME
  136. #
  137. # The name of the package file to generate, not including the
  138. # extension. For example, cmake-2.6.1-Linux-i686. The default value is::
  139. #
  140. # ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}.
  141. #
  142. # .. variable:: CPACK_PACKAGE_INSTALL_DIRECTORY
  143. #
  144. # Installation directory on the target system. This may be used by some
  145. # CPack generators like NSIS to create an installation directory e.g.,
  146. # "CMake 2.5" below the installation prefix. All installed element will be
  147. # put inside this directory.
  148. #
  149. # .. variable:: CPACK_PACKAGE_ICON
  150. #
  151. # A branding image that will be displayed inside the installer (used by GUI
  152. # installers).
  153. #
  154. # .. variable:: CPACK_PACKAGE_CHECKSUM
  155. #
  156. # An algorithm that will be used to generate additional file with checksum
  157. # of the package. Output file name will be::
  158. #
  159. # ${CPACK_PACKAGE_FILE_NAME}.${CPACK_PACKAGE_CHECKSUM}
  160. #
  161. # Supported algorithms are those listed by the
  162. # :ref:`string(\<HASH\>) <Supported Hash Algorithms>`
  163. # command.
  164. #
  165. # .. variable:: CPACK_PROJECT_CONFIG_FILE
  166. #
  167. # CPack-time project CPack configuration file. This file included at cpack
  168. # time, once per generator after CPack has set CPACK_GENERATOR to the
  169. # actual generator being used. It allows per-generator setting of CPACK_*
  170. # variables at cpack time.
  171. #
  172. # .. variable:: CPACK_RESOURCE_FILE_LICENSE
  173. #
  174. # License to be embedded in the installer. It will typically be displayed
  175. # to the user by the produced installer (often with an explicit "Accept"
  176. # button, for graphical installers) prior to installation. This license
  177. # file is NOT added to installed file but is used by some CPack generators
  178. # like NSIS. If you want to install a license file (may be the same as this
  179. # one) along with your project you must add an appropriate CMake INSTALL
  180. # command in your CMakeLists.txt.
  181. #
  182. # .. variable:: CPACK_RESOURCE_FILE_README
  183. #
  184. # ReadMe file to be embedded in the installer. It typically describes in
  185. # some detail the purpose of the project during the installation. Not all
  186. # CPack generators uses this file.
  187. #
  188. # .. variable:: CPACK_RESOURCE_FILE_WELCOME
  189. #
  190. # Welcome file to be embedded in the installer. It welcomes users to this
  191. # installer. Typically used in the graphical installers on Windows and Mac
  192. # OS X.
  193. #
  194. # .. variable:: CPACK_MONOLITHIC_INSTALL
  195. #
  196. # Disables the component-based installation mechanism. When set the
  197. # component specification is ignored and all installed items are put in a
  198. # single "MONOLITHIC" package. Some CPack generators do monolithic
  199. # packaging by default and may be asked to do component packaging by
  200. # setting CPACK_<GENNAME>_COMPONENT_INSTALL to 1/TRUE.
  201. #
  202. # .. variable:: CPACK_GENERATOR
  203. #
  204. # List of CPack generators to use. If not specified, CPack will create a
  205. # set of options CPACK_BINARY_<GENNAME> (e.g., CPACK_BINARY_NSIS) allowing
  206. # the user to enable/disable individual generators. If the ``-G`` option
  207. # is given on the :manual:`cpack <cpack(1)>` command line, it will override
  208. # this variable and any CPACK_BINARY_<GENNAME> options.
  209. #
  210. # .. variable:: CPACK_OUTPUT_CONFIG_FILE
  211. #
  212. # The name of the CPack binary configuration file. This file is the CPack
  213. # configuration generated by the CPack module for binary
  214. # installers. Defaults to CPackConfig.cmake.
  215. #
  216. # .. variable:: CPACK_PACKAGE_EXECUTABLES
  217. #
  218. # Lists each of the executables and associated text label to be used to
  219. # create Start Menu shortcuts. For example, setting this to the list
  220. # ccmake;CMake will create a shortcut named "CMake" that will execute the
  221. # installed executable ccmake. Not all CPack generators use it (at least
  222. # NSIS, WIX and OSXX11 do).
  223. #
  224. # .. variable:: CPACK_STRIP_FILES
  225. #
  226. # List of files to be stripped. Starting with CMake 2.6.0 CPACK_STRIP_FILES
  227. # will be a boolean variable which enables stripping of all files (a list
  228. # of files evaluates to TRUE in CMake, so this change is compatible).
  229. #
  230. # .. variable:: CPACK_VERBATIM_VARIABLES
  231. #
  232. # If set to TRUE, values of variables prefixed with CPACK_ will be escaped
  233. # before being written to the configuration files, so that the cpack program
  234. # receives them exactly as they were specified. If not, characters like quotes
  235. # and backslashes can cause parsing errors or alter the value received by the
  236. # cpack program. Defaults to FALSE for backwards compatibility.
  237. #
  238. # * Mandatory : NO
  239. # * Default : FALSE
  240. #
  241. # The following CPack variables are specific to source packages, and
  242. # will not affect binary packages:
  243. #
  244. # .. variable:: CPACK_SOURCE_PACKAGE_FILE_NAME
  245. #
  246. # The name of the source package. For example cmake-2.6.1.
  247. #
  248. # .. variable:: CPACK_SOURCE_STRIP_FILES
  249. #
  250. # List of files in the source tree that will be stripped. Starting with
  251. # CMake 2.6.0 CPACK_SOURCE_STRIP_FILES will be a boolean variable which
  252. # enables stripping of all files (a list of files evaluates to TRUE in
  253. # CMake, so this change is compatible).
  254. #
  255. # .. variable:: CPACK_SOURCE_GENERATOR
  256. #
  257. # List of generators used for the source packages. As with CPACK_GENERATOR,
  258. # if this is not specified then CPack will create a set of options (e.g.,
  259. # CPACK_SOURCE_ZIP) allowing users to select which packages will be
  260. # generated.
  261. #
  262. # .. variable:: CPACK_SOURCE_OUTPUT_CONFIG_FILE
  263. #
  264. # The name of the CPack source configuration file. This file is the CPack
  265. # configuration generated by the CPack module for source
  266. # installers. Defaults to CPackSourceConfig.cmake.
  267. #
  268. # .. variable:: CPACK_SOURCE_IGNORE_FILES
  269. #
  270. # Pattern of files in the source tree that won't be packaged when building
  271. # a source package. This is a list of regular expression patterns (that
  272. # must be properly escaped), e.g.,
  273. # /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.*
  274. #
  275. # The following variables are for advanced uses of CPack:
  276. #
  277. # .. variable:: CPACK_CMAKE_GENERATOR
  278. #
  279. # What CMake generator should be used if the project is CMake
  280. # project. Defaults to the value of CMAKE_GENERATOR few users will want to
  281. # change this setting.
  282. #
  283. # .. variable:: CPACK_INSTALL_CMAKE_PROJECTS
  284. #
  285. # List of four values that specify what project to install. The four values
  286. # are: Build directory, Project Name, Project Component, Directory. If
  287. # omitted, CPack will build an installer that installs everything.
  288. #
  289. # .. variable:: CPACK_SYSTEM_NAME
  290. #
  291. # System name, defaults to the value of ${CMAKE_SYSTEM_NAME}, except on
  292. # Windows where it will be "win32" or "win64".
  293. #
  294. # .. variable:: CPACK_PACKAGE_VERSION
  295. #
  296. # Package full version, used internally. By default, this is built from
  297. # CPACK_PACKAGE_VERSION_MAJOR, CPACK_PACKAGE_VERSION_MINOR, and
  298. # CPACK_PACKAGE_VERSION_PATCH.
  299. #
  300. # .. variable:: CPACK_TOPLEVEL_TAG
  301. #
  302. # Directory for the installed files.
  303. #
  304. # .. variable:: CPACK_INSTALL_COMMANDS
  305. #
  306. # Extra commands to install components.
  307. #
  308. # .. variable:: CPACK_INSTALLED_DIRECTORIES
  309. #
  310. # Extra directories to install.
  311. #
  312. # .. variable:: CPACK_PACKAGE_INSTALL_REGISTRY_KEY
  313. #
  314. # Registry key used when installing this project. This is only used by
  315. # installer for Windows. The default value is based on the installation
  316. # directory.
  317. #
  318. # .. variable:: CPACK_CREATE_DESKTOP_LINKS
  319. #
  320. # List of desktop links to create.
  321. # Each desktop link requires a corresponding start menu shortcut
  322. # as created by :variable:`CPACK_PACKAGE_EXECUTABLES`.
  323. # Define this var in order to avoid (or warn) concerning multiple inclusion
  324. if(CPack_CMake_INCLUDED)
  325. message(WARNING "CPack.cmake has already been included!!")
  326. else()
  327. set(CPack_CMake_INCLUDED 1)
  328. endif()
  329. # Pick a configuration file
  330. set(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
  331. if(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  332. set(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  333. endif()
  334. set(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
  335. if(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  336. set(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  337. endif()
  338. # Backward compatibility
  339. # Include CPackComponent macros if it has not already been included before.
  340. include(CPackComponent)
  341. # Macro for setting values if a user did not overwrite them
  342. # Mangles CMake-special characters. Only kept for backwards compatibility.
  343. macro(cpack_set_if_not_set name value)
  344. message(DEPRECATION "cpack_set_if_not_set is obsolete; do not use.")
  345. _cpack_set_default("${name}" "${value}")
  346. endmacro()
  347. # cpack_encode_variables - Function to encode variables for the configuration file
  348. # find any variable that starts with CPACK and create a variable
  349. # _CPACK_OTHER_VARIABLES_ that contains SET commands for
  350. # each cpack variable. _CPACK_OTHER_VARIABLES_ is then
  351. # used as an @ replacment in configure_file for the CPackConfig.
  352. function(cpack_encode_variables)
  353. set(commands "")
  354. get_cmake_property(res VARIABLES)
  355. foreach(var ${res})
  356. if(var MATCHES "^CPACK")
  357. if(CPACK_VERBATIM_VARIABLES)
  358. _cpack_escape_for_cmake(value "${${var}}")
  359. else()
  360. set(value "${${var}}")
  361. endif()
  362. string(APPEND commands "\nset(${var} \"${value}\")")
  363. endif()
  364. endforeach()
  365. set(_CPACK_OTHER_VARIABLES_ "${commands}" PARENT_SCOPE)
  366. endfunction()
  367. # Internal use functions
  368. function(_cpack_set_default name value)
  369. if(NOT DEFINED "${name}")
  370. set("${name}" "${value}" PARENT_SCOPE)
  371. endif()
  372. endfunction()
  373. function(_cpack_escape_for_cmake var value)
  374. string(REGEX REPLACE "([\\\$\"])" "\\\\\\1" escaped "${value}")
  375. set("${var}" "${escaped}" PARENT_SCOPE)
  376. endfunction()
  377. # Set the package name
  378. _cpack_set_default(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
  379. if(CMAKE_PROJECT_VERSION_MAJOR)
  380. _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_PROJECT_VERSION_MAJOR}")
  381. if(CMAKE_PROJECT_VERSION_MINOR)
  382. _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_PROJECT_VERSION_MINOR}")
  383. if(CMAKE_PROJECT_VERSION_PATCH)
  384. _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "${CMAKE_PROJECT_VERSION_PATCH}")
  385. _cpack_set_default(CPACK_PACKAGE_VERSION
  386. "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  387. else()
  388. _cpack_set_default(CPACK_PACKAGE_VERSION
  389. "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
  390. endif()
  391. else()
  392. _cpack_set_default(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}")
  393. endif()
  394. else()
  395. _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0")
  396. _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1")
  397. _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1")
  398. _cpack_set_default(CPACK_PACKAGE_VERSION
  399. "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  400. endif()
  401. _cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity")
  402. if(CMAKE_PROJECT_DESCRIPTION)
  403. _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
  404. "${CMAKE_PROJECT_DESCRIPTION}")
  405. else()
  406. _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
  407. "${CMAKE_PROJECT_NAME} built using CMake")
  408. endif()
  409. if(CMAKE_PROJECT_HOMEPAGE_URL)
  410. _cpack_set_default(CPACK_PACKAGE_HOMEPAGE_URL
  411. "${CMAKE_PROJECT_HOMEPAGE_URL}")
  412. endif()
  413. _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE
  414. "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
  415. _cpack_set_default(CPACK_RESOURCE_FILE_LICENSE
  416. "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
  417. _cpack_set_default(CPACK_RESOURCE_FILE_README
  418. "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
  419. _cpack_set_default(CPACK_RESOURCE_FILE_WELCOME
  420. "${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt")
  421. _cpack_set_default(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
  422. # Set default directory creation permissions mode
  423. if(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS)
  424. _cpack_set_default(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
  425. "${CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS}")
  426. endif()
  427. if(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
  428. set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
  429. endif()
  430. if(CPACK_NSIS_MODIFY_PATH)
  431. set(CPACK_NSIS_MODIFY_PATH ON)
  432. endif()
  433. set(__cpack_system_name ${CMAKE_SYSTEM_NAME})
  434. if(__cpack_system_name MATCHES "Windows")
  435. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  436. set(__cpack_system_name win64)
  437. else()
  438. set(__cpack_system_name win32)
  439. endif()
  440. endif()
  441. _cpack_set_default(CPACK_SYSTEM_NAME "${__cpack_system_name}")
  442. # Root dir: default value should be the string literal "$PROGRAMFILES"
  443. # for backwards compatibility. Projects may set this value to anything.
  444. # When creating 64 bit binaries we set the default value to "$PROGRAMFILES64"
  445. if("x${__cpack_system_name}" STREQUAL "xwin64")
  446. set(__cpack_root_default "$PROGRAMFILES64")
  447. else()
  448. set(__cpack_root_default "$PROGRAMFILES")
  449. endif()
  450. _cpack_set_default(CPACK_NSIS_INSTALL_ROOT "${__cpack_root_default}")
  451. # <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
  452. _cpack_set_default(CPACK_PACKAGE_FILE_NAME
  453. "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
  454. _cpack_set_default(CPACK_PACKAGE_INSTALL_DIRECTORY
  455. "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
  456. _cpack_set_default(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
  457. "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  458. _cpack_set_default(CPACK_PACKAGE_DEFAULT_LOCATION "/")
  459. _cpack_set_default(CPACK_PACKAGE_RELOCATABLE "true")
  460. # always force to exactly "true" or "false" for CPack.Info.plist.in:
  461. if(CPACK_PACKAGE_RELOCATABLE)
  462. set(CPACK_PACKAGE_RELOCATABLE "true")
  463. else()
  464. set(CPACK_PACKAGE_RELOCATABLE "false")
  465. endif()
  466. macro(cpack_check_file_exists file description)
  467. if(NOT EXISTS "${file}")
  468. message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
  469. endif()
  470. endmacro()
  471. cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description")
  472. cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource")
  473. cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}" "readme resource")
  474. cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource")
  475. macro(cpack_optional_append _list _cond _item)
  476. if(${_cond})
  477. set(${_list} ${${_list}} ${_item})
  478. endif()
  479. endmacro()
  480. #.rst:
  481. # .. variable:: CPACK_BINARY_<GENNAME>
  482. #
  483. # CPack generated options for binary generators. The CPack.cmake module
  484. # generates (when CPACK_GENERATOR is not set) a set of CMake options (see
  485. # CMake option command) which may then be used to select the CPack
  486. # generator(s) to be used when launching the package target.
  487. #
  488. # Provide options to choose generators we might check here if the required
  489. # tools for the generates exist and set the defaults according to the results
  490. if(NOT CPACK_GENERATOR)
  491. if(UNIX)
  492. if(CYGWIN)
  493. option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON)
  494. else()
  495. if(APPLE)
  496. option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF)
  497. option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF)
  498. option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF)
  499. option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" OFF)
  500. option(CPACK_BINARY_PRODUCTBUILD "Enable to build productbuild packages" OFF)
  501. else()
  502. option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
  503. endif()
  504. option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF)
  505. option(CPACK_BINARY_FREEBSD "Enable to build FreeBSD packages" OFF)
  506. option(CPACK_BINARY_NSIS "Enable to build NSIS packages" OFF)
  507. option(CPACK_BINARY_RPM "Enable to build RPM packages" OFF)
  508. option(CPACK_BINARY_STGZ "Enable to build STGZ packages" ON)
  509. option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages" OFF)
  510. option(CPACK_BINARY_TGZ "Enable to build TGZ packages" ON)
  511. option(CPACK_BINARY_TXZ "Enable to build TXZ packages" OFF)
  512. endif()
  513. else()
  514. option(CPACK_BINARY_7Z "Enable to build 7-Zip packages" OFF)
  515. option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON)
  516. option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF)
  517. option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF)
  518. endif()
  519. option(CPACK_BINARY_IFW "Enable to build IFW packages" OFF)
  520. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_7Z 7Z)
  521. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle)
  522. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary)
  523. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DEB DEB)
  524. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DRAGNDROP DragNDrop)
  525. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_FREEBSD FREEBSD)
  526. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_IFW IFW)
  527. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS)
  528. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11)
  529. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker)
  530. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PRODUCTBUILD productbuild)
  531. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM)
  532. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_STGZ STGZ)
  533. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2)
  534. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TGZ TGZ)
  535. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TXZ TXZ)
  536. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TZ TZ)
  537. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_WIX WIX)
  538. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_ZIP ZIP)
  539. endif()
  540. # Provide options to choose source generators
  541. if(NOT CPACK_SOURCE_GENERATOR)
  542. if(UNIX)
  543. if(CYGWIN)
  544. option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
  545. else()
  546. option(CPACK_SOURCE_RPM "Enable to build RPM source packages" OFF)
  547. option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
  548. option(CPACK_SOURCE_TGZ "Enable to build TGZ source packages" ON)
  549. option(CPACK_SOURCE_TXZ "Enable to build TXZ source packages" ON)
  550. option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON)
  551. option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF)
  552. endif()
  553. else()
  554. option(CPACK_SOURCE_7Z "Enable to build 7-Zip source packages" ON)
  555. option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
  556. endif()
  557. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_7Z 7Z)
  558. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_CYGWIN CygwinSource)
  559. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_RPM RPM)
  560. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TBZ2 TBZ2)
  561. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TGZ TGZ)
  562. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TXZ TXZ)
  563. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TZ TZ)
  564. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP)
  565. endif()
  566. # mark the above options as advanced
  567. mark_as_advanced(
  568. CPACK_BINARY_7Z
  569. CPACK_BINARY_BUNDLE
  570. CPACK_BINARY_CYGWIN
  571. CPACK_BINARY_DEB
  572. CPACK_BINARY_DRAGNDROP
  573. CPACK_BINARY_FREEBSD
  574. CPACK_BINARY_IFW
  575. CPACK_BINARY_NSIS
  576. CPACK_BINARY_OSXX11
  577. CPACK_BINARY_PACKAGEMAKER
  578. CPACK_BINARY_PRODUCTBUILD
  579. CPACK_BINARY_RPM
  580. CPACK_BINARY_STGZ
  581. CPACK_BINARY_TBZ2
  582. CPACK_BINARY_TGZ
  583. CPACK_BINARY_TXZ
  584. CPACK_BINARY_TZ
  585. CPACK_BINARY_WIX
  586. CPACK_BINARY_ZIP
  587. CPACK_SOURCE_7Z
  588. CPACK_SOURCE_CYGWIN
  589. CPACK_SOURCE_RPM
  590. CPACK_SOURCE_TBZ2
  591. CPACK_SOURCE_TGZ
  592. CPACK_SOURCE_TXZ
  593. CPACK_SOURCE_TZ
  594. CPACK_SOURCE_ZIP
  595. )
  596. # Set some other variables
  597. _cpack_set_default(CPACK_INSTALL_CMAKE_PROJECTS
  598. "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
  599. _cpack_set_default(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
  600. _cpack_set_default(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
  601. # if the user has set CPACK_NSIS_DISPLAY_NAME remember it
  602. if(DEFINED CPACK_NSIS_DISPLAY_NAME)
  603. set(CPACK_NSIS_DISPLAY_NAME_SET TRUE)
  604. endif()
  605. # if the user has set CPACK_NSIS_DISPLAY
  606. # explicitly, then use that as the default
  607. # value of CPACK_NSIS_PACKAGE_NAME instead
  608. # of CPACK_PACKAGE_INSTALL_DIRECTORY
  609. _cpack_set_default(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  610. if(CPACK_NSIS_DISPLAY_NAME_SET)
  611. _cpack_set_default(CPACK_NSIS_PACKAGE_NAME "${CPACK_NSIS_DISPLAY_NAME}")
  612. else()
  613. _cpack_set_default(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  614. endif()
  615. _cpack_set_default(CPACK_OUTPUT_CONFIG_FILE
  616. "${CMAKE_BINARY_DIR}/CPackConfig.cmake")
  617. _cpack_set_default(CPACK_SOURCE_OUTPUT_CONFIG_FILE
  618. "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")
  619. _cpack_set_default(CPACK_SET_DESTDIR OFF)
  620. _cpack_set_default(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
  621. _cpack_set_default(CPACK_NSIS_INSTALLER_ICON_CODE "")
  622. _cpack_set_default(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
  623. # WiX specific variables
  624. _cpack_set_default(CPACK_WIX_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
  625. # set sysroot so SDK tools can be used
  626. if(CMAKE_OSX_SYSROOT)
  627. _cpack_set_default(CPACK_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
  628. endif()
  629. _cpack_set_default(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR};${CMAKE_BINARY_DIR}")
  630. if(DEFINED CPACK_COMPONENTS_ALL)
  631. if(CPACK_MONOLITHIC_INSTALL)
  632. message("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.")
  633. set(CPACK_COMPONENTS_ALL)
  634. else()
  635. # The user has provided the set of components to be installed as
  636. # part of a component-based installation; trust her.
  637. set(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE)
  638. endif()
  639. else()
  640. # If the user has not specifically requested a monolithic installer
  641. # but has specified components in various "install" commands, tell
  642. # CPack about those components.
  643. if(NOT CPACK_MONOLITHIC_INSTALL)
  644. get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
  645. list(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN)
  646. if(CPACK_COMPONENTS_LEN EQUAL 1)
  647. # Only one component: this is not a component-based installation
  648. # (at least, it isn't a component-based installation, but may
  649. # become one later if the user uses the cpack_add_* commands).
  650. set(CPACK_COMPONENTS_ALL)
  651. endif()
  652. set(CPACK_COMPONENTS_LEN)
  653. endif()
  654. endif()
  655. # CMake always generates a component named "Unspecified", which is
  656. # used to install everything that doesn't have an explicitly-provided
  657. # component. Since these files should always be installed, we'll make
  658. # them hidden and required.
  659. set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE)
  660. set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE)
  661. cpack_encode_variables()
  662. configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY)
  663. # Generate source file
  664. _cpack_set_default(CPACK_SOURCE_INSTALLED_DIRECTORIES
  665. "${CMAKE_SOURCE_DIR};/")
  666. _cpack_set_default(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-Source")
  667. _cpack_set_default(CPACK_SOURCE_PACKAGE_FILE_NAME
  668. "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
  669. set(__cpack_source_ignore_files_default
  670. "/CVS/;/\\.svn/;/\\.bzr/;/\\.hg/;/\\.git/;\\.swp$;\\.#;/#")
  671. if(NOT CPACK_VERBATIM_VARIABLES)
  672. _cpack_escape_for_cmake(__cpack_source_ignore_files_default
  673. "${__cpack_source_ignore_files_default}")
  674. endif()
  675. _cpack_set_default(CPACK_SOURCE_IGNORE_FILES "${__cpack_source_ignore_files_default}")
  676. set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
  677. set(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
  678. set(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
  679. set(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}")
  680. set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
  681. set(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
  682. set(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
  683. set(CPACK_RPM_PACKAGE_SOURCES "ON")
  684. cpack_encode_variables()
  685. configure_file("${cpack_source_input_file}"
  686. "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY)