CPack.cmake 25.1 KB
Newer Older
1 2 3 4 5 6
#.rst:
# CPack
# -----
#
# Build binary and source package installers.
#
7 8 9 10
# Variables common to all CPack generators
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#
# The
11 12 13
# CPack module generates binary and source installers in a variety of
# formats using the cpack program.  Inclusion of the CPack module adds
# 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 17 18 19 20
# installed via CMake's INSTALL command (and the deprecated
# INSTALL_FILES, INSTALL_PROGRAMS, and INSTALL_TARGETS commands).
#
# For certain kinds of binary installers (including the graphical
# installers on Mac OS X and Windows), CPack generates installers that
21 22
# allow users to select individual application components to install.
# See CPackComponent module for that.
23
#
24
# The CPACK_GENERATOR variable has different meanings in different
25 26 27 28 29 30 31
# contexts.  In your CMakeLists.txt file, CPACK_GENERATOR is a *list of
# generators*: when run with no other arguments, CPack will iterate over
# that list and produce one package for each generator.  In a
# CPACK_PROJECT_CONFIG_FILE, though, CPACK_GENERATOR is a *string naming
# a single generator*.  If you need per-cpack- generator logic to
# control *other* cpack settings, then you need a
# CPACK_PROJECT_CONFIG_FILE.
32 33 34 35
#
# The CMake source tree itself contains a CPACK_PROJECT_CONFIG_FILE.
# See the top level file CMakeCPackOptions.cmake.in for an example.
#
36 37
# If set, the CPACK_PROJECT_CONFIG_FILE is included automatically on a
# per-generator basis.  It only need contain overrides.
38 39
#
# Here's how it works:
40
#
41 42 43 44 45 46
# * cpack runs
# * it includes CPackConfig.cmake
# * it iterates over the generators listed in that file's
#   CPACK_GENERATOR list variable (unless told to use just a
#   specific one via -G on the command line...)
# * foreach generator, it then
47
#
48 49 50
#   - sets CPACK_GENERATOR to the one currently being iterated
#   - includes the CPACK_PROJECT_CONFIG_FILE
#   - produces the package for that generator
51 52 53 54 55 56 57 58
#
# This is the key: For each generator listed in CPACK_GENERATOR in
# CPackConfig.cmake, cpack will *reset* CPACK_GENERATOR internally to
# *the one currently being used* and then include the
# CPACK_PROJECT_CONFIG_FILE.
#
# Before including this CPack module in your CMakeLists.txt file, there
# 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 64
#  The name of the package (or application). If not specified, defaults to
#  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 73 74 75 76
#  The directory in which CPack is doing its packaging. If it is not set
#  then this will default (internally) to the build dir. This variable may
#  be defined in CPack config file or from the cpack command line option
#  "-B". If set the command line option override the value found in the
#  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 93 94
#  A text file used to describe the project. Used, for example, the
#  introduction screen of a CPack-generated Windows installer to describe
#  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 103
#  The name of the package file to generate, not including the
#  extension. For example, cmake-2.6.1-Linux-i686.  The default value is::
104 105 106
#
#   ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}.
#
107
# .. variable:: CPACK_PACKAGE_INSTALL_DIRECTORY
108
#
109 110 111 112
#  Installation directory on the target system. This may be used by some
#  CPack generators like NSIS to create an installation directory e.g.,
#  "CMake 2.5" below the installation prefix. All installed element will be
#  put inside this directory.
113
#
114
# .. variable:: CPACK_PACKAGE_ICON
115
#
116 117
#  A branding image that will be displayed inside the installer (used by GUI
#  installers).
118
#
119
# .. variable:: CPACK_PROJECT_CONFIG_FILE
120
#
121 122 123 124
#  CPack-time project CPack configuration file. This file included at cpack
#  time, once per generator after CPack has set CPACK_GENERATOR to the
#  actual generator being used. It allows per-generator setting of CPACK_*
#  variables at cpack time.
125
#
126
# .. variable:: CPACK_RESOURCE_FILE_LICENSE
127
#
128 129 130 131 132 133 134
#  License to be embedded in the installer. It will typically be displayed
#  to the user by the produced installer (often with an explicit "Accept"
#  button, for graphical installers) prior to installation. This license
#  file is NOT added to installed file but is used by some CPack generators
#  like NSIS. If you want to install a license file (may be the same as this
#  one) along with your project you must add an appropriate CMake INSTALL
#  command in your CMakeLists.txt.
135
#
136
# .. variable:: CPACK_RESOURCE_FILE_README
137
#
138 139 140
#  ReadMe file to be embedded in the installer. It typically describes in
#  some detail the purpose of the project during the installation. Not all
#  CPack generators uses this file.
141
#
142
# .. variable:: CPACK_RESOURCE_FILE_WELCOME
143
#
144 145 146
#  Welcome file to be embedded in the installer. It welcomes users to this
#  installer.  Typically used in the graphical installers on Windows and Mac
#  OS X.
147
#
148
# .. variable:: CPACK_MONOLITHIC_INSTALL
149
#
150 151 152 153 154
#  Disables the component-based installation mechanism. When set the
#  component specification is ignored and all installed items are put in a
#  single "MONOLITHIC" package.  Some CPack generators do monolithic
#  packaging by default and may be asked to do component packaging by
#  setting CPACK_<GENNAME>_COMPONENT_INSTALL to 1/TRUE.
155
#
156
# .. variable:: CPACK_GENERATOR
157
#
158 159 160 161
#  List of CPack generators to use. If not specified, CPack will create a
#  set of options CPACK_BINARY_<GENNAME> (e.g., CPACK_BINARY_NSIS) allowing
#  the user to enable/disable individual generators. This variable may be
#  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 168 169
#  The name of the CPack binary configuration file. This file is the CPack
#  configuration generated by the CPack module for binary
#  installers. Defaults to CPackConfig.cmake.
170
#
171
# .. variable:: CPACK_PACKAGE_EXECUTABLES
172
#
173 174 175 176
#  Lists each of the executables and associated text label to be used to
#  create Start Menu shortcuts. For example, setting this to the list
#  ccmake;CMake will create a shortcut named "CMake" that will execute the
#  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 182 183
#  List of files to be stripped. Starting with CMake 2.6.0 CPACK_STRIP_FILES
#  will be a boolean variable which enables stripping of all files (a list
#  of files evaluates to TRUE in CMake, so this change is compatible).
184
#
185 186 187 188 189 190 191 192 193 194 195
# .. variable:: CPACK_VERBATIM_VARIABLES
#
#  If set to TRUE, values of variables prefixed with CPACK_ will be escaped
#  before being written to the configuration files, so that the cpack program
#  receives them exactly as they were specified. If not, characters like quotes
#  and backslashes can cause parsing errors or alter the value received by the
#  cpack program. Defaults to FALSE for backwards compatibility.
#
#  * Mandatory : NO
#  * Default   : FALSE
#
196
# The following CPack variables are specific to source packages, and
197 198
# will not affect binary packages:
#
199
# .. variable:: CPACK_SOURCE_PACKAGE_FILE_NAME
200
#
201
#  The name of the source package. For example cmake-2.6.1.
202
#
203
# .. variable:: CPACK_SOURCE_STRIP_FILES
204
#
205 206 207 208
#  List of files in the source tree that will be stripped. Starting with
#  CMake 2.6.0 CPACK_SOURCE_STRIP_FILES will be a boolean variable which
#  enables stripping of all files (a list of files evaluates to TRUE in
#  CMake, so this change is compatible).
209
#
210
# .. variable:: CPACK_SOURCE_GENERATOR
211
#
212 213 214 215
#  List of generators used for the source packages. As with CPACK_GENERATOR,
#  if this is not specified then CPack will create a set of options (e.g.,
#  CPACK_SOURCE_ZIP) allowing users to select which packages will be
#  generated.
216
#
217
# .. variable:: CPACK_SOURCE_OUTPUT_CONFIG_FILE
218
#
219 220 221
#  The name of the CPack source configuration file. This file is the CPack
#  configuration generated by the CPack module for source
#  installers. Defaults to CPackSourceConfig.cmake.
222
#
223
# .. variable:: CPACK_SOURCE_IGNORE_FILES
224
#
225 226 227 228
#  Pattern of files in the source tree that won't be packaged when building
#  a source package. This is a list of regular expression patterns (that
#  must be properly escaped), e.g.,
#  /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.*
229 230 231
#
# The following variables are for advanced uses of CPack:
#
232
# .. variable:: CPACK_CMAKE_GENERATOR
233
#
234 235 236
#  What CMake generator should be used if the project is CMake
#  project. Defaults to the value of CMAKE_GENERATOR few users will want to
#  change this setting.
237
#
238
# .. variable:: CPACK_INSTALL_CMAKE_PROJECTS
239
#
240 241
#  List of four values that specify what project to install. The four values
#  are: Build directory, Project Name, Project Component, Directory. If
242
#  omitted, CPack will build an installer that installs everything.
243
#
244
# .. variable:: CPACK_SYSTEM_NAME
245
#
246
#  System name, defaults to the value of ${CMAKE_SYSTEM_NAME}.
247
#
248
# .. variable:: CPACK_PACKAGE_VERSION
249
#
250 251 252
#  Package full version, used internally. By default, this is built from
#  CPACK_PACKAGE_VERSION_MAJOR, CPACK_PACKAGE_VERSION_MINOR, and
#  CPACK_PACKAGE_VERSION_PATCH.
253
#
254
# .. variable:: CPACK_TOPLEVEL_TAG
255
#
256
#  Directory for the installed files.
257
#
258
# .. variable:: CPACK_INSTALL_COMMANDS
259
#
260
#  Extra commands to install components.
261
#
262
# .. variable:: CPACK_INSTALLED_DIRECTORIES
263
#
264
#  Extra directories to install.
265
#
266
# .. variable:: CPACK_PACKAGE_INSTALL_REGISTRY_KEY
267
#
268 269 270
#  Registry key used when installing this project. This is only used by
#  installer for Windows.  The default value is based on the installation
#  directory.
271
#
272
# .. variable:: CPACK_CREATE_DESKTOP_LINKS
273
#
274
#  List of desktop links to create.
275 276
#  Each desktop link requires a corresponding start menu shortcut
#  as created by :variable:`CPACK_PACKAGE_EXECUTABLES`.
277

