CPack.cmake 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. ##section Variables common to all CPack generators
  2. ##end
  3. ##module
  4. # - Build binary and source package installers.
  5. # The CPack module generates binary and source installers in a variety
  6. # of formats using the cpack program. Inclusion of the CPack module
  7. # adds two new targets to the resulting makefiles, package and
  8. # package_source, which build the binary and source installers,
  9. # respectively. The generated binary installers contain everything
  10. # installed via CMake's INSTALL command (and the deprecated
  11. # INSTALL_FILES, INSTALL_PROGRAMS, and INSTALL_TARGETS commands).
  12. #
  13. # For certain kinds of binary installers (including the graphical
  14. # installers on Mac OS X and Windows), CPack generates installers that
  15. # allow users to select individual application components to
  16. # install. See CPackComponent module for that.
  17. #
  18. # The CPACK_GENERATOR variable has different meanings in different
  19. # contexts. In your CMakeLists.txt file, CPACK_GENERATOR is a
  20. # *list of generators*: when run with no other arguments, CPack
  21. # will iterate over that list and produce one package for each
  22. # generator. In a CPACK_PROJECT_CONFIG_FILE, though, CPACK_GENERATOR
  23. # is a *string naming a single generator*. If you need per-cpack-
  24. # generator logic to control *other* cpack settings, then you need
  25. # a CPACK_PROJECT_CONFIG_FILE.
  26. #
  27. # The CMake source tree itself contains a CPACK_PROJECT_CONFIG_FILE.
  28. # See the top level file CMakeCPackOptions.cmake.in for an example.
  29. #
  30. # If set, the CPACK_PROJECT_CONFIG_FILE is included automatically
  31. # on a per-generator basis. It only need contain overrides.
  32. #
  33. # Here's how it works:
  34. # - cpack runs
  35. # - it includes CPackConfig.cmake
  36. # - it iterates over the generators listed in that file's
  37. # CPACK_GENERATOR list variable (unless told to use just a
  38. # specific one via -G on the command line...)
  39. #
  40. # - foreach generator, it then
  41. # - sets CPACK_GENERATOR to the one currently being iterated
  42. # - includes the CPACK_PROJECT_CONFIG_FILE
  43. # - produces the package for that generator
  44. #
  45. # This is the key: For each generator listed in CPACK_GENERATOR
  46. # in CPackConfig.cmake, cpack will *reset* CPACK_GENERATOR
  47. # internally to *the one currently being used* and then include
  48. # the CPACK_PROJECT_CONFIG_FILE.
  49. #
  50. # Before including this CPack module in your CMakeLists.txt file,
  51. # there are a variety of variables that can be set to customize
  52. # the resulting installers. The most commonly-used variables are:
  53. ##end
  54. #
  55. ##variable
  56. # CPACK_PACKAGE_NAME - The name of the package (or application). If
  57. # not specified, defaults to the project name.
  58. ##end
  59. #
  60. ##variable
  61. # CPACK_PACKAGE_VENDOR - The name of the package vendor. (e.g.,
  62. # "Kitware").
  63. ##end
  64. #
  65. ##variable
  66. # CPACK_PACKAGE_VERSION_MAJOR - Package major Version
  67. ##end
  68. #
  69. ##variable
  70. # CPACK_PACKAGE_VERSION_MINOR - Package minor Version
  71. ##end
  72. #
  73. ##variable
  74. # CPACK_PACKAGE_VERSION_PATCH - Package patch Version
  75. ##end
  76. #
  77. ##variable
  78. # CPACK_PACKAGE_DESCRIPTION_FILE - A text file used to describe the
  79. # project. Used, for example, the introduction screen of a
  80. # CPack-generated Windows installer to describe the project.
  81. ##end
  82. #
  83. ##variable
  84. # CPACK_PACKAGE_DESCRIPTION_SUMMARY - Short description of the
  85. # project (only a few words).
  86. ##end
  87. #
  88. ##variable
  89. # CPACK_PACKAGE_FILE_NAME - The name of the package file to generate,
  90. # not including the extension. For example, cmake-2.6.1-Linux-i686.
  91. # The default value is
  92. # ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}.
  93. ##end
  94. #
  95. ##variable
  96. # CPACK_PACKAGE_INSTALL_DIRECTORY - Installation directory on the
  97. # target system. This may be used by some CPack generators
  98. # like NSIS to create an installation directory e.g., "CMake 2.5"
  99. # below the installation prefix. All installed element will be
  100. # put inside this directory.
  101. ##end
  102. #
  103. ##variable
  104. # CPACK_PACKAGE_ICON - A branding image that will be displayed inside
  105. # the installer (used by GUI installers).
  106. ##end
  107. #
  108. ##variable
  109. # CPACK_PROJECT_CONFIG_FILE - CPack-time project CPack configuration
  110. # file. This file included at cpack time, once per
  111. # generator after CPack has set CPACK_GENERATOR to the actual generator
  112. # being used. It allows per-generator setting of CPACK_* variables at
  113. # cpack time.
  114. ##end
  115. #
  116. ##variable
  117. # CPACK_RESOURCE_FILE_LICENSE - License to be embedded in the installer. It
  118. # will typically be displayed to the user by the produced installer
  119. # (often with an explicit "Accept" button, for graphical installers)
  120. # prior to installation. This license file is NOT added to installed
  121. # file but is used by some CPack generators like NSIS. If you want
  122. # to install a license file (may be the same as this one)
  123. # along with your project you must add an appropriate CMake INSTALL
  124. # command in your CMakeLists.txt.
  125. ##end
  126. #
  127. ##variable
  128. # CPACK_RESOURCE_FILE_README - ReadMe file to be embedded in the installer. It
  129. # typically describes in some detail the purpose of the project
  130. # during the installation. Not all CPack generators uses
  131. # this file.
  132. ##end
  133. #
  134. ##variable
  135. # CPACK_RESOURCE_FILE_WELCOME - Welcome file to be embedded in the
  136. # installer. It welcomes users to this installer.
  137. # Typically used in the graphical installers on Windows and Mac OS X.
  138. ##end
  139. #
  140. ##variable
  141. # CPACK_MONOLITHIC_INSTALL - Disables the component-based
  142. # installation mechanism. When set the component specification is ignored
  143. # and all installed items are put in a single "MONOLITHIC" package.
  144. # Some CPack generators do monolithic packaging by default and
  145. # may be asked to do component packaging by setting
  146. # CPACK_<GENNAME>_COMPONENT_INSTALL to 1/TRUE.
  147. ##end
  148. #
  149. ##variable
  150. # CPACK_GENERATOR - List of CPack generators to use. If not
  151. # specified, CPack will create a set of options CPACK_BINARY_<GENNAME> (e.g.,
  152. # CPACK_BINARY_NSIS) allowing the user to enable/disable individual
  153. # generators. This variable may be used on the command line
  154. # as well as in:
  155. #
  156. # cpack -D CPACK_GENERATOR="ZIP;TGZ" /path/to/build/tree
  157. ##end
  158. #
  159. ##variable
  160. # CPACK_OUTPUT_CONFIG_FILE - The name of the CPack binary configuration
  161. # file. This file is the CPack configuration generated by the CPack module
  162. # for binary installers. Defaults to CPackConfig.cmake.
  163. ##end
  164. #
  165. ##variable
  166. # CPACK_PACKAGE_EXECUTABLES - Lists each of the executables and associated
  167. # text label to be used to create Start Menu shortcuts. For example,
  168. # setting this to the list ccmake;CMake will
  169. # create a shortcut named "CMake" that will execute the installed
  170. # executable ccmake. Not all CPack generators use it (at least NSIS and
  171. # OSXX11 do).
  172. ##end
  173. #
  174. ##variable
  175. # CPACK_STRIP_FILES - List of files to be stripped. Starting with
  176. # CMake 2.6.0 CPACK_STRIP_FILES will be a boolean variable which
  177. # enables stripping of all files (a list of files evaluates to TRUE
  178. # in CMake, so this change is compatible).
  179. ##end
  180. #
  181. # The following CPack variables are specific to source packages, and
  182. # will not affect binary packages:
  183. #
  184. ##variable
  185. # CPACK_SOURCE_PACKAGE_FILE_NAME - The name of the source package. For
  186. # example cmake-2.6.1.
  187. ##end
  188. #
  189. ##variable
  190. # CPACK_SOURCE_STRIP_FILES - List of files in the source tree that
  191. # will be stripped. Starting with CMake 2.6.0
  192. # CPACK_SOURCE_STRIP_FILES will be a boolean variable which enables
  193. # stripping of all files (a list of files evaluates to TRUE in CMake,
  194. # so this change is compatible).
  195. ##end
  196. #
  197. ##variable
  198. # CPACK_SOURCE_GENERATOR - List of generators used for the source
  199. # packages. As with CPACK_GENERATOR, if this is not specified then
  200. # CPack will create a set of options (e.g., CPACK_SOURCE_ZIP)
  201. # allowing users to select which packages will be generated.
  202. ##end
  203. #
  204. ##variable
  205. # CPACK_SOURCE_OUTPUT_CONFIG_FILE - The name of the CPack source
  206. # configuration file. This file is the CPack configuration generated by the
  207. # CPack module for source installers. Defaults to CPackSourceConfig.cmake.
  208. ##end
  209. #
  210. ##variable
  211. # CPACK_SOURCE_IGNORE_FILES - Pattern of files in the source tree
  212. # that won't be packaged when building a source package. This is a
  213. # list of regular expression patterns (that must be properly escaped),
  214. # e.g., /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.*
  215. ##end
  216. #
  217. # The following variables are for advanced uses of CPack:
  218. #
  219. ##variable
  220. # CPACK_CMAKE_GENERATOR - What CMake generator should be used if the
  221. # project is CMake project. Defaults to the value of CMAKE_GENERATOR
  222. # few users will want to change this setting.
  223. ##end
  224. #
  225. ##variable
  226. # CPACK_INSTALL_CMAKE_PROJECTS - List of four values that specify
  227. # what project to install. The four values are: Build directory,
  228. # Project Name, Project Component, Directory. If omitted, CPack will
  229. # build an installer that installers everything.
  230. ##end
  231. #
  232. ##variable
  233. # CPACK_SYSTEM_NAME - System name, defaults to the value of
  234. # ${CMAKE_SYSTEM_NAME}.
  235. ##end
  236. #
  237. ##variable
  238. # CPACK_PACKAGE_VERSION - Package full version, used internally. By
  239. # default, this is built from CPACK_PACKAGE_VERSION_MAJOR,
  240. # CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH.
  241. ##end
  242. #
  243. ##variable
  244. # CPACK_TOPLEVEL_TAG - Directory for the installed files.
  245. ##end
  246. #
  247. ##variable
  248. # CPACK_INSTALL_COMMANDS - Extra commands to install components.
  249. ##end
  250. #
  251. ##variable
  252. # CPACK_INSTALLED_DIRECTORIES - Extra directories to install.
  253. ##end
  254. #
  255. ##variable
  256. # CPACK_PACKAGE_INSTALL_REGISTRY_KEY - Registry key used when
  257. # installing this project. This is only used
  258. # by installer for Windows.
  259. ##end
  260. ##variable
  261. # CPACK_CREATE_DESKTOP_LINKS - List of desktop links to create.
  262. ##end
  263. #
  264. #=============================================================================
  265. # Copyright 2006-2009 Kitware, Inc.
  266. #
  267. # Distributed under the OSI-approved BSD License (the "License");
  268. # see accompanying file Copyright.txt for details.
  269. #
  270. # This software is distributed WITHOUT ANY WARRANTY; without even the
  271. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  272. # See the License for more information.
  273. #=============================================================================
  274. # (To distribute this file outside of CMake, substitute the full
  275. # License text for the above reference.)
  276. # Define this var in order to avoid (or warn) concerning multiple inclusion
  277. IF(CPack_CMake_INCLUDED)
  278. MESSAGE(WARNING "CPack.cmake has already been included!!")
  279. ELSE(CPack_CMake_INCLUDED)
  280. SET(CPack_CMake_INCLUDED 1)
  281. ENDIF(CPack_CMake_INCLUDED)
  282. # Pick a configuration file
  283. SET(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
  284. IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  285. SET(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  286. ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  287. SET(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
  288. IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  289. SET(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  290. ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  291. # Backward compatibility
  292. # Include CPackComponent macros if it has not already been included before.
  293. include(CPackComponent)
  294. # Macro for setting values if a user did not overwrite them
  295. MACRO(cpack_set_if_not_set name value)
  296. IF(NOT DEFINED "${name}")
  297. SET(${name} "${value}")
  298. ENDIF(NOT DEFINED "${name}")
  299. ENDMACRO(cpack_set_if_not_set)
  300. # cpack_encode_variables - Macro to encode variables for the configuration file
  301. # find any variable that starts with CPACK and create a variable
  302. # _CPACK_OTHER_VARIABLES_ that contains SET commands for
  303. # each cpack variable. _CPACK_OTHER_VARIABLES_ is then
  304. # used as an @ replacment in configure_file for the CPackConfig.
  305. MACRO(cpack_encode_variables)
  306. SET(_CPACK_OTHER_VARIABLES_)
  307. GET_CMAKE_PROPERTY(res VARIABLES)
  308. FOREACH(var ${res})
  309. IF("xxx${var}" MATCHES "xxxCPACK")
  310. SET(_CPACK_OTHER_VARIABLES_
  311. "${_CPACK_OTHER_VARIABLES_}\nSET(${var} \"${${var}}\")")
  312. ENDIF("xxx${var}" MATCHES "xxxCPACK")
  313. ENDFOREACH(var ${res})
  314. ENDMACRO(cpack_encode_variables)
  315. # Set the package name
  316. cpack_set_if_not_set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
  317. cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MAJOR "0")
  318. cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MINOR "1")
  319. cpack_set_if_not_set(CPACK_PACKAGE_VERSION_PATCH "1")
  320. cpack_set_if_not_set(CPACK_PACKAGE_VERSION
  321. "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
  322. cpack_set_if_not_set(CPACK_PACKAGE_VENDOR "Humanity")
  323. cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
  324. "${CMAKE_PROJECT_NAME} built using CMake")
  325. cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_FILE
  326. "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
  327. cpack_set_if_not_set(CPACK_RESOURCE_FILE_LICENSE
  328. "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
  329. cpack_set_if_not_set(CPACK_RESOURCE_FILE_README
  330. "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
  331. cpack_set_if_not_set(CPACK_RESOURCE_FILE_WELCOME
  332. "${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt")
  333. cpack_set_if_not_set(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
  334. IF(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
  335. SET(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
  336. ENDIF(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
  337. IF(CPACK_NSIS_MODIFY_PATH)
  338. SET(CPACK_NSIS_MODIFY_PATH ON)
  339. ENDIF(CPACK_NSIS_MODIFY_PATH)
  340. SET(__cpack_system_name ${CMAKE_SYSTEM_NAME})
  341. IF(${__cpack_system_name} MATCHES Windows)
  342. IF(CMAKE_CL_64)
  343. SET(__cpack_system_name win64)
  344. ELSE(CMAKE_CL_64)
  345. SET(__cpack_system_name win32)
  346. ENDIF(CMAKE_CL_64)
  347. ENDIF(${__cpack_system_name} MATCHES Windows)
  348. cpack_set_if_not_set(CPACK_SYSTEM_NAME "${__cpack_system_name}")
  349. # Root dir: default value should be the string literal "$PROGRAMFILES"
  350. # for backwards compatibility. Projects may set this value to anything.
  351. set(__cpack_root_default "$PROGRAMFILES")
  352. cpack_set_if_not_set(CPACK_NSIS_INSTALL_ROOT "${__cpack_root_default}")
  353. # <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
  354. cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME
  355. "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
  356. cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY
  357. "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
  358. cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
  359. "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  360. cpack_set_if_not_set(CPACK_PACKAGE_DEFAULT_LOCATION "/")
  361. cpack_set_if_not_set(CPACK_PACKAGE_RELOCATABLE "true")
  362. # always force to exactly "true" or "false" for CPack.Info.plist.in:
  363. if(CPACK_PACKAGE_RELOCATABLE)
  364. set(CPACK_PACKAGE_RELOCATABLE "true")
  365. else(CPACK_PACKAGE_RELOCATABLE)
  366. set(CPACK_PACKAGE_RELOCATABLE "false")
  367. endif(CPACK_PACKAGE_RELOCATABLE)
  368. macro(cpack_check_file_exists file description)
  369. if(NOT EXISTS "${file}")
  370. message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
  371. endif(NOT EXISTS "${file}")
  372. endmacro(cpack_check_file_exists)
  373. cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description")
  374. cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource")
  375. cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}" "readme resource")
  376. cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource")
  377. macro(cpack_optional_append _list _cond _item)
  378. if(${_cond})
  379. set(${_list} ${${_list}} ${_item})
  380. endif(${_cond})
  381. endmacro(cpack_optional_append _list _cond _item)
  382. ##variable
  383. # CPACK_BINARY_<GENNAME> - CPack generated options for binary generators. The
  384. # CPack.cmake module generates (when CPACK_GENERATOR is not set)
  385. # a set of CMake options (see CMake option command) which may then be used to
  386. # select the CPack generator(s) to be used when launching the package target.
  387. ##end
  388. # Provide options to choose generators
  389. # we might check here if the required tools for the generates exist
  390. # and set the defaults according to the results
  391. if(NOT CPACK_GENERATOR)
  392. if(UNIX)
  393. if(CYGWIN)
  394. option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON)
  395. else(CYGWIN)
  396. if(APPLE)
  397. option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF)
  398. option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF)
  399. option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" ON)
  400. option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF)
  401. else(APPLE)
  402. option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
  403. endif(APPLE)
  404. option(CPACK_BINARY_STGZ "Enable to build STGZ packages" ON)
  405. option(CPACK_BINARY_TGZ "Enable to build TGZ packages" ON)
  406. option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages" OFF)
  407. option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF)
  408. option(CPACK_BINARY_RPM "Enable to build RPM packages" OFF)
  409. option(CPACK_BINARY_NSIS "Enable to build NSIS packages" OFF)
  410. endif(CYGWIN)
  411. else(UNIX)
  412. option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON)
  413. option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF)
  414. endif(UNIX)
  415. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle)
  416. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DRAGNDROP DragNDrop)
  417. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker)
  418. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11)
  419. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary)
  420. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DEB DEB)
  421. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM)
  422. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS)
  423. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_STGZ STGZ)
  424. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TGZ TGZ)
  425. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2)
  426. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TZ TZ)
  427. cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_ZIP ZIP)
  428. endif(NOT CPACK_GENERATOR)
  429. # Provide options to choose source generators
  430. if(NOT CPACK_SOURCE_GENERATOR)
  431. if(UNIX)
  432. if(CYGWIN)
  433. option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
  434. else(CYGWIN)
  435. option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
  436. option(CPACK_SOURCE_TGZ "Enable to build TGZ source packages" ON)
  437. option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON)
  438. option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF)
  439. endif(CYGWIN)
  440. else(UNIX)
  441. option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
  442. endif(UNIX)
  443. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_CYGWIN CygwinSource)
  444. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TGZ TGZ)
  445. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TBZ2 TBZ2)
  446. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TZ TZ)
  447. cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP)
  448. endif(NOT CPACK_SOURCE_GENERATOR)
  449. # mark the above options as advanced
  450. mark_as_advanced(CPACK_BINARY_CYGWIN CPACK_BINARY_PACKAGEMAKER CPACK_BINARY_OSXX11
  451. CPACK_BINARY_STGZ CPACK_BINARY_TGZ CPACK_BINARY_TBZ2
  452. CPACK_BINARY_DEB CPACK_BINARY_RPM CPACK_BINARY_TZ
  453. CPACK_BINARY_NSIS CPACK_BINARY_ZIP CPACK_BINARY_BUNDLE
  454. CPACK_SOURCE_CYGWIN CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ
  455. CPACK_SOURCE_TZ CPACK_SOURCE_ZIP CPACK_BINARY_DRAGNDROP)
  456. # Set some other variables
  457. cpack_set_if_not_set(CPACK_INSTALL_CMAKE_PROJECTS
  458. "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
  459. cpack_set_if_not_set(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
  460. cpack_set_if_not_set(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
  461. # if the user has set CPACK_NSIS_DISPLAY_NAME remember it
  462. if(DEFINED CPACK_NSIS_DISPLAY_NAME)
  463. SET(CPACK_NSIS_DISPLAY_NAME_SET TRUE)
  464. endif()
  465. # if the user has set CPACK_NSIS_DISPLAY
  466. # explicitly, then use that as the default
  467. # value of CPACK_NSIS_PACKAGE_NAME instead
  468. # of CPACK_PACKAGE_INSTALL_DIRECTORY
  469. cpack_set_if_not_set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  470. if(CPACK_NSIS_DISPLAY_NAME_SET)
  471. string(REPLACE "\\" "\\\\"
  472. _NSIS_DISPLAY_NAME_TMP "${CPACK_NSIS_DISPLAY_NAME}")
  473. cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME "${_NSIS_DISPLAY_NAME_TMP}")
  474. else()
  475. cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
  476. endif()
  477. cpack_set_if_not_set(CPACK_OUTPUT_CONFIG_FILE
  478. "${CMAKE_BINARY_DIR}/CPackConfig.cmake")
  479. cpack_set_if_not_set(CPACK_SOURCE_OUTPUT_CONFIG_FILE
  480. "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")
  481. cpack_set_if_not_set(CPACK_SET_DESTDIR OFF)
  482. cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
  483. cpack_set_if_not_set(CPACK_NSIS_INSTALLER_ICON_CODE "")
  484. cpack_set_if_not_set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
  485. IF(DEFINED CPACK_COMPONENTS_ALL)
  486. IF(CPACK_MONOLITHIC_INSTALL)
  487. MESSAGE("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.")
  488. SET(CPACK_COMPONENTS_ALL)
  489. ELSE(CPACK_MONOLITHIC_INSTALL)
  490. # The user has provided the set of components to be installed as
  491. # part of a component-based installation; trust her.
  492. SET(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE)
  493. ENDIF(CPACK_MONOLITHIC_INSTALL)
  494. ELSE(DEFINED CPACK_COMPONENTS_ALL)
  495. # If the user has not specifically requested a monolithic installer
  496. # but has specified components in various "install" commands, tell
  497. # CPack about those components.
  498. IF(NOT CPACK_MONOLITHIC_INSTALL)
  499. GET_CMAKE_PROPERTY(CPACK_COMPONENTS_ALL COMPONENTS)
  500. LIST(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN)
  501. IF(CPACK_COMPONENTS_LEN EQUAL 1)
  502. # Only one component: this is not a component-based installation
  503. # (at least, it isn't a component-based installation, but may
  504. # become one later if the user uses the cpack_add_* commands).
  505. SET(CPACK_COMPONENTS_ALL)
  506. ENDIF(CPACK_COMPONENTS_LEN EQUAL 1)
  507. SET(CPACK_COMPONENTS_LEN)
  508. ENDIF(NOT CPACK_MONOLITHIC_INSTALL)
  509. ENDIF(DEFINED CPACK_COMPONENTS_ALL)
  510. # CMake always generates a component named "Unspecified", which is
  511. # used to install everything that doesn't have an explicitly-provided
  512. # component. Since these files should always be installed, we'll make
  513. # them hidden and required.
  514. set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE)
  515. set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE)
  516. cpack_encode_variables()
  517. configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)
  518. # Generate source file
  519. cpack_set_if_not_set(CPACK_SOURCE_INSTALLED_DIRECTORIES
  520. "${CMAKE_SOURCE_DIR};/")
  521. cpack_set_if_not_set(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-Source")
  522. cpack_set_if_not_set(CPACK_SOURCE_PACKAGE_FILE_NAME
  523. "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
  524. cpack_set_if_not_set(CPACK_SOURCE_IGNORE_FILES
  525. "/CVS/;/\\\\\\\\.svn/;/\\\\\\\\.bzr/;/\\\\\\\\.hg/;/\\\\\\\\.git/;\\\\\\\\.swp$;\\\\\\\\.#;/#")
  526. SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
  527. SET(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
  528. SET(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
  529. SET(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}")
  530. SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
  531. SET(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
  532. SET(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
  533. cpack_encode_variables()
  534. configure_file("${cpack_source_input_file}"
  535. "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)