CPack.cmake 23 KB

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