1 # - Build binary and source package installers
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).
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. The contents of each of the components are identified by
15 # the COMPONENT argument of CMake's INSTALL command. These components
16 # can be annotated with user-friendly names and descriptions,
17 # inter-component dependencies, etc., and grouped in various ways to
18 # customize the resulting installer. See the cpack_add_* commands,
19 # described below, for more information about component-specific
22 # Before including the CPack module, there are a variety of variables
23 # that can be set to customize the resulting installers. The most
24 # commonly-used variables are:
26 # CPACK_PACKAGE_NAME - The name of the package (or application). If
27 # not specified, defaults to the project name.
29 # CPACK_PACKAGE_VENDOR - The name of the package vendor (e.g.,
32 # CPACK_PACKAGE_VERSION_MAJOR - Package major Version
34 # CPACK_PACKAGE_VERSION_MINOR - Package minor Version
36 # CPACK_PACKAGE_VERSION_PATCH - Package patch Version
38 # CPACK_PACKAGE_DESCRIPTION_FILE - A text file used to describe the
39 # project. Used, for example, the introduction screen of a
40 # CPack-generated Windows installer to describe the project.
42 # CPACK_PACKAGE_DESCRIPTION_SUMMARY - Short description of the
43 # project (only a few words).
45 # CPACK_PACKAGE_FILE_NAME - The name of the package file to generate,
46 # not including the extension. For example, cmake-2.6.1-Linux-i686.
48 # CPACK_PACKAGE_INSTALL_DIRECTORY - Installation directory on the
49 # target system, e.g., "CMake 2.5".
51 # CPACK_RESOURCE_FILE_LICENSE - License file for the project, which
52 # will typically be displayed to the user (often with an explicit
53 # "Accept" button, for graphical installers) prior to installation.
55 # CPACK_RESOURCE_FILE_README - ReadMe file for the project, which
56 # typically describes in some detail
58 # CPACK_RESOURCE_FILE_WELCOME - Welcome file for the project, which
59 # welcomes users to this installer. Typically used in the graphical
60 # installers on Windows and Mac OS X.
62 # CPACK_MONOLITHIC_INSTALL - Disables the component-based
63 # installation mechanism, so that all components are always installed.
65 # CPACK_GENERATOR - List of CPack generators to use. If not
66 # specified, CPack will create a set of options (e.g.,
67 # CPACK_BINARY_NSIS) allowing the user to enable/disable individual
70 # CPACK_OUTPUT_CONFIG_FILE - The name of the CPack configuration file
71 # for binary installers that will be generated by the CPack
72 # module. Defaults to CPackConfig.cmake.
74 # CPACK_PACKAGE_EXECUTABLES - Lists each of the executables along
75 # with a text label, to be used to create Start Menu shortcuts on
76 # Windows. For example, setting this to the list ccmake;CMake will
77 # create a shortcut named "CMake" that will execute the installed
80 # CPACK_STRIP_FILES - List of files to be stripped. Starting with
81 # CMake 2.6.0 CPACK_STRIP_FILES will be a boolean variable which
82 # enables stripping of all files (a list of files evaluates to TRUE
83 # in CMake, so this change is compatible).
85 # The following CPack variables are specific to source packages, and
86 # will not affect binary packages:
88 # CPACK_SOURCE_PACKAGE_FILE_NAME - The name of the source package,
91 # CPACK_SOURCE_STRIP_FILES - List of files in the source tree that
92 # will be stripped. Starting with CMake 2.6.0
93 # CPACK_SOURCE_STRIP_FILES will be a boolean variable which enables
94 # stripping of all files (a list of files evaluates to TRUE in CMake,
95 # so this change is compatible).
97 # CPACK_SOURCE_GENERATOR - List of generators used for the source
98 # packages. As with CPACK_GENERATOR, if this is not specified then
99 # CPack will create a set of options (e.g., CPACK_SOURCE_ZIP)
100 # allowing users to select which packages will be generated.
102 # CPACK_SOURCE_OUTPUT_CONFIG_FILE - The name of the CPack
103 # configuration file for source installers that will be generated by
104 # the CPack module. Defaults to CPackSourceConfig.cmake.
106 # CPACK_SOURCE_IGNORE_FILES - Pattern of files in the source tree
107 # that won't be packaged when building a source package. This is a
108 # list of patterns, e.g., /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.*
110 # The following variables are specific to the graphical installers built
111 # on Windows using the Nullsoft Installation System.
113 # CPACK_PACKAGE_INSTALL_REGISTRY_KEY - Registry key used when
114 # installing this project.
116 # CPACK_NSIS_MUI_ICON - The icon file (.ico) for the generated
119 # CPACK_NSIS_MUI_UNIICON - The icon file (.ico) for the generated
122 # CPACK_PACKAGE_ICON - A branding image that will be displayed inside
125 # CPACK_NSIS_EXTRA_INSTALL_COMMANDS - Extra NSIS commands that will
126 # be added to the install Section.
128 # CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS - Extra NSIS commands that will
129 # be added to the uninstall Section.
131 # CPACK_NSIS_COMPRESSOR - The arguments that will be passed to the
132 # NSIS SetCompressor command.
134 # CPACK_NSIS_MODIFY_PATH - If this is set to "ON", then an extra page
135 # will appear in the installer that will allow the user to choose
136 # whether the program directory should be added to the system PATH
139 # CPACK_NSIS_DISPLAY_NAME - The title displayed at the top of the
142 # CPACK_NSIS_INSTALLED_ICON_NAME - A path to the executable that
143 # contains the installer icon.
145 # CPACK_NSIS_HELP_LINK - URL to a web site providing assistance in
146 # installing your application.
148 # CPACK_NSIS_URL_INFO_ABOUT - URL to a web site providing more
149 # information about your application.
151 # CPACK_NSIS_CONTACT - Contact information for questions and comments
152 # about the installation process.
154 # CPACK_NSIS_CREATE_ICONS_EXTRA - Additional NSIS commands for
155 # creating start menu shortcuts.
157 # CPACK_NSIS_DELETE_ICONS_EXTRA -Additional NSIS commands to
158 # uninstall start menu shortcuts.
160 # The following variable is specific to installers build on Mac OS X
161 # using PackageMaker:
163 # CPACK_OSX_PACKAGE_VERSION - The version of Mac OS X that the
164 # resulting PackageMaker archive should be compatible
165 # with. Different versions of Mac OS X support different
166 # features. For example, CPack can only build component-based
167 # installers for Mac OS X 10.4 or newer, and can only build
168 # installers that download component son-the-fly for Mac OS X 10.5
169 # or newer. If left blank, this value will be set to the minimum
170 # version of Mac OS X that supports the requested features. Set this
171 # variable to some value (e.g., 10.4) only if you want to guarantee
172 # that your installer will work on that version of Mac OS X, and
173 # don't mind missing extra features available in the installer
174 # shipping with later versions of Mac OS X.
176 # The following variables are for advanced uses of CPack:
178 # CPACK_CMAKE_GENERATOR - What CMake generator should be used if the
179 # project is CMake project. Defaults to the value of CMAKE_GENERATOR;
180 # few users will want to change this setting.
182 # CPACK_INSTALL_CMAKE_PROJECTS - List of four values that specify
183 # what project to install. The four values are: Build directory,
184 # Project Name, Project Component, Directory. If omitted, CPack will
185 # build an installer that installers everything.
187 # CPACK_SYSTEM_NAME - System name, defaults to the value of
188 # ${CMAKE_SYSTEM_NAME}.
190 # CPACK_PACKAGE_VERSION - Package full version, used internally. By
191 # default, this is built from CPACK_PACKAGE_VERSION_MAJOR,
192 # CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH.
194 # CPACK_TOPLEVEL_TAG - Directory for the installed files.
196 # CPACK_INSTALL_COMMANDS - Extra commands to install components.
198 # CPACK_INSTALL_DIRECTORIES - Extra directories to install.
200 # Component-specific installation allows users to select specific sets
201 # of components to install during the install process. Installation
202 # components are identified by the COMPONENT argument of CMake's
203 # INSTALL commands, and should be further described by the following
206 # cpack_add_component - Describes a CPack installation component
207 # named by the COMPONENT argument to a CMake INSTALL command.
209 # cpack_add_component(compname
210 # [DISPLAY_NAME name]
211 # [DESCRIPTION description]
212 # [HIDDEN | REQUIRED | DISABLED ]
214 # [DEPENDS comp1 comp2 ... ]
215 # [INSTALL_TYPES type1 type2 ... ]
217 # [ARCHIVE_FILE filename])
219 # The cmake_add_component command describes an installation
220 # component, which the user can opt to install or remove as part of
221 # the graphical installation process. compname is the name of the
222 # component, as provided to the COMPONENT argument of one or more
223 # CMake INSTALL commands.
225 # DISPLAY_NAME is the displayed name of the component, used in
226 # graphical installers to display the component name. This value can
229 # DESCRIPTION is an extended description of the component, used in
230 # graphical installers to give the user additional information about
231 # the component. Descriptions can span multiple lines using "\n" as
232 # the line separator. Typically, these descriptions should be no
233 # more than a few lines long.
235 # HIDDEN indicates that this component will be hidden in the
236 # graphical installer, so that the user cannot directly change
237 # whether it is installed or not.
239 # REQUIRED indicates that this component is required, and therefore
240 # will always be installed. It will be visible in the graphical
241 # installer, but it cannot be unselected. (Typically, required
242 # components are shown greyed out).
244 # DISABLED indicates that this component should be disabled
245 # (unselected) by default. The user is free to select this component
246 # for installation, unless it is also HIDDEN.
248 # DEPENDS lists the components on which this component depends. If
249 # this component is selected, then each of the components listed
250 # must also be selected. The dependency information is encoded
251 # within the installer itself, so that users cannot install
252 # inconsitent sets of components.
254 # GROUP names the component group of which this component is a
255 # part. If not provided, the component will be a standalone
256 # component, not part of any component group. Component groups are
257 # described with the cpack_add_component_group command, detailed
260 # INSTALL_TYPES lists the installation types of which this component
261 # is a part. When one of these installations types is selected, this
262 # component will automatically be selected. Installation types are
263 # described with the cpack_add_install_type command, detailed below.
265 # DOWNLOADED indicates that this component should be downloaded
266 # on-the-fly by the installer, rather than packaged in with the
267 # installer itself. For more information, see the cpack_configure_downloads
270 # ARCHIVE_FILE provides a name for the archive file created by CPack
271 # to be used for downloaded components. If not supplied, CPack will
272 # create a file with some name based on CPACK_PACKAGE_FILE_NAME and
273 # the name of the component. See cpack_configure_downloads for more
276 # cpack_add_component_group - Describes a group of related CPack
277 # installation components.
279 # cpack_add_component_group(groupname
280 # [DISPLAY_NAME name]
281 # [DESCRIPTION description]
282 # [PARENT_GROUP parent]
286 # The cpack_add_component_group describes a group of installation
287 # components, which will be placed together within the listing of
288 # options. Typically, component groups allow the user to
289 # select/deselect all of the components within a single group via a
290 # single group-level option. Use component groups to reduce the
291 # complexity of installers with many options. groupname is an
292 # arbitrary name used to identify the group in the GROUP argument of
293 # the cpack_add_component command, which is used to place a
294 # component in a group. The name of the group must not conflict with
295 # the name of any component.
297 # DISPLAY_NAME is the displayed name of the component group, used in
298 # graphical installers to display the component group name. This
299 # value can be any string.
301 # DESCRIPTION is an extended description of the component group,
302 # used in graphical installers to give the user additional
303 # information about the components within that group. Descriptions
304 # can span multiple lines using "\n" as the line
305 # separator. Typically, these descriptions should be no more than a
308 # PARENT_GROUP, if supplied, names the parent group of this group.
309 # Parent groups are used to establish a hierarchy of groups,
310 # providing an arbitrary hierarchy of groups.
312 # EXPANDED indicates that, by default, the group should show up as
313 # "expanded", so that the user immediately sees all of the
314 # components within the group. Otherwise, the group will initially
315 # show up as a single entry.
317 # BOLD_TITLE indicates that the group title should appear in bold,
318 # to call the user's attention to the group.
320 # cpack_add_install_type - Add a new installation type containing a
321 # set of predefined component selections to the graphical installer.
323 # cpack_add_install_type(typename
324 # [DISPLAY_NAME name])
326 # The cpack_add_install_type command identifies a set of preselected
327 # components that represents a common use case for an
328 # application. For example, a "Developer" install type might include
329 # an application along with its header and library files, while an
330 # "End user" install type might just include the application's
331 # executable. Each component identifies itself with one or more
332 # install types via the INSTALL_TYPES argument to
333 # cpack_add_component.
335 # DISPLAY_NAME is the displayed name of the install type, which will
336 # typically show up in a drop-down box within a graphical
337 # installer. This value can be any string.
339 # cpack_configure_downloads - Configure CPack to download selected
340 # components on-the-fly as part of the installation process.
342 # cpack_configure_downloads(site
343 # [UPLOAD_DIRECTORY dirname]
345 # [ADD_REMOVE|NO_ADD_REMOVE])
347 # The cpack_configure_downloads command configures installation-time
348 # downloads of selected components. For each downloadable component,
349 # CPack will create an archive containing the contents of that
350 # component, which should be uploaded to the given site. When the
351 # user selects that component for installation, the installer will
352 # download and extract the component in place. This feature is
353 # useful for creating small installers that only download the
354 # requested components, saving bandwidth. Additionally, the
355 # installers are small enough that they will be installed as part of
356 # the normal installation process, and the "Change" button in
357 # Windows Add/Remove Programs control panel will allow one to add or
358 # remove parts of the application after the original
359 # installation. On Windows, the downloaded-components functionality
360 # requires the ZipDLL plug-in for NSIS, available at:
362 # http://nsis.sourceforge.net/ZipDLL_plug-in
364 # On Mac OS X, installers that download components on-the-fly can
365 # only be built and installed on system using Mac OS X 10.5 or
368 # The site argument is a URL where the archives for downloadable
369 # components will reside, e.g., http://www.cmake.org/files/2.6.1/installer/
370 # All of the archives produced by CPack should be uploaded to that location.
372 # UPLOAD_DIRECTORY is the local directory where CPack will create the
373 # various archives for each of the components. The contents of this
374 # directory should be uploaded to a location accessible by the URL given
375 # in the site argument. If omitted, CPack will use the directory CPackUploads
376 # inside the CMake binary directory to store the generated archives.
378 # The ALL flag indicates that all components be downloaded. Otherwise, only
379 # those components explicitly marked as DOWNLOADED or that have a specified
380 # ARCHIVE_FILE will be downloaded. Additionally, the ALL option implies
381 # ADD_REMOVE (unless NO_ADD_REMOVE is specified).
383 # ADD_REMOVE indicates that CPack should install a copy of the installer
384 # that can be called from Windows' Add/Remove Programs dialog (via the
385 # "Modify" button) to change the set of installed components. NO_ADD_REMOVE
386 # turns off this behavior. This option is ignored on Mac OS X.
389 # Pick a configuration file
390 SET(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
391 IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
392 SET(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
393 ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
394 SET(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
395 IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
396 SET(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
397 ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
399 # Argument-parsing macro from http://www.cmake.org/Wiki/CMakeMacroParseArguments
400 MACRO(cpack_parse_arguments prefix arg_names option_names)
401 SET(${prefix}_DEFAULT_ARGS)
402 FOREACH(arg_name ${arg_names})
403 SET(${prefix}_${arg_name})
405 FOREACH(option ${option_names})
406 SET(${prefix}_${option} FALSE)
409 SET(current_arg_name DEFAULT_ARGS)
410 SET(current_arg_list)
412 SET(larg_names ${arg_names})
413 LIST(FIND larg_names "${arg}" is_arg_name)
414 IF (is_arg_name GREATER -1)
415 SET(${prefix}_${current_arg_name} ${current_arg_list})
416 SET(current_arg_name ${arg})
417 SET(current_arg_list)
418 ELSE (is_arg_name GREATER -1)
419 SET(loption_names ${option_names})
420 LIST(FIND loption_names "${arg}" is_option)
421 IF (is_option GREATER -1)
422 SET(${prefix}_${arg} TRUE)
423 ELSE (is_option GREATER -1)
424 SET(current_arg_list ${current_arg_list} ${arg})
425 ENDIF (is_option GREATER -1)
426 ENDIF (is_arg_name GREATER -1)
428 SET(${prefix}_${current_arg_name} ${current_arg_list})
429 ENDMACRO(cpack_parse_arguments)
431 # Macro that appends a SET command for the given variable name (var)
432 # to the macro named strvar, but only if the variable named "var"
433 # has been defined. The string will eventually be appended to a CPack
434 # configuration file.
435 MACRO(cpack_append_variable_set_command var strvar)
437 SET(${strvar} "${${strvar}}SET(${var}")
438 FOREACH(APPENDVAL ${${var}})
439 SET(${strvar} "${${strvar}} ${APPENDVAL}")
440 ENDFOREACH(APPENDVAL)
441 SET(${strvar} "${${strvar}})\n")
442 ENDIF (DEFINED ${var})
443 ENDMACRO(cpack_append_variable_set_command)
445 # Macro that appends a SET command for the given variable name (var)
446 # to the macro named strvar, but only if the variable named "var"
447 # has been defined and is a string. The string will eventually be
448 # appended to a CPack configuration file.
449 MACRO(cpack_append_string_variable_set_command var strvar)
451 LIST(LENGTH ${var} CPACK_APP_VALUE_LEN)
452 IF(${CPACK_APP_VALUE_LEN} EQUAL 1)
453 SET(${strvar} "${${strvar}}SET(${var} \"${${var}}\")\n")
454 ENDIF(${CPACK_APP_VALUE_LEN} EQUAL 1)
455 ENDIF (DEFINED ${var})
456 ENDMACRO(cpack_append_string_variable_set_command)
458 # Macro that appends a SET command for the given variable name (var)
459 # to the macro named strvar, but only if the variable named "var"
460 # has been set to true. The string will eventually be
461 # appended to a CPack configuration file.
462 MACRO(cpack_append_option_set_command var strvar)
464 LIST(LENGTH ${var} CPACK_APP_VALUE_LEN)
465 IF(${CPACK_APP_VALUE_LEN} EQUAL 1)
466 SET(${strvar} "${${strvar}}SET(${var} TRUE)\n")
467 ENDIF(${CPACK_APP_VALUE_LEN} EQUAL 1)
469 ENDMACRO(cpack_append_option_set_command)
471 # Macro that adds a component to the CPack installer
472 MACRO(cpack_add_component compname)
473 STRING(TOUPPER ${compname} CPACK_ADDCOMP_UNAME)
474 cpack_parse_arguments(CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}
475 "DISPLAY_NAME;DESCRIPTION;GROUP;DEPENDS;INSTALL_TYPES;ARCHIVE_FILE"
476 "HIDDEN;REQUIRED;DISABLED;DOWNLOADED"
480 if (CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED)
481 SET(CPACK_ADDCOMP_STR "\n# Configuration for downloaded component \"${compname}\"\n")
483 SET(CPACK_ADDCOMP_STR "\n# Configuration for component \"${compname}\"\n")
486 IF(NOT CPACK_MONOLITHIC_INSTALL)
487 # If the user didn't set CPACK_COMPONENTS_ALL explicitly, update the
488 # value of CPACK_COMPONENTS_ALL in the configuration file. This will
489 # take care of any components that have been added after the CPack
490 # moduled was included.
491 IF(NOT CPACK_COMPONENTS_ALL_SET_BY_USER)
492 GET_CMAKE_PROPERTY(CPACK_ADDCOMP_COMPONENTS COMPONENTS)
493 SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR}\nSET(CPACK_COMPONENTS_ALL")
494 FOREACH(COMP ${CPACK_ADDCOMP_COMPONENTS})
495 SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR} ${COMP}")
497 SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR})\n")
498 ENDIF(NOT CPACK_COMPONENTS_ALL_SET_BY_USER)
499 ENDIF(NOT CPACK_MONOLITHIC_INSTALL)
501 cpack_append_string_variable_set_command(
502 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISPLAY_NAME
504 cpack_append_string_variable_set_command(
505 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DESCRIPTION
507 cpack_append_variable_set_command(
508 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_GROUP
510 cpack_append_variable_set_command(
511 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DEPENDS
513 cpack_append_variable_set_command(
514 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_INSTALL_TYPES
516 cpack_append_string_variable_set_command(
517 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_ARCHIVE_FILE
519 cpack_append_option_set_command(
520 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_HIDDEN
522 cpack_append_option_set_command(
523 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_REQUIRED
525 cpack_append_option_set_command(
526 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISABLED
528 cpack_append_option_set_command(
529 CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED
531 FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDCOMP_STR}")
532 ENDMACRO(cpack_add_component)
534 # Macro that adds a component group to the CPack installer
535 MACRO(cpack_add_component_group grpname)
536 STRING(TOUPPER ${grpname} CPACK_ADDGRP_UNAME)
537 cpack_parse_arguments(CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}
538 "DISPLAY_NAME;DESCRIPTION"
539 "EXPANDED;BOLD_TITLE"
543 SET(CPACK_ADDGRP_STR "\n# Configuration for component group \"${grpname}\"\n")
544 cpack_append_string_variable_set_command(
545 CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DISPLAY_NAME
547 cpack_append_string_variable_set_command(
548 CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DESCRIPTION
550 cpack_append_option_set_command(
551 CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_EXPANDED
553 cpack_append_option_set_command(
554 CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_BOLD_TITLE
556 FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDGRP_STR}")
557 ENDMACRO(cpack_add_component_group)
559 # Macro that adds an installation type to the CPack installer
560 MACRO(cpack_add_install_type insttype)
561 STRING(TOUPPER ${insttype} CPACK_INSTTYPE_UNAME)
562 cpack_parse_arguments(CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME}
568 SET(CPACK_INSTTYPE_STR
569 "\n# Configuration for installation type \"${insttype}\"\n")
570 SET(CPACK_INSTTYPE_STR
571 "${CPACK_INSTTYPE_STR}LIST(APPEND CPACK_ALL_INSTALL_TYPES ${insttype})\n")
572 cpack_append_string_variable_set_command(
573 CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME}_DISPLAY_NAME
575 FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_INSTTYPE_STR}")
576 ENDMACRO(cpack_add_install_type)
578 MACRO(cpack_configure_downloads site)
579 cpack_parse_arguments(CPACK_DOWNLOAD
581 "ALL;ADD_REMOVE;NO_ADD_REMOVE"
585 SET(CPACK_CONFIG_DL_STR
586 "\n# Downloaded components configuration\n")
587 SET(CPACK_UPLOAD_DIRECTORY ${CPACK_DOWNLOAD_UPLOAD_DIRECTORY})
588 SET(CPACK_DOWNLOAD_SITE ${site})
589 cpack_append_string_variable_set_command(
592 cpack_append_string_variable_set_command(
593 CPACK_UPLOAD_DIRECTORY
595 cpack_append_option_set_command(
598 IF (${CPACK_DOWNLOAD_ALL} AND NOT ${CPACK_DOWNLOAD_NO_ADD_REMOVE})
599 SET(CPACK_DOWNLOAD_ADD_REMOVE ON)
600 ENDIF (${CPACK_DOWNLOAD_ALL} AND NOT ${CPACK_DOWNLOAD_NO_ADD_REMOVE})
601 SET(CPACK_ADD_REMOVE ${CPACK_DOWNLOAD_ADD_REMOVE})
602 cpack_append_option_set_command(
605 FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_CONFIG_DL_STR}")
606 ENDMACRO(cpack_configure_downloads)
608 # Macro for setting values if a user did not overwrite them
609 MACRO(cpack_set_if_not_set name value)
610 IF(NOT DEFINED "${name}")
611 SET(${name} "${value}")
612 ENDIF(NOT DEFINED "${name}")
613 ENDMACRO(cpack_set_if_not_set)
615 # Macro to encode variables for the configuration file
616 # find any varable that stars with CPACK and create a variable
617 # _CPACK_OTHER_VARIABLES_ that contains SET commands for
618 # each cpack variable. _CPACK_OTHER_VARIABLES_ is then
619 # used as an @ replacment in configure_file for the CPackConfig.
620 MACRO(cpack_encode_variables)
621 SET(_CPACK_OTHER_VARIABLES_)
622 GET_CMAKE_PROPERTY(res VARIABLES)
624 IF("xxx${var}" MATCHES "xxxCPACK")
625 SET(_CPACK_OTHER_VARIABLES_
626 "${_CPACK_OTHER_VARIABLES_}\nSET(${var} \"${${var}}\")")
627 ENDIF("xxx${var}" MATCHES "xxxCPACK")
628 ENDFOREACH(var ${res})
629 ENDMACRO(cpack_encode_variables)
631 # Set the package name
632 cpack_set_if_not_set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
633 cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MAJOR "0")
634 cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MINOR "1")
635 cpack_set_if_not_set(CPACK_PACKAGE_VERSION_PATCH "1")
636 cpack_set_if_not_set(CPACK_PACKAGE_VERSION
637 "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
638 cpack_set_if_not_set(CPACK_PACKAGE_VENDOR "Humanity")
639 cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
640 "${CMAKE_PROJECT_NAME} built using CMake")
642 cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_FILE
643 "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
644 cpack_set_if_not_set(CPACK_RESOURCE_FILE_LICENSE
645 "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
646 cpack_set_if_not_set(CPACK_RESOURCE_FILE_README
647 "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
648 cpack_set_if_not_set(CPACK_RESOURCE_FILE_WELCOME
649 "${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt")
651 cpack_set_if_not_set(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
653 IF(CPACK_NSIS_MODIFY_PATH)
654 SET(CPACK_NSIS_MODIFY_PATH ON)
655 ENDIF(CPACK_NSIS_MODIFY_PATH)
657 SET(__cpack_system_name ${CMAKE_SYSTEM_NAME})
658 IF(${__cpack_system_name} MATCHES Windows)
660 SET(__cpack_system_name win64)
662 SET(__cpack_system_name win32)
664 ENDIF(${__cpack_system_name} MATCHES Windows)
665 cpack_set_if_not_set(CPACK_SYSTEM_NAME "${__cpack_system_name}")
667 # <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
668 cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME
669 "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
670 cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY
671 "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
672 cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
673 "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
674 cpack_set_if_not_set(CPACK_PACKAGE_DEFAULT_LOCATION "/")
675 cpack_set_if_not_set(CPACK_PACKAGE_RELOCATABLE "true")
677 # always force to exactly "true" or "false" for CPack.Info.plist.in:
678 if(CPACK_PACKAGE_RELOCATABLE)
679 set(CPACK_PACKAGE_RELOCATABLE "true")
680 else(CPACK_PACKAGE_RELOCATABLE)
681 set(CPACK_PACKAGE_RELOCATABLE "false")
682 endif(CPACK_PACKAGE_RELOCATABLE)
684 macro(cpack_check_file_exists file description)
685 if(NOT EXISTS "${file}")
686 message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
687 endif(NOT EXISTS "${file}")
688 endmacro(cpack_check_file_exists)
690 cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description")
691 cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}" "license resource")
692 cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}" "readme resource")
693 cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}" "welcome resource")
695 macro(cpack_optional_append _list _cond _item)
697 set(${_list} ${${_list}} ${_item})
699 endmacro(cpack_optional_append _list _cond _item)
701 # Provide options to choose generators
702 # we might check here if the required tools for the generates exist
703 # and set the defaults according to the results
704 if(NOT CPACK_GENERATOR)
707 option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON)
710 option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF)
711 option(CPACK_BINARY_DRAGNDROP "Enable to build OSX Drag And Drop package" OFF)
712 option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" ON)
713 option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF)
715 option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
717 option(CPACK_BINARY_STGZ "Enable to build STGZ packages" ON)
718 option(CPACK_BINARY_TGZ "Enable to build TGZ packages" ON)
719 option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages" OFF)
720 option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF)
721 option(CPACK_BINARY_RPM "Enable to build RPM packages" OFF)
722 option(CPACK_BINARY_NSIS "Enable to build NSIS packages" OFF)
725 option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON)
726 option(CPACK_BINARY_ZIP "Enable to build ZIP packages" OFF)
729 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle)
730 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DRAGNDROP DragNDrop)
731 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker)
732 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11)
733 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary)
734 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DEB DEB)
735 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_RPM RPM)
736 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_NSIS NSIS)
737 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_STGZ STGZ)
738 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TGZ TGZ)
739 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TBZ2 TBZ2)
740 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_TZ TZ)
741 cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_ZIP ZIP)
743 endif(NOT CPACK_GENERATOR)
745 # Provide options to choose source generators
746 if(NOT CPACK_SOURCE_GENERATOR)
749 option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
751 option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
752 option(CPACK_SOURCE_TGZ "Enable to build TGZ source packages" ON)
753 option(CPACK_SOURCE_TZ "Enable to build TZ source packages" ON)
754 option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" OFF)
757 option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
760 cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_CYGWIN CygwinSource)
761 cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TGZ TGZ)
762 cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TBZ2 TBZ2)
763 cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_TZ TZ)
764 cpack_optional_append(CPACK_SOURCE_GENERATOR CPACK_SOURCE_ZIP ZIP)
765 endif(NOT CPACK_SOURCE_GENERATOR)
767 # mark the above options as advanced
768 mark_as_advanced(CPACK_BINARY_CYGWIN CPACK_BINARY_PACKAGEMAKER CPACK_BINARY_OSXX11
769 CPACK_BINARY_STGZ CPACK_BINARY_TGZ CPACK_BINARY_TBZ2
770 CPACK_BINARY_DEB CPACK_BINARY_RPM CPACK_BINARY_TZ
771 CPACK_BINARY_NSIS CPACK_BINARY_ZIP CPACK_BINARY_BUNDLE
772 CPACK_SOURCE_CYGWIN CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ
773 CPACK_SOURCE_TZ CPACK_SOURCE_ZIP CPACK_BINARY_DRAGNDROP)
775 # Set some other variables
776 cpack_set_if_not_set(CPACK_INSTALL_CMAKE_PROJECTS
777 "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
778 cpack_set_if_not_set(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
779 cpack_set_if_not_set(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
781 cpack_set_if_not_set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
783 cpack_set_if_not_set(CPACK_OUTPUT_CONFIG_FILE
784 "${CMAKE_BINARY_DIR}/CPackConfig.cmake")
786 cpack_set_if_not_set(CPACK_SOURCE_OUTPUT_CONFIG_FILE
787 "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")
789 cpack_set_if_not_set(CPACK_SET_DESTDIR OFF)
790 cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
792 cpack_set_if_not_set(CPACK_NSIS_INSTALLER_ICON_CODE "")
793 cpack_set_if_not_set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
795 IF(DEFINED CPACK_COMPONENTS_ALL)
796 IF(CPACK_MONOLITHIC_INSTALL)
797 MESSAGE("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.")
798 SET(CPACK_COMPONENTS_ALL)
799 ELSE(CPACK_MONOLITHIC_INSTALL)
800 # The user has provided the set of components to be installed as
801 # part of a component-based installation; trust her.
802 SET(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE)
803 ENDIF(CPACK_MONOLITHIC_INSTALL)
804 ELSE(DEFINED CPACK_COMPONENTS_ALL)
805 # If the user has not specifically requested a monolithic installer
806 # but has specified components in various "install" commands, tell
807 # CPack about those components.
808 IF(NOT CPACK_MONOLITHIC_INSTALL)
809 GET_CMAKE_PROPERTY(CPACK_COMPONENTS_ALL COMPONENTS)
810 LIST(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN)
811 IF(CPACK_COMPONENTS_LEN EQUAL 1)
812 # Only one component: this is not a component-based installation
813 # (at least, it isn't a component-based installation, but may
814 # become one later if the user uses the cpack_add_* commands).
815 SET(CPACK_COMPONENTS_ALL)
816 ENDIF(CPACK_COMPONENTS_LEN EQUAL 1)
817 SET(CPACK_COMPONENTS_LEN)
818 ENDIF(NOT CPACK_MONOLITHIC_INSTALL)
819 ENDIF(DEFINED CPACK_COMPONENTS_ALL)
821 # CMake always generates a component named "Unspecified", which is
822 # used to install everything that doesn't have an explicitly-provided
823 # component. Since these files should always be installed, we'll make
824 # them hidden and required.
825 set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE)
826 set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE)
828 cpack_encode_variables()
829 configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)
831 # Generate source file
832 cpack_set_if_not_set(CPACK_SOURCE_INSTALLED_DIRECTORIES
833 "${CMAKE_SOURCE_DIR};/")
834 cpack_set_if_not_set(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-Source")
835 cpack_set_if_not_set(CPACK_SOURCE_PACKAGE_FILE_NAME
836 "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
837 cpack_set_if_not_set(CPACK_SOURCE_IGNORE_FILES
838 "/CVS/;/\\\\\\\\.svn/;\\\\\\\\.swp$;\\\\\\\\.#;/#")
839 SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
840 SET(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
841 SET(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
842 SET(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}")
843 SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
844 SET(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
845 SET(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
847 cpack_encode_variables()
848 configure_file("${cpack_source_input_file}"
849 "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)