CPack.cmake 23 KB

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