CPack.cmake 23 KB

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