4 The built in (binary) CPack RPM generator (Unix only)
6 Variables specific to CPack RPM generator
7 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9 The CPack RPM generator may be used to create RPM packages using :module:`CPack`.
10 The CPack RPM generator is a :module:`CPack` generator thus it uses the
11 ``CPACK_XXX`` variables used by :module:`CPack`.
13 The CPack RPM generator has specific features which are controlled by the specifics
14 ``CPACK_RPM_XXX`` variables.
16 ``CPACK_RPM_<COMPONENT>_XXXX`` variables may be used in order to have
17 **component** specific values. Note however that ``<COMPONENT>`` refers to the
18 **grouping name** written in upper case. It may be either a component name or
19 a component GROUP name. Usually those variables correspond to RPM spec file
20 entities. One may find information about spec files here
21 https://rpm.org/documentation
23 .. versionchanged:: 3.6
25 `<COMPONENT>` part of variables is preferred to be in upper case (e.g. if
26 component is named ``foo`` then use ``CPACK_RPM_FOO_XXXX`` variable name format)
27 as is with other ``CPACK_<COMPONENT>_XXXX`` variables.
28 For the purposes of back compatibility (CMake/CPack version 3.5 and lower)
29 support for same cased component (e.g. ``fOo`` would be used as
30 ``CPACK_RPM_fOo_XXXX``) is still supported for variables defined in older
31 versions of CMake/CPack but is not guaranteed for variables that
32 will be added in the future. For the sake of back compatibility same cased
33 component variables also override upper cased versions where both are
36 Here are some CPack RPM generator wiki resources that are here for historic
37 reasons and are no longer maintained but may still prove useful:
39 - https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/Configuration
40 - https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/PackageGenerators#rpm-unix-only
42 List of CPack RPM generator specific variables:
44 .. variable:: CPACK_RPM_COMPONENT_INSTALL
46 Enable component packaging for CPack RPM generator
51 If enabled (``ON``) multiple packages are generated. By default
52 a single package containing files of all components is generated.
54 .. variable:: CPACK_RPM_PACKAGE_SUMMARY
55 CPACK_RPM_<component>_PACKAGE_SUMMARY
57 The RPM package summary.
60 * Default : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
63 Per-component ``CPACK_RPM_<component>_PACKAGE_SUMMARY`` variables.
65 .. variable:: CPACK_RPM_PACKAGE_NAME
66 CPACK_RPM_<component>_PACKAGE_NAME
71 * Default : :variable:`CPACK_PACKAGE_NAME`
74 Per-component ``CPACK_RPM_<component>_PACKAGE_NAME`` variables.
76 .. variable:: CPACK_RPM_FILE_NAME
77 CPACK_RPM_<component>_FILE_NAME
84 * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].rpm`` with spaces
87 This may be set to ``RPM-DEFAULT`` to allow ``rpmbuild`` tool to generate package
89 Alternatively provided package file name must end with ``.rpm`` suffix.
93 By using user provided spec file, rpm macro extensions such as for
94 generating ``debuginfo`` packages or by simply using multiple components more
95 than one rpm file may be generated, either from a single spec file or from
96 multiple spec files (each component execution produces its own spec file).
97 In such cases duplicate file names may occur as a result of this variable
98 setting or spec file content structure. Duplicate files get overwritten
99 and it is up to the packager to set the variables in a manner that will
102 .. variable:: CPACK_RPM_MAIN_COMPONENT
104 .. versionadded:: 3.8
106 Main component that is packaged without component suffix.
111 This variable can be set to any component or group name so that component or
112 group rpm package is generated without component suffix in filename and
115 .. variable:: CPACK_RPM_PACKAGE_EPOCH
117 .. versionadded:: 3.10
119 The RPM package epoch
124 Optional number that should be incremented when changing versioning schemas
125 or fixing mistakes in the version numbers of older packages.
127 .. variable:: CPACK_RPM_PACKAGE_VERSION
129 The RPM package version.
132 * Default : :variable:`CPACK_PACKAGE_VERSION`
134 .. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE
135 CPACK_RPM_<component>_PACKAGE_ARCHITECTURE
137 The RPM package architecture.
140 * Default : Native architecture output by ``uname -m``
142 This may be set to ``noarch`` if you know you are building a ``noarch`` package.
144 .. versionadded:: 3.3
145 Per-component ``CPACK_RPM_<component>_PACKAGE_ARCHITECTURE`` variables.
147 .. variable:: CPACK_RPM_PACKAGE_RELEASE
149 The RPM package release.
154 This is the numbering of the RPM package itself, i.e. the version of the
155 packaging and not the version of the content (see
156 :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if
157 the previous packaging was buggy and/or you want to put here a fancy Linux
158 distro specific numbering.
162 This is the string that goes into the RPM ``Release:`` field. Some distros
163 (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number.
164 ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
166 .. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST
168 .. versionadded:: 3.6
170 The dist tag that is added RPM ``Release:`` field.
175 This is the reported ``%{dist}`` tag from the current distribution or empty
176 ``%{dist}`` if RPM macro is not set. If this variable is set then RPM
177 ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``.
179 .. variable:: CPACK_RPM_PACKAGE_LICENSE
181 The RPM package license policy.
184 * Default : "unknown"
186 .. variable:: CPACK_RPM_PACKAGE_GROUP
187 CPACK_RPM_<component>_PACKAGE_GROUP
189 The RPM package group.
192 * Default : "unknown"
194 .. versionadded:: 3.5
195 Per-component ``CPACK_RPM_<component>_PACKAGE_GROUP`` variables.
197 .. variable:: CPACK_RPM_PACKAGE_VENDOR
199 The RPM package vendor.
202 * Default : CPACK_PACKAGE_VENDOR if set or "unknown"
204 .. variable:: CPACK_RPM_PACKAGE_URL
205 CPACK_RPM_<component>_PACKAGE_URL
210 * Default : :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
212 .. versionadded:: 3.12
213 The ``CMAKE_PROJECT_HOMEPAGE_URL`` variable.
215 .. variable:: CPACK_RPM_PACKAGE_DESCRIPTION
216 CPACK_RPM_<component>_PACKAGE_DESCRIPTION
218 RPM package description.
221 * Default : :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component
222 based installers only) if set, :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`
223 if set or "no package description available"
225 .. versionadded:: 3.2
226 Per-component ``CPACK_RPM_<component>_PACKAGE_DESCRIPTION`` variables.
228 .. variable:: CPACK_RPM_COMPRESSION_TYPE
230 RPM compression type.
235 May be used to override RPM compression type to be used to build the
236 RPM. For example some Linux distribution now default to ``lzma`` or ``xz``
237 compression whereas older cannot use such RPM. Using this one can enforce
238 compression type to be used.
247 .. variable:: CPACK_RPM_PACKAGE_AUTOREQ
248 CPACK_RPM_<component>_PACKAGE_AUTOREQ
250 RPM spec autoreq field.
255 May be used to enable (``1``, ``yes``) or disable (``0``, ``no``) automatic
256 shared libraries dependency detection. Dependencies are added to requires list.
260 By default automatic dependency detection is enabled by rpm generator.
262 .. variable:: CPACK_RPM_PACKAGE_AUTOPROV
263 CPACK_RPM_<component>_PACKAGE_AUTOPROV
265 RPM spec autoprov field.
270 May be used to enable (``1``, ``yes``) or disable (``0``, ``no``)
271 automatic listing of shared libraries that are provided by the package.
272 Shared libraries are added to provides list.
276 By default automatic provides detection is enabled by rpm generator.
278 .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV
279 CPACK_RPM_<component>_PACKAGE_AUTOREQPROV
281 RPM spec autoreqprov field.
286 Variable enables/disables autoreq and autoprov at the same time.
287 See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and
288 :variable:`CPACK_RPM_PACKAGE_AUTOPROV` for more details.
292 By default automatic detection feature is enabled by rpm.
294 .. variable:: CPACK_RPM_PACKAGE_REQUIRES
295 CPACK_RPM_<component>_PACKAGE_REQUIRES
297 RPM spec requires field.
302 May be used to set RPM dependencies (requires). Note that you must enclose
303 the complete requires string between quotes, for example::
305 set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8")
307 The required package list of an RPM file could be printed with::
309 rpm -qp --requires file.rpm
311 .. variable:: CPACK_RPM_PACKAGE_CONFLICTS
312 CPACK_RPM_<component>_PACKAGE_CONFLICTS
314 RPM spec conflicts field.
319 May be used to set negative RPM dependencies (conflicts). Note that you must
320 enclose the complete requires string between quotes, for example::
322 set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2")
324 The conflicting package list of an RPM file could be printed with::
326 rpm -qp --conflicts file.rpm
328 .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
329 CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE
331 .. versionadded:: 3.2
333 RPM spec requires(pre) field.
338 May be used to set RPM preinstall dependencies (requires(pre)). Note that
339 you must enclose the complete requires string between quotes, for example::
341 set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
343 .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
344 CPACK_RPM_<component>_PACKAGE_REQUIRES_POST
346 .. versionadded:: 3.2
348 RPM spec requires(post) field.
353 May be used to set RPM postinstall dependencies (requires(post)). Note that
354 you must enclose the complete requires string between quotes, for example::
356 set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
358 .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
359 CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
361 .. versionadded:: 3.2
363 RPM spec requires(postun) field.
368 May be used to set RPM postuninstall dependencies (requires(postun)). Note
369 that you must enclose the complete requires string between quotes, for
372 set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts")
374 .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
375 CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
377 .. versionadded:: 3.2
379 RPM spec requires(preun) field.
384 May be used to set RPM preuninstall dependencies (requires(preun)). Note that
385 you must enclose the complete requires string between quotes, for example::
387 set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
389 .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
390 CPACK_RPM_<component>_PACKAGE_SUGGESTS
392 RPM spec suggest field.
397 May be used to set weak RPM dependencies (suggests). If ``rpmbuild`` doesn't
398 support the ``Suggests`` tag, CPack will emit a warning and ignore this
399 variable. Note that you must enclose the complete requires string between
402 .. variable:: CPACK_RPM_PACKAGE_PROVIDES
403 CPACK_RPM_<component>_PACKAGE_PROVIDES
405 RPM spec provides field.
410 May be used to set RPM dependencies (provides). The provided package list
411 of an RPM file could be printed with::
413 rpm -qp --provides file.rpm
415 .. variable:: CPACK_RPM_PACKAGE_OBSOLETES
416 CPACK_RPM_<component>_PACKAGE_OBSOLETES
418 RPM spec obsoletes field.
423 May be used to set RPM packages that are obsoleted by this one.
425 .. variable:: CPACK_RPM_PACKAGE_RELOCATABLE
427 build a relocatable RPM.
430 * Default : CPACK_PACKAGE_RELOCATABLE
432 If this variable is set to TRUE or ON, the CPack RPM generator will try
433 to build a relocatable RPM package. A relocatable RPM may
436 rpm --prefix or --relocate
438 in order to install it at an alternate place see rpm(8). Note that
439 currently this may fail if :variable:`CPACK_SET_DESTDIR` is set to ``ON``. If
440 :variable:`CPACK_SET_DESTDIR` is set then you will get a warning message but
441 if there is file installed with absolute path you'll get unexpected behavior.
443 .. variable:: CPACK_RPM_SPEC_INSTALL_POST
445 Deprecated - use :variable:`CPACK_RPM_SPEC_MORE_DEFINE` instead.
451 May be used to override the ``__spec_install_post`` section within the
452 generated spec file. This affects the install step during package creation,
453 not during package installation. For adding operations to be performed
454 during package installation, use
455 :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE` instead.
457 .. variable:: CPACK_RPM_SPEC_MORE_DEFINE
459 RPM extended spec definitions lines.
464 May be used to add any ``%define`` lines to the generated spec file. An
465 example of its use is to prevent stripping of executables (but note that
466 this may also disable other default post install processing)::
468 set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true")
470 .. variable:: CPACK_RPM_PACKAGE_DEBUG
472 Toggle CPack RPM generator debug output.
477 May be set when invoking cpack in order to trace debug information
478 during CPack RPM run. For example you may launch CPack like this::
480 cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
482 .. variable:: CPACK_RPM_USER_BINARY_SPECFILE
483 CPACK_RPM_<componentName>_USER_BINARY_SPECFILE
485 A user provided spec file.
490 May be set by the user in order to specify a USER binary spec file
491 to be used by the CPack RPM generator instead of generating the file.
492 The specified file will be processed by configure_file( @ONLY).
494 .. variable:: CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
501 If set CPack will generate a template for USER specified binary
502 spec file and stop with an error. For example launch CPack like this::
504 cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM
506 The user may then use this file in order to hand-craft is own
507 binary spec file which may be used with
508 :variable:`CPACK_RPM_USER_BINARY_SPECFILE`.
510 .. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
511 CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
512 CPACK_RPM_PRE_TRANS_SCRIPT_FILE
514 Path to file containing pre install/uninstall/transaction script.
519 May be used to embed a pre installation/uninstallation/transaction script in the spec file.
520 The referred script file (or both) will be read and directly
521 put after the ``%pre`` or ``%preun`` section
522 If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the install/uninstall/transaction
523 script for each component can be overridden with
524 ``CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE``,
525 ``CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE``, and
526 ``CPACK_RPM_<COMPONENT>_PRE_TRANS_SCRIPT_FILE``
527 One may verify which scriptlet has been included with::
529 rpm -qp --scripts package.rpm
531 .. versionadded:: 3.18
532 The ``CPACK_RPM_PRE_TRANS_SCRIPT_FILE`` variable.
534 .. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE
535 CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
536 CPACK_RPM_POST_TRANS_SCRIPT_FILE
538 Path to file containing post install/uninstall/transaction script.
543 May be used to embed a post installation/uninstallation/transaction script in the spec file.
544 The referred script file (or both) will be read and directly
545 put after the ``%post`` or ``%postun`` section.
546 If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the install/uninstall/transaction
547 script for each component can be overridden with
548 ``CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE``,
549 ``CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE``, and
550 ``CPACK_RPM_<COMPONENT>_POST_TRANS_SCRIPT_FILE``
551 One may verify which scriptlet has been included with::
553 rpm -qp --scripts package.rpm
555 .. versionadded:: 3.18
556 The ``CPACK_RPM_POST_TRANS_SCRIPT_FILE`` variable.
558 .. variable:: CPACK_RPM_USER_FILELIST
559 CPACK_RPM_<COMPONENT>_USER_FILELIST
564 May be used to explicitly specify ``%(<directive>)`` file line
565 in the spec file. Like ``%config(noreplace)`` or any other directive
566 that be found in the ``%files`` section. Since
567 the CPack RPM generator is generating the list of files (and directories) the
568 user specified files of the ``CPACK_RPM_<COMPONENT>_USER_FILELIST`` list will
569 be removed from the generated list. If referring to directories do
570 not add a trailing slash.
572 .. versionadded:: 3.8
573 You can have multiple directives per line, as in
574 ``%attr(600,root,root) %config(noreplace)``.
576 .. variable:: CPACK_RPM_CHANGELOG_FILE
583 May be used to embed a changelog in the spec file.
584 The referred file will be read and directly put after the ``%changelog``
587 .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
589 list of path to be excluded.
592 * Default : /etc /etc/init.d /usr /usr/bin /usr/include /usr/lib
593 /usr/libx32 /usr/lib64 /usr/share /usr/share/aclocal
596 May be used to exclude path (directories or files) from the auto-generated
597 list of paths discovered by CPack RPM. The default value contains a
598 reasonable set of values if the variable is not defined by the user. If the
599 variable is defined by the user then the CPack RPM generator will NOT any of
600 the default path. If you want to add some path to the default list then you
601 can use :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable.
603 .. versionadded:: 3.10
604 Added ``/usr/share/aclocal`` to the default list of excludes.
606 .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
608 additional list of path to be excluded.
613 May be used to add more exclude path (directories or files) from the initial
614 default list of excluded paths. See
615 :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST`.
617 .. variable:: CPACK_RPM_RELOCATION_PATHS
619 .. versionadded:: 3.2
621 Packages relocation paths list.
626 May be used to specify more than one relocation path per relocatable RPM.
627 Variable contains a list of relocation paths that if relative are prefixed
628 by the value of :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` or by the
629 value of :variable:`CPACK_PACKAGING_INSTALL_PREFIX` if the component version
631 Variable is not component based as its content can be used to set a different
632 path prefix for e.g. binary dir and documentation dir at the same time.
633 Only prefixes that are required by a certain component are added to that
634 component - component must contain at least one file/directory/symbolic link
635 with :variable:`CPACK_RPM_RELOCATION_PATHS` prefix for a certain relocation
636 path to be added. Package will not contain any relocation paths if there are
637 no files/directories/symbolic links on any of the provided prefix locations.
638 Packages that either do not contain any relocation paths or contain
639 files/directories/symbolic links that are outside relocation paths print
640 out an ``AUTHOR_WARNING`` that RPM will be partially relocatable.
642 .. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
644 .. versionadded:: 3.2
646 Per component relocation path install prefix.
649 * Default : CPACK_PACKAGING_INSTALL_PREFIX
651 May be used to set per component :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
652 for relocatable RPM packages.
654 .. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
655 CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION
657 .. versionadded:: 3.3
659 Removal of default install prefix from relocation paths list.
662 * Default : CPACK_PACKAGING_INSTALL_PREFIX or CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
663 are treated as one of relocation paths
665 May be used to remove CPACK_PACKAGING_INSTALL_PREFIX and CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
666 from relocatable RPM prefix paths.
668 .. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS
670 .. versionadded:: 3.3
675 May be used to set additional man dirs that could potentially be compressed
676 by brp-compress RPM macro. Variable content must be a list of regular
677 expressions that point to directories containing man files or to man files
678 directly. Note that in order to compress man pages a path must also be
679 present in brp-compress RPM script and that brp-compress script must be
680 added to RPM configuration by the operating system.
682 Regular expressions that are added by default were taken from brp-compress
688 - /usr/share/man/man.*
689 - /usr/share/man/.*/man.*
691 - /usr/kerberos/man.*
692 - /usr/X11R6/man/man.*
693 - /usr/lib/perl5/man/man.*
694 - /usr/share/doc/.*/man/man.*
695 - /usr/lib/.*/man/man.*
697 .. variable:: CPACK_RPM_DEFAULT_USER
698 CPACK_RPM_<compName>_DEFAULT_USER
700 .. versionadded:: 3.6
702 default user ownership of RPM content
707 Value should be user name and not UID.
708 Note that <compName> must be in upper-case.
710 .. variable:: CPACK_RPM_DEFAULT_GROUP
711 CPACK_RPM_<compName>_DEFAULT_GROUP
713 .. versionadded:: 3.6
715 default group ownership of RPM content
720 Value should be group name and not GID.
721 Note that <compName> must be in upper-case.
723 .. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS
724 CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS
726 .. versionadded:: 3.6
728 default permissions used for packaged files
731 * Default : - (system default)
733 Accepted values are lists with ``PERMISSIONS``. Valid permissions
746 Note that <compName> must be in upper-case.
748 .. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS
749 CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS
751 .. versionadded:: 3.6
753 default permissions used for packaged directories
756 * Default : - (system default)
758 Accepted values are lists with PERMISSIONS. Valid permissions
759 are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`.
760 Note that <compName> must be in upper-case.
762 .. variable:: CPACK_RPM_INSTALL_WITH_EXEC
764 .. versionadded:: 3.11
766 force execute permissions on programs and shared libraries
769 * Default : - (system default)
771 Force set owner, group and world execute permissions on programs and shared
772 libraries. This can be used for creating valid rpm packages on systems such
773 as Debian where shared libraries do not have execute permissions set.
777 Programs and shared libraries without execute permissions are ignored during
778 separation of debug symbols from the binary for debuginfo packages.
780 Packaging of Symbolic Links
781 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
783 .. versionadded:: 3.3
785 The CPack RPM generator supports packaging of symbolic links::
787 execute_process(COMMAND ${CMAKE_COMMAND}
788 -E create_symlink <relative_path_location> <symlink_name>)
789 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/<symlink_name>
790 DESTINATION <symlink_location> COMPONENT libraries)
792 Symbolic links will be optimized (paths will be shortened if possible)
793 before being added to the package or if multiple relocation paths are
794 detected, a post install symlink relocation script will be generated.
796 Symbolic links may point to locations that are not packaged by the same
797 package (either a different component or even not packaged at all) but
798 those locations will be treated as if they were a part of the package
799 while determining if symlink should be either created or present in a
800 post install script - depending on relocation paths.
802 .. versionchanged:: 3.6
803 Symbolic links that point to locations outside packaging path produce a
804 warning and are treated as non relocatable permanent symbolic links.
805 Previous versions of CMake produced an error in this case.
807 Currently there are a few limitations though:
809 * For component based packaging component interdependency is not checked
810 when processing symbolic links. Symbolic links pointing to content of
811 a different component are treated the same way as if pointing to location
812 that will not be packaged.
814 * Symbolic links pointing to a location through one or more intermediate
815 symbolic links will not be handled differently - if the intermediate
816 symbolic link(s) is also on a relocatable path, relocating it during
817 package installation may cause initial symbolic link to point to an
820 Packaging of debug information
821 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
823 .. versionadded:: 3.7
825 Debuginfo packages contain debug symbols and sources for debugging packaged
828 Debuginfo RPM packaging has its own set of variables:
830 .. variable:: CPACK_RPM_DEBUGINFO_PACKAGE
831 CPACK_RPM_<component>_DEBUGINFO_PACKAGE
833 Enable generation of debuginfo RPM package(s).
840 Binaries must contain debug symbols before packaging so use either ``Debug``
841 or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
843 Additionally, if :variable:`CPACK_STRIP_FILES` is set, the files will be stripped before
844 they get to the RPM generator, so will not contain debug symbols and
845 a debuginfo package will not get built. Do not use with :variable:`CPACK_STRIP_FILES`.
849 Packages generated from packages without binary files, with binary files but
850 without execute permissions or without debug symbols will cause packaging
853 .. variable:: CPACK_BUILD_SOURCE_DIRS
855 Provides locations of root directories of source files from which binaries
858 * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
863 For CMake project :variable:`CPACK_BUILD_SOURCE_DIRS` is set by default to
864 point to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR` paths.
868 Sources with path prefixes that do not fall under any location provided with
869 :variable:`CPACK_BUILD_SOURCE_DIRS` will not be present in debuginfo package.
871 .. variable:: CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
872 CPACK_RPM_<component>_BUILD_SOURCE_DIRS_PREFIX
874 Prefix of location where sources will be placed during package installation.
876 * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
877 * Default : "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>" and
878 for component packaging "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>-<component>"
882 Each source path prefix is additionally suffixed by ``src_<index>`` where
883 index is index of the path used from :variable:`CPACK_BUILD_SOURCE_DIRS`
884 variable. This produces ``<CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX>/src_<index>``
886 Limitation is that replaced path part must be shorter or of equal
887 length than the length of its replacement. If that is not the case either
888 :variable:`CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX` variable has to be set to
889 a shorter path or source directories must be placed on a longer path.
891 .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS
893 Directories containing sources that should be excluded from debuginfo packages.
896 * Default : "/usr /usr/src /usr/src/debug"
898 Listed paths are owned by other RPM packages and should therefore not be
899 deleted on debuginfo package uninstallation.
901 .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION
903 Paths that should be appended to :variable:`CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS`
909 .. variable:: CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE
911 .. versionadded:: 3.8
913 Create a single debuginfo package even if components packaging is set.
918 When this variable is enabled it produces a single debuginfo package even if
919 component packaging is enabled.
921 When using this feature in combination with components packaging and there is
922 more than one component this variable requires :variable:`CPACK_RPM_MAIN_COMPONENT`
927 If none of the :variable:`CPACK_RPM_<component>_DEBUGINFO_PACKAGE` variables
928 is set then :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is automatically set to
929 ``ON`` when :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` is set.
931 .. variable:: CPACK_RPM_DEBUGINFO_FILE_NAME
932 CPACK_RPM_<component>_DEBUGINFO_FILE_NAME
934 .. versionadded:: 3.9
936 Debuginfo package file name.
939 * Default : rpmbuild tool generated package file name
941 Alternatively provided debuginfo package file name must end with ``.rpm``
942 suffix and should differ from file names of other generated packages.
944 Variable may contain ``@cpack_component@`` placeholder which will be
945 replaced by component name if component packaging is enabled otherwise it
946 deletes the placeholder.
948 Setting the variable to ``RPM-DEFAULT`` may be used to explicitly set
949 filename generation to default.
953 :variable:`CPACK_RPM_FILE_NAME` also supports rpmbuild tool generated package
954 file name - disabled by default but can be enabled by setting the variable to
957 Packaging of sources (SRPM)
958 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
960 .. versionadded:: 3.7
962 SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES`
963 variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable
964 to provide directory containing CMakeLists.txt and source files.
966 For CMake projects SRPM package would be produced by executing::
968 cpack -G RPM --config ./CPackSourceConfig.cmake
972 Produced SRPM package is expected to be built with :manual:`cmake(1)` executable
973 and packaged with :manual:`cpack(1)` executable so CMakeLists.txt has to be
974 located in root source directory and must be able to generate binary rpm
975 packages by executing :option:`cpack -G` command. The two executables as well as
976 rpmbuild must also be present when generating binary rpm packages from the
977 produced SRPM package.
979 Once the SRPM package is generated it can be used to generate binary packages
980 by creating a directory structure for rpm generation and executing rpmbuild
983 mkdir -p build_dir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
984 rpmbuild --define "_topdir <path_to_build_dir>" --rebuild <SRPM_file_name>
986 Generated packages will be located in build_dir/RPMS directory or its sub
991 SRPM package internally uses CPack/RPM generator to generate binary packages
992 so CMakeScripts.txt can decide during the SRPM to binary rpm generation step
993 what content the package(s) should have as well as how they should be packaged
994 (monolithic or components). CMake can decide this for e.g. by reading environment
995 variables set by the package manager before starting the process of generating
996 binary rpm packages. This way a single SRPM package can be used to produce
997 different binary rpm packages on different platforms depending on the platform's
1000 Source RPM packaging has its own set of variables:
1002 .. variable:: CPACK_RPM_PACKAGE_SOURCES
1004 Should the content be packaged as a source rpm (default is binary rpm).
1011 For cmake projects :variable:`CPACK_RPM_PACKAGE_SOURCES` variable is set
1012 to ``OFF`` in CPackConfig.cmake and ``ON`` in CPackSourceConfig.cmake
1015 .. variable:: CPACK_RPM_SOURCE_PKG_BUILD_PARAMS
1017 Additional command-line parameters provided to :manual:`cmake(1)` executable.
1022 .. variable:: CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX
1024 Packaging install prefix that would be provided in :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
1025 variable for producing binary RPM packages.
1030 .. variable:: CPACK_RPM_BUILDREQUIRES
1032 List of source rpm build dependencies.
1037 May be used to set source RPM build dependencies (BuildRequires). Note that
1038 you must enclose the complete build requirements string between quotes, for
1041 set(CPACK_RPM_BUILDREQUIRES "python >= 2.5.0, cmake >= 2.8")
1043 .. variable:: CPACK_RPM_REQUIRES_EXCLUDE_FROM
1045 .. versionadded:: 3.22
1050 May be used to keep the dependency generator from scanning specific files
1051 or directories for dependencies. Note that you can use a regular
1052 expression that matches all of the directories or files, for example::
1054 set(CPACK_RPM_REQUIRES_EXCLUDE_FROM "bin/libqsqloci.*\\.so.*")