Introduce "generator expressions" to add_test()
[cmake.git] / Modules / CPack.cmake
blob0f0d88033cefeeacf2529e99ee166957b44a2041
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
20 # installations.
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.,
30 #   "Kitware").
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
68 #   generators.
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
78 #   executable ccmake.
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,
89 #   e.g., cmake-2.6.1
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
117 #   install program.
119 #   CPACK_NSIS_MUI_UNIICON - The icon file (.ico) for the generated
120 #   uninstall program.
122 #   CPACK_PACKAGE_ICON - A branding image that will be displayed inside
123 #   the installer.
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
137 #   variable.
139 #   CPACK_NSIS_DISPLAY_NAME - The display name string that appears in
140 #   the Windows Add/Remove Program control panel
142 #   CPACK_NSIS_PACKAGE_NAME - The title displayed at the top of the
143 #   installer.
145 #   CPACK_NSIS_INSTALLED_ICON_NAME - A path to the executable that
146 #   contains the installer icon.
148 #   CPACK_NSIS_HELP_LINK - URL to a web site providing assistance in
149 #   installing your application.
151 #   CPACK_NSIS_URL_INFO_ABOUT - URL to a web site providing more
152 #   information about your application.
154 #   CPACK_NSIS_CONTACT - Contact information for questions and comments
155 #   about the installation process.
157 #   CPACK_NSIS_CREATE_ICONS_EXTRA - Additional NSIS commands for
158 #   creating start menu shortcuts.
160 #   CPACK_NSIS_DELETE_ICONS_EXTRA -Additional NSIS commands to
161 #   uninstall start menu shortcuts.
163 # The following variable is specific to installers build on Mac OS X
164 # using PackageMaker:
166 #   CPACK_OSX_PACKAGE_VERSION - The version of Mac OS X that the
167 #   resulting PackageMaker archive should be compatible
168 #   with. Different versions of Mac OS X support different
169 #   features. For example, CPack can only build component-based
170 #   installers for Mac OS X 10.4 or newer, and can only build
171 #   installers that download component son-the-fly for Mac OS X 10.5
172 #   or newer. If left blank, this value will be set to the minimum
173 #   version of Mac OS X that supports the requested features. Set this
174 #   variable to some value (e.g., 10.4) only if you want to guarantee
175 #   that your installer will work on that version of Mac OS X, and
176 #   don't mind missing extra features available in the installer
177 #   shipping with later versions of Mac OS X.
179 # The following variables are for advanced uses of CPack:
181 #   CPACK_CMAKE_GENERATOR - What CMake generator should be used if the
182 #   project is CMake project. Defaults to the value of CMAKE_GENERATOR;
183 #   few users will want to change this setting.
185 #   CPACK_INSTALL_CMAKE_PROJECTS - List of four values that specify
186 #   what project to install. The four values are: Build directory,
187 #   Project Name, Project Component, Directory. If omitted, CPack will
188 #   build an installer that installers everything.
190 #   CPACK_SYSTEM_NAME - System name, defaults to the value of
191 #   ${CMAKE_SYSTEM_NAME}.
193 #   CPACK_PACKAGE_VERSION - Package full version, used internally. By
194 #   default, this is built from CPACK_PACKAGE_VERSION_MAJOR,
195 #   CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH.
197 #   CPACK_TOPLEVEL_TAG - Directory for the installed files.
199 #   CPACK_INSTALL_COMMANDS - Extra commands to install components.
201 #   CPACK_INSTALL_DIRECTORIES - Extra directories to install.
203 # Component-specific installation allows users to select specific sets
204 # of components to install during the install process. Installation
205 # components are identified by the COMPONENT argument of CMake's
206 # INSTALL commands, and should be further described by the following
207 # CPack commands:
209 #   cpack_add_component - Describes a CPack installation component
210 #   named by the COMPONENT argument to a CMake INSTALL command.
212 #     cpack_add_component(compname
213 #                         [DISPLAY_NAME name]
214 #                         [DESCRIPTION description]
215 #                         [HIDDEN | REQUIRED | DISABLED ]
216 #                         [GROUP group]
217 #                         [DEPENDS comp1 comp2 ... ]
218 #                         [INSTALL_TYPES type1 type2 ... ]
219 #                         [DOWNLOADED]
220 #                         [ARCHIVE_FILE filename])
222 #   The cmake_add_component command describes an installation
223 #   component, which the user can opt to install or remove as part of
224 #   the graphical installation process. compname is the name of the
225 #   component, as provided to the COMPONENT argument of one or more
226 #   CMake INSTALL commands.
228 #   DISPLAY_NAME is the displayed name of the component, used in
229 #   graphical installers to display the component name. This value can
230 #   be any string.
232 #   DESCRIPTION is an extended description of the component, used in
233 #   graphical installers to give the user additional information about
234 #   the component. Descriptions can span multiple lines using "\n" as
235 #   the line separator. Typically, these descriptions should be no
236 #   more than a few lines long.
238 #   HIDDEN indicates that this component will be hidden in the
239 #   graphical installer, so that the user cannot directly change
240 #   whether it is installed or not.
242 #   REQUIRED indicates that this component is required, and therefore
243 #   will always be installed. It will be visible in the graphical
244 #   installer, but it cannot be unselected. (Typically, required
245 #   components are shown greyed out).
247 #   DISABLED indicates that this component should be disabled
248 #   (unselected) by default. The user is free to select this component
249 #   for installation, unless it is also HIDDEN.
251 #   DEPENDS lists the components on which this component depends. If
252 #   this component is selected, then each of the components listed
253 #   must also be selected. The dependency information is encoded
254 #   within the installer itself, so that users cannot install
255 #   inconsitent sets of components.
257 #   GROUP names the component group of which this component is a
258 #   part. If not provided, the component will be a standalone
259 #   component, not part of any component group. Component groups are
260 #   described with the cpack_add_component_group command, detailed
261 #   below.
263 #   INSTALL_TYPES lists the installation types of which this component
264 #   is a part. When one of these installations types is selected, this
265 #   component will automatically be selected. Installation types are
266 #   described with the cpack_add_install_type command, detailed below.
268 #   DOWNLOADED indicates that this component should be downloaded
269 #   on-the-fly by the installer, rather than packaged in with the
270 #   installer itself. For more information, see the cpack_configure_downloads
271 #   command.
273 #   ARCHIVE_FILE provides a name for the archive file created by CPack
274 #   to be used for downloaded components. If not supplied, CPack will
275 #   create a file with some name based on CPACK_PACKAGE_FILE_NAME and
276 #   the name of the component. See cpack_configure_downloads for more
277 #   information.
279 #   cpack_add_component_group - Describes a group of related CPack
280 #   installation components.
282 #     cpack_add_component_group(groupname
283 #                              [DISPLAY_NAME name]
284 #                              [DESCRIPTION description]
285 #                              [PARENT_GROUP parent]
286 #                              [EXPANDED]
287 #                              [BOLD_TITLE])
289 #   The cpack_add_component_group describes a group of installation
290 #   components, which will be placed together within the listing of
291 #   options. Typically, component groups allow the user to
292 #   select/deselect all of the components within a single group via a
293 #   single group-level option. Use component groups to reduce the
294 #   complexity of installers with many options. groupname is an
295 #   arbitrary name used to identify the group in the GROUP argument of
296 #   the cpack_add_component command, which is used to place a
297 #   component in a group. The name of the group must not conflict with
298 #   the name of any component.
300 #   DISPLAY_NAME is the displayed name of the component group, used in
301 #   graphical installers to display the component group name. This
302 #   value can be any string.
304 #   DESCRIPTION is an extended description of the component group,
305 #   used in graphical installers to give the user additional
306 #   information about the components within that group. Descriptions
307 #   can span multiple lines using "\n" as the line
308 #   separator. Typically, these descriptions should be no more than a
309 #   few lines long.
311 #   PARENT_GROUP, if supplied, names the parent group of this group. 
312 #   Parent groups are used to establish a hierarchy of groups, 
313 #   providing an arbitrary hierarchy of groups.
315 #   EXPANDED indicates that, by default, the group should show up as
316 #   "expanded", so that the user immediately sees all of the
317 #   components within the group. Otherwise, the group will initially
318 #   show up as a single entry.
320 #   BOLD_TITLE indicates that the group title should appear in bold,
321 #   to call the user's attention to the group.
323 #   cpack_add_install_type - Add a new installation type containing a
324 #   set of predefined component selections to the graphical installer.
325 #                      
326 #     cpack_add_install_type(typename
327 #                            [DISPLAY_NAME name])   
329 #   The cpack_add_install_type command identifies a set of preselected
330 #   components that represents a common use case for an
331 #   application. For example, a "Developer" install type might include
332 #   an application along with its header and library files, while an
333 #   "End user" install type might just include the application's
334 #   executable. Each component identifies itself with one or more
335 #   install types via the INSTALL_TYPES argument to
336 #   cpack_add_component.
338 #   DISPLAY_NAME is the displayed name of the install type, which will
339 #   typically show up in a drop-down box within a graphical
340 #   installer. This value can be any string.
342 #   cpack_configure_downloads - Configure CPack to download selected
343 #   components on-the-fly as part of the installation process.
345 #     cpack_configure_downloads(site
346 #                               [UPLOAD_DIRECTORY dirname]
347 #                               [ALL]
348 #                               [ADD_REMOVE|NO_ADD_REMOVE])
350 #   The cpack_configure_downloads command configures installation-time
351 #   downloads of selected components. For each downloadable component,
352 #   CPack will create an archive containing the contents of that
353 #   component, which should be uploaded to the given site. When the
354 #   user selects that component for installation, the installer will
355 #   download and extract the component in place. This feature is
356 #   useful for creating small installers that only download the
357 #   requested components, saving bandwidth. Additionally, the
358 #   installers are small enough that they will be installed as part of
359 #   the normal installation process, and the "Change" button in
360 #   Windows Add/Remove Programs control panel will allow one to add or
361 #   remove parts of the application after the original
362 #   installation. On Windows, the downloaded-components functionality
363 #   requires the ZipDLL plug-in for NSIS, available at:
365 #     http://nsis.sourceforge.net/ZipDLL_plug-in
367 #   On Mac OS X, installers that download components on-the-fly can
368 #   only be built and installed on system using Mac OS X 10.5 or
369 #   later.
371 #   The site argument is a URL where the archives for downloadable 
372 #   components will reside, e.g., http://www.cmake.org/files/2.6.1/installer/
373 #   All of the archives produced by CPack should be uploaded to that location.
375 #   UPLOAD_DIRECTORY is the local directory where CPack will create the 
376 #   various archives for each of the components. The contents of this
377 #   directory should be uploaded to a location accessible by the URL given
378 #   in the site argument. If omitted, CPack will use the directory CPackUploads
379 #   inside the CMake binary directory to store the generated archives.
381 #   The ALL flag indicates that all components be downloaded. Otherwise, only 
382 #   those components explicitly marked as DOWNLOADED or that have a specified 
383 #   ARCHIVE_FILE will be downloaded. Additionally, the ALL option implies
384 #   ADD_REMOVE (unless NO_ADD_REMOVE is specified).
386 #   ADD_REMOVE indicates that CPack should install a copy of the installer
387 #   that can be called from Windows' Add/Remove Programs dialog (via the 
388 #   "Modify" button) to change the set of installed components. NO_ADD_REMOVE
389 #   turns off this behavior. This option is ignored on Mac OS X.
392 # Pick a configuration file
393 SET(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
394 IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
395   SET(cpack_input_file "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
396 ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in")
397 SET(cpack_source_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in")
398 IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
399   SET(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
400 ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in")
402 # Argument-parsing macro from http://www.cmake.org/Wiki/CMakeMacroParseArguments
403 MACRO(cpack_parse_arguments prefix arg_names option_names)
404   SET(${prefix}_DEFAULT_ARGS)
405   FOREACH(arg_name ${arg_names})    
406     SET(${prefix}_${arg_name})
407   ENDFOREACH(arg_name)
408   FOREACH(option ${option_names})
409     SET(${prefix}_${option} FALSE)
410   ENDFOREACH(option)
412   SET(current_arg_name DEFAULT_ARGS)
413   SET(current_arg_list)
414   FOREACH(arg ${ARGN})            
415     SET(larg_names ${arg_names})    
416     LIST(FIND larg_names "${arg}" is_arg_name)                   
417     IF (is_arg_name GREATER -1)
418       SET(${prefix}_${current_arg_name} ${current_arg_list})
419       SET(current_arg_name ${arg})
420       SET(current_arg_list)
421     ELSE (is_arg_name GREATER -1)
422       SET(loption_names ${option_names})    
423       LIST(FIND loption_names "${arg}" is_option)            
424       IF (is_option GREATER -1)
425         SET(${prefix}_${arg} TRUE)
426       ELSE (is_option GREATER -1)
427         SET(current_arg_list ${current_arg_list} ${arg})
428       ENDIF (is_option GREATER -1)
429     ENDIF (is_arg_name GREATER -1)
430   ENDFOREACH(arg)
431   SET(${prefix}_${current_arg_name} ${current_arg_list})
432 ENDMACRO(cpack_parse_arguments)
434 # Macro that appends a SET command for the given variable name (var)
435 # to the macro named strvar, but only if the variable named "var"
436 # has been defined. The string will eventually be appended to a CPack
437 # configuration file.
438 MACRO(cpack_append_variable_set_command var strvar)
439   IF (DEFINED ${var})
440     SET(${strvar} "${${strvar}}SET(${var}")
441     FOREACH(APPENDVAL ${${var}})
442       SET(${strvar} "${${strvar}} ${APPENDVAL}")
443     ENDFOREACH(APPENDVAL)
444     SET(${strvar} "${${strvar}})\n")
445   ENDIF (DEFINED ${var})
446 ENDMACRO(cpack_append_variable_set_command)
448 # Macro that appends a SET command for the given variable name (var)
449 # to the macro named strvar, but only if the variable named "var"
450 # has been defined and is a string. The string will eventually be
451 # appended to a CPack configuration file.
452 MACRO(cpack_append_string_variable_set_command var strvar)
453   IF (DEFINED ${var})
454     LIST(LENGTH ${var} CPACK_APP_VALUE_LEN)
455     IF(${CPACK_APP_VALUE_LEN} EQUAL 1)
456       SET(${strvar} "${${strvar}}SET(${var} \"${${var}}\")\n")
457     ENDIF(${CPACK_APP_VALUE_LEN} EQUAL 1)
458   ENDIF (DEFINED ${var})
459 ENDMACRO(cpack_append_string_variable_set_command)
461 # Macro that appends a SET command for the given variable name (var)
462 # to the macro named strvar, but only if the variable named "var"
463 # has been set to true. The string will eventually be
464 # appended to a CPack configuration file.
465 MACRO(cpack_append_option_set_command var strvar)
466   IF (${var})
467     LIST(LENGTH ${var} CPACK_APP_VALUE_LEN)
468     IF(${CPACK_APP_VALUE_LEN} EQUAL 1)
469       SET(${strvar} "${${strvar}}SET(${var} TRUE)\n")
470     ENDIF(${CPACK_APP_VALUE_LEN} EQUAL 1)
471   ENDIF (${var})
472 ENDMACRO(cpack_append_option_set_command)
474 # Macro that adds a component to the CPack installer
475 MACRO(cpack_add_component compname)
476   STRING(TOUPPER ${compname} CPACK_ADDCOMP_UNAME)
477   cpack_parse_arguments(CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}
478     "DISPLAY_NAME;DESCRIPTION;GROUP;DEPENDS;INSTALL_TYPES;ARCHIVE_FILE"
479     "HIDDEN;REQUIRED;DISABLED;DOWNLOADED"
480     ${ARGN}
481     )
482   
483   if (CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED)
484     SET(CPACK_ADDCOMP_STR "\n# Configuration for downloaded component \"${compname}\"\n")
485   else ()
486     SET(CPACK_ADDCOMP_STR "\n# Configuration for component \"${compname}\"\n")
487   endif ()
489   IF(NOT CPACK_MONOLITHIC_INSTALL)
490     # If the user didn't set CPACK_COMPONENTS_ALL explicitly, update the
491     # value of CPACK_COMPONENTS_ALL in the configuration file. This will
492     # take care of any components that have been added after the CPack
493     # moduled was included.
494     IF(NOT CPACK_COMPONENTS_ALL_SET_BY_USER)
495       GET_CMAKE_PROPERTY(CPACK_ADDCOMP_COMPONENTS COMPONENTS)
496       SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR}\nSET(CPACK_COMPONENTS_ALL")
497       FOREACH(COMP ${CPACK_ADDCOMP_COMPONENTS})
498         SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR} ${COMP}")
499       ENDFOREACH(COMP)
500       SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR})\n")
501     ENDIF(NOT CPACK_COMPONENTS_ALL_SET_BY_USER)
502   ENDIF(NOT CPACK_MONOLITHIC_INSTALL)
504   cpack_append_string_variable_set_command(
505     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISPLAY_NAME
506     CPACK_ADDCOMP_STR)
507   cpack_append_string_variable_set_command(
508     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DESCRIPTION
509     CPACK_ADDCOMP_STR)
510   cpack_append_variable_set_command(
511     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_GROUP
512     CPACK_ADDCOMP_STR)
513   cpack_append_variable_set_command(
514     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DEPENDS
515     CPACK_ADDCOMP_STR)
516   cpack_append_variable_set_command(
517     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_INSTALL_TYPES
518     CPACK_ADDCOMP_STR)
519   cpack_append_string_variable_set_command(
520     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_ARCHIVE_FILE
521     CPACK_ADDCOMP_STR)    
522   cpack_append_option_set_command(
523     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_HIDDEN
524     CPACK_ADDCOMP_STR)
525   cpack_append_option_set_command(
526     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_REQUIRED
527     CPACK_ADDCOMP_STR)
528   cpack_append_option_set_command(
529     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISABLED
530     CPACK_ADDCOMP_STR)
531   cpack_append_option_set_command(
532     CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED
533     CPACK_ADDCOMP_STR)
534   FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDCOMP_STR}")
535 ENDMACRO(cpack_add_component)
537 # Macro that adds a component group to the CPack installer
538 MACRO(cpack_add_component_group grpname)
539   STRING(TOUPPER ${grpname} CPACK_ADDGRP_UNAME)
540   cpack_parse_arguments(CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}
541     "DISPLAY_NAME;DESCRIPTION"
542     "EXPANDED;BOLD_TITLE"
543     ${ARGN}
544     )
546   SET(CPACK_ADDGRP_STR "\n# Configuration for component group \"${grpname}\"\n")
547   cpack_append_string_variable_set_command(
548     CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DISPLAY_NAME
549     CPACK_ADDGRP_STR)
550   cpack_append_string_variable_set_command(
551     CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DESCRIPTION
552     CPACK_ADDGRP_STR)
553   cpack_append_option_set_command(
554     CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_EXPANDED
555     CPACK_ADDGRP_STR)
556   cpack_append_option_set_command(
557     CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_BOLD_TITLE
558     CPACK_ADDGRP_STR)
559   FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDGRP_STR}")
560 ENDMACRO(cpack_add_component_group)
562 # Macro that adds an installation type to the CPack installer
563 MACRO(cpack_add_install_type insttype)
564   STRING(TOUPPER ${insttype} CPACK_INSTTYPE_UNAME)
565   cpack_parse_arguments(CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME}
566     "DISPLAY_NAME"
567     ""
568     ${ARGN}
569     )
571   SET(CPACK_INSTTYPE_STR 
572     "\n# Configuration for installation type \"${insttype}\"\n")
573   SET(CPACK_INSTTYPE_STR 
574     "${CPACK_INSTTYPE_STR}LIST(APPEND CPACK_ALL_INSTALL_TYPES ${insttype})\n")
575   cpack_append_string_variable_set_command(
576     CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME}_DISPLAY_NAME
577     CPACK_INSTTYPE_STR)
578   FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_INSTTYPE_STR}")
579 ENDMACRO(cpack_add_install_type)
581 MACRO(cpack_configure_downloads site)
582   cpack_parse_arguments(CPACK_DOWNLOAD
583     "UPLOAD_DIRECTORY"
584     "ALL;ADD_REMOVE;NO_ADD_REMOVE"
585     ${ARGN}
586     )
587     
588   SET(CPACK_CONFIG_DL_STR
589     "\n# Downloaded components configuration\n")
590   SET(CPACK_UPLOAD_DIRECTORY ${CPACK_DOWNLOAD_UPLOAD_DIRECTORY})
591   SET(CPACK_DOWNLOAD_SITE ${site})
592   cpack_append_string_variable_set_command(
593     CPACK_DOWNLOAD_SITE
594     CPACK_CONFIG_DL_STR)  
595   cpack_append_string_variable_set_command(
596     CPACK_UPLOAD_DIRECTORY
597     CPACK_CONFIG_DL_STR)
598   cpack_append_option_set_command(
599     CPACK_DOWNLOAD_ALL
600     CPACK_CONFIG_DL_STR)
601   IF (${CPACK_DOWNLOAD_ALL} AND NOT ${CPACK_DOWNLOAD_NO_ADD_REMOVE})
602     SET(CPACK_DOWNLOAD_ADD_REMOVE ON)
603   ENDIF (${CPACK_DOWNLOAD_ALL} AND NOT ${CPACK_DOWNLOAD_NO_ADD_REMOVE})
604   SET(CPACK_ADD_REMOVE ${CPACK_DOWNLOAD_ADD_REMOVE})
605   cpack_append_option_set_command(
606     CPACK_ADD_REMOVE
607     CPACK_CONFIG_DL_STR)
608   FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_CONFIG_DL_STR}")
609 ENDMACRO(cpack_configure_downloads)
611 # Macro for setting values if a user did not overwrite them
612 MACRO(cpack_set_if_not_set name value)
613   IF(NOT DEFINED "${name}")
614     SET(${name} "${value}")
615   ENDIF(NOT DEFINED "${name}")
616 ENDMACRO(cpack_set_if_not_set)
618 # Macro to encode variables for the configuration file
619 # find any varable that stars with CPACK and create a variable
620 # _CPACK_OTHER_VARIABLES_ that contains SET commands for
621 # each cpack variable.  _CPACK_OTHER_VARIABLES_ is then
622 # used as an @ replacment in configure_file for the CPackConfig.
623 MACRO(cpack_encode_variables)
624   SET(_CPACK_OTHER_VARIABLES_)
625   GET_CMAKE_PROPERTY(res VARIABLES)
626   FOREACH(var ${res})
627     IF("xxx${var}" MATCHES "xxxCPACK")  
628       SET(_CPACK_OTHER_VARIABLES_
629         "${_CPACK_OTHER_VARIABLES_}\nSET(${var} \"${${var}}\")")
630       ENDIF("xxx${var}" MATCHES "xxxCPACK")
631   ENDFOREACH(var ${res})
632 ENDMACRO(cpack_encode_variables)
634 # Set the package name
635 cpack_set_if_not_set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
636 cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MAJOR "0")
637 cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MINOR "1")
638 cpack_set_if_not_set(CPACK_PACKAGE_VERSION_PATCH "1")
639 cpack_set_if_not_set(CPACK_PACKAGE_VERSION
640   "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
641 cpack_set_if_not_set(CPACK_PACKAGE_VENDOR "Humanity")
642 cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
643   "${CMAKE_PROJECT_NAME} built using CMake")
645 cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_FILE
646   "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
647 cpack_set_if_not_set(CPACK_RESOURCE_FILE_LICENSE
648   "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
649 cpack_set_if_not_set(CPACK_RESOURCE_FILE_README
650   "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
651 cpack_set_if_not_set(CPACK_RESOURCE_FILE_WELCOME
652   "${CMAKE_ROOT}/Templates/CPack.GenericWelcome.txt")
654 cpack_set_if_not_set(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
656 IF(CPACK_NSIS_MODIFY_PATH)
657   SET(CPACK_NSIS_MODIFY_PATH ON)
658 ENDIF(CPACK_NSIS_MODIFY_PATH)
660 SET(__cpack_system_name ${CMAKE_SYSTEM_NAME})
661 IF(${__cpack_system_name} MATCHES Windows)
662   IF(CMAKE_CL_64)
663     SET(__cpack_system_name win64)
664   ELSE(CMAKE_CL_64)
665     SET(__cpack_system_name win32)
666   ENDIF(CMAKE_CL_64)
667 ENDIF(${__cpack_system_name} MATCHES Windows)
668 cpack_set_if_not_set(CPACK_SYSTEM_NAME "${__cpack_system_name}")
670 # <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
671 cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME
672   "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
673 cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY
674   "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
675 cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
676   "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
677 cpack_set_if_not_set(CPACK_PACKAGE_DEFAULT_LOCATION "/")
678 cpack_set_if_not_set(CPACK_PACKAGE_RELOCATABLE "true")
680 # always force to exactly "true" or "false" for CPack.Info.plist.in:
681 if(CPACK_PACKAGE_RELOCATABLE)
682   set(CPACK_PACKAGE_RELOCATABLE "true")
683 else(CPACK_PACKAGE_RELOCATABLE)
684   set(CPACK_PACKAGE_RELOCATABLE "false")
685 endif(CPACK_PACKAGE_RELOCATABLE)
687 macro(cpack_check_file_exists file description)
688   if(NOT EXISTS "${file}")
689     message(SEND_ERROR "CPack ${description} file: \"${file}\" could not be found.")
690   endif(NOT EXISTS "${file}")
691 endmacro(cpack_check_file_exists)
693 cpack_check_file_exists("${CPACK_PACKAGE_DESCRIPTION_FILE}" "package description")
694 cpack_check_file_exists("${CPACK_RESOURCE_FILE_LICENSE}"    "license resource")
695 cpack_check_file_exists("${CPACK_RESOURCE_FILE_README}"     "readme resource")
696 cpack_check_file_exists("${CPACK_RESOURCE_FILE_WELCOME}"    "welcome resource")
698 macro(cpack_optional_append _list _cond _item)
699   if(${_cond})
700     set(${_list} ${${_list}} ${_item})
701   endif(${_cond})
702 endmacro(cpack_optional_append _list _cond _item)
704 # Provide options to choose generators
705 # we might check here if the required tools for the generates exist
706 # and set the defaults according to the results
707 if(NOT CPACK_GENERATOR)
708   if(UNIX)
709     if(CYGWIN)
710       option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON)
711     else(CYGWIN)
712       if(APPLE)
713         option(CPACK_BINARY_BUNDLE       "Enable to build OSX bundles"      OFF)
714         option(CPACK_BINARY_DRAGNDROP    "Enable to build OSX Drag And Drop package" OFF)
715         option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" ON)
716         option(CPACK_BINARY_OSXX11       "Enable to build OSX X11 packages"      OFF)
717       else(APPLE)
718         option(CPACK_BINARY_TZ  "Enable to build TZ packages"     ON)
719       endif(APPLE)
720       option(CPACK_BINARY_STGZ "Enable to build STGZ packages"    ON)
721       option(CPACK_BINARY_TGZ  "Enable to build TGZ packages"     ON)
722       option(CPACK_BINARY_TBZ2 "Enable to build TBZ2 packages"    OFF)
723       option(CPACK_BINARY_DEB  "Enable to build Debian packages"  OFF)
724       option(CPACK_BINARY_RPM  "Enable to build RPM packages"     OFF)
725       option(CPACK_BINARY_NSIS "Enable to build NSIS packages"    OFF)
726     endif(CYGWIN)
727   else(UNIX)
728     option(CPACK_BINARY_NSIS "Enable to build NSIS packages" ON)
729     option(CPACK_BINARY_ZIP  "Enable to build ZIP packages" OFF)
730   endif(UNIX)
731   
732   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_BUNDLE       Bundle)
733   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_DRAGNDROP    DragNDrop)
734   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_PACKAGEMAKER PackageMaker)
735   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_OSXX11       OSXX11)
736   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_CYGWIN       CygwinBinary)
737   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_DEB          DEB)
738   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_RPM          RPM)
739   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_NSIS         NSIS)
740   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_STGZ         STGZ)
741   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_TGZ          TGZ)
742   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_TBZ2         TBZ2)
743   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_TZ           TZ)
744   cpack_optional_append(CPACK_GENERATOR  CPACK_BINARY_ZIP          ZIP)
745   
746 endif(NOT CPACK_GENERATOR)
748 # Provide options to choose source generators
749 if(NOT CPACK_SOURCE_GENERATOR)
750   if(UNIX)
751     if(CYGWIN)
752       option(CPACK_SOURCE_CYGWIN "Enable to build Cygwin source packages" ON)
753     else(CYGWIN)
754       option(CPACK_SOURCE_TBZ2 "Enable to build TBZ2 source packages" ON)
755       option(CPACK_SOURCE_TGZ  "Enable to build TGZ source packages"  ON)
756       option(CPACK_SOURCE_TZ   "Enable to build TZ source packages"   ON)
757       option(CPACK_SOURCE_ZIP  "Enable to build ZIP source packages"  OFF)
758     endif(CYGWIN)
759   else(UNIX)
760     option(CPACK_SOURCE_ZIP "Enable to build ZIP source packages" ON)
761   endif(UNIX)
763   cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_CYGWIN  CygwinSource)
764   cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_TGZ     TGZ)
765   cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_TBZ2    TBZ2)
766   cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_TZ      TZ)
767   cpack_optional_append(CPACK_SOURCE_GENERATOR  CPACK_SOURCE_ZIP     ZIP)
768 endif(NOT CPACK_SOURCE_GENERATOR)
770 # mark the above options as advanced
771 mark_as_advanced(CPACK_BINARY_CYGWIN CPACK_BINARY_PACKAGEMAKER CPACK_BINARY_OSXX11
772                  CPACK_BINARY_STGZ   CPACK_BINARY_TGZ          CPACK_BINARY_TBZ2 
773                  CPACK_BINARY_DEB    CPACK_BINARY_RPM          CPACK_BINARY_TZ     
774                  CPACK_BINARY_NSIS CPACK_BINARY_ZIP CPACK_BINARY_BUNDLE
775                  CPACK_SOURCE_CYGWIN CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ 
776                  CPACK_SOURCE_TZ CPACK_SOURCE_ZIP CPACK_BINARY_DRAGNDROP)
778 # Set some other variables
779 cpack_set_if_not_set(CPACK_INSTALL_CMAKE_PROJECTS
780   "${CMAKE_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
781 cpack_set_if_not_set(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}")
782 cpack_set_if_not_set(CPACK_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}")
784 cpack_set_if_not_set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
785 cpack_set_if_not_set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
787 cpack_set_if_not_set(CPACK_OUTPUT_CONFIG_FILE
788   "${CMAKE_BINARY_DIR}/CPackConfig.cmake")
790 cpack_set_if_not_set(CPACK_SOURCE_OUTPUT_CONFIG_FILE
791   "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")
793 cpack_set_if_not_set(CPACK_SET_DESTDIR OFF)
794 cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
796 cpack_set_if_not_set(CPACK_NSIS_INSTALLER_ICON_CODE "")
797 cpack_set_if_not_set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
799 IF(DEFINED CPACK_COMPONENTS_ALL)
800   IF(CPACK_MONOLITHIC_INSTALL)
801     MESSAGE("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.")
802     SET(CPACK_COMPONENTS_ALL)
803   ELSE(CPACK_MONOLITHIC_INSTALL)
804     # The user has provided the set of components to be installed as
805     # part of a component-based installation; trust her.
806     SET(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE)
807   ENDIF(CPACK_MONOLITHIC_INSTALL)
808 ELSE(DEFINED CPACK_COMPONENTS_ALL)
809   # If the user has not specifically requested a monolithic installer
810   # but has specified components in various "install" commands, tell
811   # CPack about those components.
812   IF(NOT CPACK_MONOLITHIC_INSTALL)
813     GET_CMAKE_PROPERTY(CPACK_COMPONENTS_ALL COMPONENTS)
814     LIST(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN)
815     IF(CPACK_COMPONENTS_LEN EQUAL 1)
816       # Only one component: this is not a component-based installation
817       # (at least, it isn't a component-based installation, but may
818       # become one later if the user uses the cpack_add_* commands).
819       SET(CPACK_COMPONENTS_ALL)
820     ENDIF(CPACK_COMPONENTS_LEN EQUAL 1)
821     SET(CPACK_COMPONENTS_LEN)
822   ENDIF(NOT CPACK_MONOLITHIC_INSTALL)
823 ENDIF(DEFINED CPACK_COMPONENTS_ALL)
825 # CMake always generates a component named "Unspecified", which is
826 # used to install everything that doesn't have an explicitly-provided
827 # component. Since these files should always be installed, we'll make
828 # them hidden and required.
829 set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE)
830 set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE)
832 cpack_encode_variables()
833 configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)
835 # Generate source file
836 cpack_set_if_not_set(CPACK_SOURCE_INSTALLED_DIRECTORIES
837   "${CMAKE_SOURCE_DIR};/")
838 cpack_set_if_not_set(CPACK_SOURCE_TOPLEVEL_TAG "${CPACK_SYSTEM_NAME}-Source")
839 cpack_set_if_not_set(CPACK_SOURCE_PACKAGE_FILE_NAME
840   "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-Source")
841 cpack_set_if_not_set(CPACK_SOURCE_IGNORE_FILES
842   "/CVS/;/\\\\\\\\.svn/;\\\\\\\\.swp$;\\\\\\\\.#;/#")
843 SET(CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_SOURCE_INSTALL_CMAKE_PROJECTS}")
844 SET(CPACK_INSTALLED_DIRECTORIES "${CPACK_SOURCE_INSTALLED_DIRECTORIES}")
845 SET(CPACK_GENERATOR "${CPACK_SOURCE_GENERATOR}")
846 SET(CPACK_TOPLEVEL_TAG "${CPACK_SOURCE_TOPLEVEL_TAG}")
847 SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}")
848 SET(CPACK_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}")
849 SET(CPACK_STRIP_FILES "${CPACK_SOURCE_STRIP_FILES}")
851 cpack_encode_variables()
852 configure_file("${cpack_source_input_file}"
853   "${CPACK_SOURCE_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE)