CPack.cmake 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  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"). 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. Default value is 0.
  83. #
  84. # .. variable:: CPACK_PACKAGE_VERSION_MINOR
  85. #
  86. # Package minor Version. Default value is 1.
  87. #
  88. # .. variable:: CPACK_PACKAGE_VERSION_PATCH
  89. #
  90. # Package patch Version. Default value is 1.
  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}, except on
  265. # Windows where it will be "win32" or "win64".
  266. #
  267. # .. variable:: CPACK_PACKAGE_VERSION
  268. #
  269. # Package full version, used internally. By default, this is built from
  270. # CPACK_PACKAGE_VERSION_MAJOR, CPACK_PACKAGE_VERSION_MINOR, and
  271. # CPACK_PACKAGE_VERSION_PATCH.
  272. #
  273. # .. variable:: CPACK_TOPLEVEL_TAG
  274. #
  275. # Directory for the installed files.
  276. #
  277. # .. variable:: CPACK_INSTALL_COMMANDS
  278. #
  279. # Extra commands to install components.
  280. #
  281. # .. variable:: CPACK_INSTALLED_DIRECTORIES
  282. #
  283. # Extra directories to install.
  284. #
  285. # .. variable:: CPACK_PACKAGE_INSTALL_REGISTRY_KEY
  286. #
  287. # Registry key used when installing this project. This is only used by
  288. # installer for Windows. The default value is based on the installation
  289. # directory.
  290. #
  291. # .. variable:: CPACK_CREATE_DESKTOP_LINKS
  292. #
  293. # List of desktop links to create.
  294. # Each desktop link requires a corresponding start menu shortcut
  295. # as created by :variable:`CPACK_PACKAGE_EXECUTABLES`.
  296. # Define this var in order to avoid (or warn) concerning multiple inclusion
  297. if(CPack_CMake_INCLUDED)
  298. message(WARNING "CPack.cmake has already been included!!")
  299. else()
  300. set(CPack_CMake_INCLUDED 1)
  301. endif()
  302. # Pick a configuration file
  303. set(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
  304. if(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  305. set(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  306. endif()
  307. set(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
  308. if(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  309. set(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  310. endif()
  311. # Backward compatibility
  312. # Include CPackComponent macros if it has not already been included before.
  313. include(CPackComponent)
  314. # Macro for setting values if a user did not overwrite them
  315. # Mangles CMake-special characters. Only kept for backwards compatibility.
  316. macro(cpack_set_if_not_set name value)
  317. message(DEPRECATION "cpack_set_if_not_set is obsolete; do not use.")
  318. _cpack_set_default("${name}" "${value}")
  319. endmacro()
  320. # cpack_encode_variables - Function to encode variables for the configuration file
  321. # find any variable that starts with CPACK and create a variable
  322. # _CPACK_OTHER_VARIABLES_ that contains SET commands for
  323. # each cpack variable. _CPACK_OTHER_VARIABLES_ is then
  324. # used as an @ replacment in configure_file for the CPackConfig.
  325. function(cpack_encode_variables)
  326. set(commands "")
  327. get_cmake_property(res VARIABLES)
  328. foreach(var ${res})
  329. if(var MATCHES "^CPACK")
  330. if(CPACK_VERBATIM_VARIABLES)
  331. _cpack_escape_for_cmake(value "${${var}}")
  332. else()
  333. set(value "${${var}}")
  334. endif()
  335. string(APPEND commands "\nset(${var} \"${value}\")")
  336. endif()
  337. endforeach()
  338. set(_CPACK_OTHER_VARIABLES_ "${commands}" PARENT_SCOPE)
  339. endfunction()
  340. # Internal use functions
  341. function(_cpack_set_default name value)
  342. if(NOT DEFINED "${name}")
  343. set("${name}" "${value}" PARENT_SCOPE)
  344. endif()
  345. endfunction()
  346. function(_cpack_escape_for_cmake var value)
  347. string(REGEX REPLACE "([\\\$\"])" "\\\\\\1" escaped "${value}")
  348. set("${var}" "${escaped}" PARENT_SCOPE)
  349. endfunction()
  350. # Set the package name
  351. _cpack_set_default(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
  352. _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0")
  353. _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1")
  354. _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1")
  355. _cpack_set_default(CPACK_PACKAGE_VERSION
  356. "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  357. _cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity")
  358. if(CMAKE_PROJECT_DESCRIPTION)
  359. _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
  360. "${CMAKE_PROJECT_DESCRIPTION}")
  361. else()
  362. _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
  363. "${CMAKE_PROJECT_NAME} built using CMake")
  364. endif()
  365. _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE
  366. "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
  367. _cpack_set_default(CPACK_RESOURCE_FILE_LICENSE
  368. "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
  369. _cpack_set_default(CPACK_RESOURCE_FILE_README
  370. "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
  371. _cpack_set_default(CPACK_RESOURCE_FILE_WELCOME
  372. "${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt")
  373. _cpack_set_default(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
  374. # Set default directory creation permissions mode
  375. if(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS)
  376. _cpack_set_default(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
  377. "${CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS}")
  378. endif()
  379. if(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
  380. set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
  381. endif()
  382. if(CPACK_NSIS_MODIFY_PATH)
  383. set(CPACK_NSIS_MODIFY_PATH ON)
  384. endif()
  385. set(__cpack_system_name ${CMAKE_SYSTEM_NAME})
  386. if(__cpack_system_name MATCHES "Windows")
  387. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  388. set(__cpack_system_name win64)
  389. else()
  390. set(__cpack_system_name win32)
  391. endif()
  392. endif()
  393. _cpack_set_default(CPACK_SYSTEM_NAME "${__cpack_system_name}")
  394. # Root dir: default value should be the string literal "$PROGRAMFILES"
  395. # for backwards compatibility. Projects may set this value to anything.
  396. # When creating 64 bit binaries we set the default value to "$PROGRAMFILES64"
  397. if("x${__cpack_system_name}" STREQUAL "xwin64")
  398. set(__cpack_root_default "$PROGRAMFILES64")
  399. else()
  400. set(__cpack_root_default "$PROGRAMFILES")
  401. endif()
  402. _cpack_set_default(CPACK_NSIS_INSTALL_ROOT "${__cpack_root_default}")
  403. # <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
  404. _cpack_set_default(CPACK_PACKAGE_FILE_NAME
  405. "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
  406. _cpack_set_default(CPACK_PACKAGE_INSTALL_DIRECTORY
  407. "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
  408. _cpack_set_default(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
  409. "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  410. _cpack_set_default(CPACK_PACKAGE_DEFAULT_LOCATION "/")
  411. _cpack_set_default(CPACK_PACKAGE_RELOCATABLE "true")
  412. # always force to exactly "true" or "false" for CPack.Info.plist.in:
  413. if(CPACK_PACKAGE_RELOCATABLE)
  414. set(CPACK_PACKAGE_RELOCATABLE "true")
  415. else()
  416. set(CPACK_PACKAGE_RELOCATABLE "false")
  417. endif()
  418. macro(cpack_check_file_exists file description)
  419. if(NOT EXISTS "${file}")
  420. message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
  421. endif()
  422. endmacro()
  423. cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description")
  424. cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource")
  425. cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}" "readme resource")
  426. cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource")
  427. macro(cpack_optional_append _list _cond _item)
  428. if(${_cond})
  429. set(${_list} ${${_list}} ${_item})
  430. endif()
  431. endmacro()
  432. #.rst:
  433. # .. variable:: CPACK_BINARY_<GENNAME>
  434. #
  435. # CPack generated options for binary generators. The CPack.cmake module
  436. # generates (when CPACK_GENERATOR is not set) a set of CMake options (see
  437. # CMake option command) which may then be used to select the CPack
  438. # generator(s) to be used when launching the package target.
  439. #
  440. # Provide options to choose generators we might check here if the required
  441. # tools for the generates exist and set the defaults according to the results
  442. if(NOT CPACK_GENERATOR)
  443. if(UNIX)
  444. if(CYGWIN)
  445. option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON)
  446. else()
  447. if(APPLE)
  448. option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF)
  449. option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF)
  450. option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF)
  451. option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" OFF)
  452. option(CPACK_BINARY_PRODUCTBUILD "Enable to build productbuild packages" OFF)
  453. else()
  454. option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
  455. endif()
  456. option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF)
  457. option(CPACK_BINARY_FREEBSD "Enable to build FreeBSD packages" OFF)
  458. option(CPACK_BINARY_NSIS "Enable to build NSIS packages" OFF)
  459. option(CPACK_BINARY_RPM "Enable to build RPM packages" OFF)
  460. option(CPACK_BINARY_STGZ "Enable to build STGZ packages" ON)
  461. option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages" OFF)
  462. option(CPACK_BINARY_TGZ "Enable to build TGZ packages" ON)
  463. option(CPACK_BINARY_TXZ "Enable to build TXZ packages" OFF)
  464. endif()
  465. else()
  466. option(CPACK_BINARY_7Z "Enable to build 7-Zip packages" OFF)
  467. option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON)
  468. option(CPACK_BINARY_WIX "Enable to build WiX packages" OFF)
  469. option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF)
  470. endif()
  471. option(CPACK_BINARY_IFW "Enable to build IFW packages" OFF)
  472. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_7Z 7Z)
  473. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle)
  474. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary)
  475. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DEB DEB)
  476. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DRAGNDROP DragNDrop)
  477. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_FREEBSD FREEBSD)
  478. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_IFW IFW)
  479. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS)
  480. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11)
  481. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker)
  482. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PRODUCTBUILD productbuild)
  483. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM)
  484. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_STGZ STGZ)
  485. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2)
  486. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TGZ TGZ)
  487. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TXZ TXZ)
  488. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TZ TZ)
  489. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_WIX WIX)
  490. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_ZIP ZIP)
  491. endif()
  492. # Provide options to choose source generators
  493. if(NOT CPACK_SOURCE_GENERATOR)
  494. if(UNIX)
  495. if(CYGWIN)
  496. option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
  497. else()
  498. option(CPACK_SOURCE_RPM "Enable to build RPM source packages" OFF)
  499. option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
  500. option(CPACK_SOURCE_TGZ "Enable to build TGZ source packages" ON)
  501. option(CPACK_SOURCE_TXZ "Enable to build TXZ source packages" ON)
  502. option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON)
  503. option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF)
  504. endif()
  505. else()
  506. option(CPACK_SOURCE_7Z "Enable to build 7-Zip source packages" ON)
  507. option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
  508. endif()
  509. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_7Z 7Z)
  510. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_CYGWIN CygwinSource)
  511. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_RPM RPM)
  512. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TBZ2 TBZ2)
  513. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TGZ TGZ)
  514. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TXZ TXZ)
  515. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TZ TZ)
  516. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP)
  517. endif()
  518. # mark the above options as advanced
  519. mark_as_advanced(
  520. CPACK_BINARY_7Z
  521. CPACK_BINARY_BUNDLE
  522. CPACK_BINARY_CYGWIN
  523. CPACK_BINARY_DEB
  524. CPACK_BINARY_DRAGNDROP
  525. CPACK_BINARY_FREEBSD
  526. CPACK_BINARY_IFW
  527. CPACK_BINARY_NSIS
  528. CPACK_BINARY_OSXX11
  529. CPACK_BINARY_PACKAGEMAKER
  530. CPACK_BINARY_PRODUCTBUILD
  531. CPACK_BINARY_RPM
  532. CPACK_BINARY_STGZ
  533. CPACK_BINARY_TBZ2
  534. CPACK_BINARY_TGZ
  535. CPACK_BINARY_TXZ
  536. CPACK_BINARY_TZ
  537. CPACK_BINARY_WIX
  538. CPACK_BINARY_ZIP
  539. CPACK_SOURCE_7Z
  540. CPACK_SOURCE_CYGWIN
  541. CPACK_SOURCE_RPM
  542. CPACK_SOURCE_TBZ2
  543. CPACK_SOURCE_TGZ
  544. CPACK_SOURCE_TXZ
  545. CPACK_SOURCE_TZ
  546. CPACK_SOURCE_ZIP
  547. )
  548. # Set some other variables
  549. _cpack_set_default(CPACK_INSTALL_CMAKE_PROJECTS
  550. "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
  551. _cpack_set_default(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
  552. _cpack_set_default(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
  553. # if the user has set CPACK_NSIS_DISPLAY_NAME remember it
  554. if(DEFINED CPACK_NSIS_DISPLAY_NAME)
  555. set(CPACK_NSIS_DISPLAY_NAME_SET TRUE)
  556. endif()
  557. # if the user has set CPACK_NSIS_DISPLAY
  558. # explicitly, then use that as the default
  559. # value of CPACK_NSIS_PACKAGE_NAME instead
  560. # of CPACK_PACKAGE_INSTALL_DIRECTORY
  561. _cpack_set_default(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  562. if(CPACK_NSIS_DISPLAY_NAME_SET)
  563. _cpack_set_default(CPACK_NSIS_PACKAGE_NAME "${CPACK_NSIS_DISPLAY_NAME}")
  564. else()
  565. _cpack_set_default(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  566. endif()
  567. _cpack_set_default(CPACK_OUTPUT_CONFIG_FILE
  568. "${CMAKE_BINARY_DIR}/CPackConfig.cmake")
  569. _cpack_set_default(CPACK_SOURCE_OUTPUT_CONFIG_FILE
  570. "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")
  571. _cpack_set_default(CPACK_SET_DESTDIR OFF)
  572. _cpack_set_default(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
  573. _cpack_set_default(CPACK_NSIS_INSTALLER_ICON_CODE "")
  574. _cpack_set_default(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
  575. # WiX specific variables
  576. _cpack_set_default(CPACK_WIX_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
  577. # set sysroot so SDK tools can be used
  578. if(CMAKE_OSX_SYSROOT)
  579. _cpack_set_default(CPACK_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
  580. endif()
  581. _cpack_set_default(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR};${CMAKE_BINARY_DIR}")
  582. if(DEFINED CPACK_COMPONENTS_ALL)
  583. if(CPACK_MONOLITHIC_INSTALL)
  584. message("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.")
  585. set(CPACK_COMPONENTS_ALL)
  586. else()
  587. # The user has provided the set of components to be installed as
  588. # part of a component-based installation; trust her.
  589. set(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE)
  590. endif()
  591. else()
  592. # If the user has not specifically requested a monolithic installer
  593. # but has specified components in various "install" commands, tell
  594. # CPack about those components.
  595. if(NOT CPACK_MONOLITHIC_INSTALL)
  596. get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
  597. list(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN)
  598. if(CPACK_COMPONENTS_LEN EQUAL 1)
  599. # Only one component: this is not a component-based installation
  600. # (at least, it isn't a component-based installation, but may
  601. # become one later if the user uses the cpack_add_* commands).
  602. set(CPACK_COMPONENTS_ALL)
  603. endif()
  604. set(CPACK_COMPONENTS_LEN)
  605. endif()
  606. endif()
  607. # CMake always generates a component named "Unspecified", which is
  608. # used to install everything that doesn't have an explicitly-provided
  609. # component. Since these files should always be installed, we'll make
  610. # them hidden and required.
  611. set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE)
  612. set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE)
  613. cpack_encode_variables()
  614. configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY)
  615. # Generate source file
  616. _cpack_set_default(CPACK_SOURCE_INSTALLED_DIRECTORIES
  617. "${CMAKE_SOURCE_DIR};/")
  618. _cpack_set_default(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-Source")
  619. _cpack_set_default(CPACK_SOURCE_PACKAGE_FILE_NAME
  620. "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
  621. set(__cpack_source_ignore_files_default
  622. "/CVS/;/\\.svn/;/\\.bzr/;/\\.hg/;/\\.git/;\\.swp$;\\.#;/#")
  623. if(NOT CPACK_VERBATIM_VARIABLES)
  624. _cpack_escape_for_cmake(__cpack_source_ignore_files_default
  625. "${__cpack_source_ignore_files_default}")
  626. endif()
  627. _cpack_set_default(CPACK_SOURCE_IGNORE_FILES "${__cpack_source_ignore_files_default}")
  628. set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
  629. set(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
  630. set(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
  631. set(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}")
  632. set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
  633. set(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
  634. set(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
  635. set(CPACK_RPM_PACKAGE_SOURCES "ON")
  636. cpack_encode_variables()
  637. configure_file("${cpack_source_input_file}"
  638. "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY)