CPack.cmake 26 KB

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