278 279 280 281 282 283 284 285 286 287
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
288
# (To distribute this file outside of CMake, substitute the full
289
#  License text for the above reference.)
290

291
# Define this var in order to avoid (or warn) concerning multiple inclusion
292 293
if(CPack_CMake_INCLUDED)
  message(WARNING "CPack.cmake has already been included!!")
294
else()
295
  set(CPack_CMake_INCLUDED 1)
296
endif()
297

298
# Pick a configuration file
299 300 301
set(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
if(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
  set(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
302
endif()
303 304 305
set(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
if(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
  set(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
306
endif()
307

308 309 310
# Backward compatibility
# Include CPackComponent macros if it has not already been included before.
include(CPackComponent)
311

312
# Macro for setting values if a user did not overwrite them
313
# Mangles CMake-special characters. Only kept for backwards compatibility.
314
macro(cpack_set_if_not_set name value)
315 316
  message(DEPRECATION "cpack_set_if_not_set is obsolete; do not use.")
  _cpack_set_default("${name}" "${value}")
317
endmacro()
318

319
# cpack_encode_variables - Function to encode variables for the configuration file
320
# find any variable that starts with CPACK and create a variable
Bill Hoffman's avatar
Bill Hoffman committed
321 322 323
# _CPACK_OTHER_VARIABLES_ that contains SET commands for
# each cpack variable.  _CPACK_OTHER_VARIABLES_ is then
# used as an @ replacment in configure_file for the CPackConfig.
324 325
function(cpack_encode_variables)
  set(commands "")
326 327
  get_cmake_property(res VARIABLES)
  foreach(var ${res})
328
    if(var MATCHES "^CPACK")
329 330 331 332
      if(CPACK_VERBATIM_VARIABLES)
        _cpack_escape_for_cmake(value "${${var}}")
      else()
        set(value "${${var}}")
333
      endif()
334 335 336

      set(commands "${commands}\nSET(${var} \"${value}\")")
    endif()
337
  endforeach()
338 339 340

  set(_CPACK_OTHER_VARIABLES_ "${commands}" PARENT_SCOPE)
endfunction()
341

342 343 344 345 346 347 348
# Internal use functions
function(_cpack_set_default name value)
  if(NOT DEFINED "${name}")
    set("${name}" "${value}" PARENT_SCOPE)
  endif()
endfunction()

349 350 351 352 353
function(_cpack_escape_for_cmake var value)
  string(REGEX REPLACE "([\\\$\"])" "\\\\\\1" escaped "${value}")
  set("${var}" "${escaped}" PARENT_SCOPE)
endfunction()

354
# Set the package name
355 356 357 358 359
_cpack_set_default(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
_cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0")
_cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1")
_cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1")
_cpack_set_default(CPACK_PACKAGE_VERSION
360
  "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
361 362
_cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity")
_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
363
  "${CMAKE_PROJECT_NAME} built using CMake")
364

365
_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE
Andy Cedilnik's avatar
Andy Cedilnik committed
366
  "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
367
_cpack_set_default(CPACK_RESOURCE_FILE_LICENSE
368
  "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
369
_cpack_set_default(CPACK_RESOURCE_FILE_README
370
  "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
371
_cpack_set_default(CPACK_RESOURCE_FILE_WELCOME
372
  "${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt")
373

374
_cpack_set_default(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
375

376 377
if(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
  set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
378
endif()
379 380 381

if(CPACK_NSIS_MODIFY_PATH)
  set(CPACK_NSIS_MODIFY_PATH ON)
382
endif()
383 384

set(__cpack_system_name ${CMAKE_SYSTEM_NAME})
385 386
if(__cpack_system_name MATCHES "Windows")
  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
387
    set(__cpack_system_name win64)
388
  else()
389
    set(__cpack_system_name win32)
390 391
  endif()
endif()
392
_cpack_set_default(CPACK_SYSTEM_NAME "${__cpack_system_name}")
393

394 395
# Root dir: default value should be the string literal "$PROGRAMFILES"
# for backwards compatibility. Projects may set this value to anything.
396 397 398 399 400 401
# When creating 64 bit binaries we set the default value to "$PROGRAMFILES64"
if("x${__cpack_system_name}" STREQUAL "xwin64")
  set(__cpack_root_default "$PROGRAMFILES64")
else()
  set(__cpack_root_default "$PROGRAMFILES")
endif()
402
_cpack_set_default(CPACK_NSIS_INSTALL_ROOT "${__cpack_root_default}")
403

404
# <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
405
_cpack_set_default(CPACK_PACKAGE_FILE_NAME
406
  "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
407
_cpack_set_default(CPACK_PACKAGE_INSTALL_DIRECTORY
408
  "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
409
_cpack_set_default(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
410
  "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
411 412
_cpack_set_default(CPACK_PACKAGE_DEFAULT_LOCATION "/")
_cpack_set_default(CPACK_PACKAGE_RELOCATABLE "true")
413 414 415 416

# always force to exactly "true" or "false" for CPack.Info.plist.in:
if(CPACK_PACKAGE_RELOCATABLE)
  set(CPACK_PACKAGE_RELOCATABLE "true")
417
else()
418
  set(CPACK_PACKAGE_RELOCATABLE "false")
419
endif()
420

421 422 423
macro(cpack_check_file_exists file description)
  if(NOT EXISTS "${file}")
    message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
424 425
  endif()
endmacro()
426

427 428 429 430
cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description")
cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}"    "license resource")
cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}"     "readme resource")
cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}"    "welcome resource")
431

432 433 434
macro(cpack_optional_append _list _cond _item)
  if(${_cond})
    set(${_list} ${${_list}} ${_item})
435 436
  endif()
endmacro()
437

438 439 440 441 442 443 444 445 446 447
#.rst:
# .. variable:: CPACK_BINARY_<GENNAME>
#
#  CPack generated options for binary generators. The CPack.cmake module
#  generates (when CPACK_GENERATOR is not set) a set of CMake options (see
#  CMake option command) which may then be used to select the CPack
#  generator(s) to be used when launching the package target.
#
#  Provide options to choose generators we might check here if the required
#  tools for the generates exist and set the defaults according to the results
448 449 450
if(NOT CPACK_GENERATOR)
  if(UNIX)
    if(CYGWIN)
451
      option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON)
452
    else()
453
      if(APPLE)
454
        option(CPACK_BINARY_BUNDLE       "Enable to build OSX bundles"      OFF)
455
        option(CPACK_BINARY_DRAGNDROP    "Enable to build OSX Drag And Drop package" OFF)
456
        option(CPACK_BINARY_OSXX11       "Enable to build OSX X11 packages"      OFF)
457
        option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" OFF)
458
      else()
459
        option(CPACK_BINARY_TZ  "Enable to build TZ packages"     ON)
460
      endif()
461 462 463
      option(CPACK_BINARY_DEB  "Enable to build Debian packages"  OFF)
      option(CPACK_BINARY_NSIS "Enable to build NSIS packages"    OFF)
      option(CPACK_BINARY_RPM  "Enable to build RPM packages"     OFF)
464
      option(CPACK_BINARY_STGZ "Enable to build STGZ packages"    ON)
465
      option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages"    OFF)
466
      option(CPACK_BINARY_TGZ  "Enable to build TGZ packages"     ON)
467
      option(CPACK_BINARY_TXZ  "Enable to build TXZ packages"     OFF)
468 469
    endif()
  else()
470
    option(CPACK_BINARY_7Z   "Enable to build 7-Zip packages" OFF)
471
    option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON)
472
    option(CPACK_BINARY_WIX  "Enable to build WiX packages" OFF)
473
    option(CPACK_BINARY_ZIP  "Enable to build ZIP packages" OFF)
474
  endif()
475
  option(CPACK_BINARY_IFW "Enable to build IFW packages" OFF)
476

477
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_7Z           7Z)
478
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_BUNDLE       Bundle)
479 480
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_CYGWIN       CygwinBinary)
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_DEB          DEB)
481 482
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_DRAGNDROP    DragNDrop)
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_IFW          IFW)
483
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_NSIS         NSIS)
484 485 486
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_OSXX11       OSXX11)
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_PACKAGEMAKER PackageMaker)
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_RPM          RPM)
487 488
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_STGZ         STGZ)
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_TBZ2         TBZ2)
489
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_TGZ          TGZ)
490
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_TXZ          TXZ)
491
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_TZ           TZ)
492
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_WIX          WIX)
493
  cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_ZIP          ZIP)
494

495
endif()
496 497 498 499 500 501

# Provide options to choose source generators
if(NOT CPACK_SOURCE_GENERATOR)
  if(UNIX)
    if(CYGWIN)
      option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
502
    else()
503 504
      option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
      option(CPACK_SOURCE_TGZ  "Enable to build TGZ source packages"  ON)
505
      option(CPACK_SOURCE_TXZ  "Enable to build TXZ source packages"  ON)
506 507
      option(CPACK_SOURCE_TZ   "Enable to build TZ source packages"   ON)
      option(CPACK_SOURCE_ZIP  "Enable to build ZIP source packages"  OFF)
508 509
    endif()
  else()
510
    option(CPACK_SOURCE_7Z  "Enable to build 7-Zip source packages" ON)
511
    option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
512
  endif()
513

514
  cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_7Z      7Z)
515 516
  cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_CYGWIN  CygwinSource)
  cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_TBZ2    TBZ2)
517
  cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_TGZ     TGZ)
518
  cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_TXZ     TXZ)
519 520
  cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_TZ      TZ)
  cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_ZIP     ZIP)
521
endif()
522

523
# mark the above options as advanced
524
mark_as_advanced(
525 526
  CPACK_BINARY_7Z
  CPACK_BINARY_BUNDLE
527
  CPACK_BINARY_CYGWIN
528 529 530 531
  CPACK_BINARY_DEB
  CPACK_BINARY_DRAGNDROP
  CPACK_BINARY_IFW
  CPACK_BINARY_NSIS
532
  CPACK_BINARY_OSXX11
533 534
  CPACK_BINARY_PACKAGEMAKER
  CPACK_BINARY_RPM
535 536
  CPACK_BINARY_STGZ
  CPACK_BINARY_TBZ2
537
  CPACK_BINARY_TGZ
538
  CPACK_BINARY_TXZ
539
  CPACK_BINARY_TZ
540 541
  CPACK_BINARY_WIX
  CPACK_BINARY_ZIP
542
  CPACK_SOURCE_7Z
543 544 545 546 547 548 549
  CPACK_SOURCE_CYGWIN
  CPACK_SOURCE_TBZ2
  CPACK_SOURCE_TGZ
  CPACK_SOURCE_TXZ
  CPACK_SOURCE_TZ
  CPACK_SOURCE_ZIP
  )
550

551
# Set some other variables
552
_cpack_set_default(CPACK_INSTALL_CMAKE_PROJECTS
553
  "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
554 555
_cpack_set_default(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
_cpack_set_default(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
556 557
# if the user has set CPACK_NSIS_DISPLAY_NAME remember it
if(DEFINED CPACK_NSIS_DISPLAY_NAME)
558
  set(CPACK_NSIS_DISPLAY_NAME_SET TRUE)
559 560 561 562
endif()
# if the user has set CPACK_NSIS_DISPLAY
# explicitly, then use that as the default
# value of CPACK_NSIS_PACKAGE_NAME  instead
563
# of CPACK_PACKAGE_INSTALL_DIRECTORY
564
_cpack_set_default(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
565 566

if(CPACK_NSIS_DISPLAY_NAME_SET)
567
  _cpack_set_default(CPACK_NSIS_PACKAGE_NAME "${CPACK_NSIS_DISPLAY_NAME}")
568
else()
569
  _cpack_set_default(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
570
endif()
571

572
_cpack_set_default(CPACK_OUTPUT_CONFIG_FILE
573 574
  "${CMAKE_BINARY_DIR}/CPackConfig.cmake")

575
_cpack_set_default(CPACK_SOURCE_OUTPUT_CONFIG_FILE
576 577
  "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")

578 579
_cpack_set_default(CPACK_SET_DESTDIR OFF)
_cpack_set_default(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
580

581 582
_cpack_set_default(CPACK_NSIS_INSTALLER_ICON_CODE "")
_cpack_set_default(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
583

584
# WiX specific variables
585
_cpack_set_default(CPACK_WIX_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
586

587
# set sysroot so SDK tools can be used
588
if(CMAKE_OSX_SYSROOT)
589
  _cpack_set_default(CPACK_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
590 591
endif()

592 593 594 595
if(DEFINED CPACK_COMPONENTS_ALL)
  if(CPACK_MONOLITHIC_INSTALL)
    message("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.")
    set(CPACK_COMPONENTS_ALL)
596
  else()
597 598
    # The user has provided the set of components to be installed as
    # part of a component-based installation; trust her.
599
    set(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE)
600 601
  endif()
else()
602 603 604
  # If the user has not specifically requested a monolithic installer
  # but has specified components in various "install" commands, tell
  # CPack about those components.
605 606 607 608
  if(NOT CPACK_MONOLITHIC_INSTALL)
    get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
    list(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN)
    if(CPACK_COMPONENTS_LEN EQUAL 1)
609 610 611
      # Only one component: this is not a component-based installation
      # (at least, it isn't a component-based installation, but may
      # become one later if the user uses the cpack_add_* commands).
612
      set(CPACK_COMPONENTS_ALL)
613
    endif()
614
    set(CPACK_COMPONENTS_LEN)
615 616
  endif()
endif()
617 618 619 620 621 622 623 624

# CMake always generates a component named "Unspecified", which is
# used to install everything that doesn't have an explicitly-provided
# component. Since these files should always be installed, we'll make
# them hidden and required.
set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE)
set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE)

Bill Hoffman's avatar
Bill Hoffman committed
625
cpack_encode_variables()
626
configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY)
627

628
# Generate source file
629
_cpack_set_default(CPACK_SOURCE_INSTALLED_DIRECTORIES
630
  "${CMAKE_SOURCE_DIR};/")
631 632
_cpack_set_default(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-Source")
_cpack_set_default(CPACK_SOURCE_PACKAGE_FILE_NAME
633
  "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
634 635 636 637 638 639 640 641 642

set(__cpack_source_ignore_files_default
  "/CVS/;/\\.svn/;/\\.bzr/;/\\.hg/;/\\.git/;\\.swp$;\\.#;/#")
if(NOT CPACK_VERBATIM_VARIABLES)
  _cpack_escape_for_cmake(__cpack_source_ignore_files_default
    "${__cpack_source_ignore_files_default}")
endif()
_cpack_set_default(CPACK_SOURCE_IGNORE_FILES "${__cpack_source_ignore_files_default}")

643 644 645 646 647 648 649
set(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
set(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
set(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
set(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
set(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
set(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
650

651
cpack_encode_variables()
652
configure_file("${cpack_source_input_file}"
653
  "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY)