The built in (binary) CPack DEB generator (Unix only)
The CPack DEB generator may be used to create DEB package using CPack. The CPack DEB generator is a CPack generator thus it uses the CPACK_XXX variables used by CPack.
The CPack DEB generator should work on any Linux host but it will produce better deb package when Debian specific tools dpkg-xxx are usable on the build system.
The CPack DEB generator has specific features which are controlled by the specifics CPACK_DEBIAN_XXX variables.
CPACK_DEBIAN_<COMPONENT>_XXXX variables may be used in order to have component specific values. Note however that <COMPONENT> refers to the grouping name written in upper case. It may be either a component name or a component GROUP name.
Here are some CPack DEB generator wiki resources that are here for historic reasons and are no longer maintained but may still prove useful:
List of CPack DEB generator specific variables:
Enable component packaging for CPackDEB
If enabled (ON) multiple packages are generated. By default a single package containing files of all components is generated.
Set Package control field (variable is automatically transformed to lower case).
See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
Package file name.
This may be set to DEB-DEFAULT to allow the CPack DEB generator to generate package file name by itself in deb format:
<PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
Alternatively provided package file name must end with either .deb or .ipk suffix.
Note
Preferred setting of this variable is DEB-DEFAULT but for backward compatibility with the CPack DEB generator in CMake prior to version 3.6 this feature is disabled by default.
Note
By using non default filenames duplicate names may occur. Duplicate files get overwritten and it is up to the packager to set the variables in a manner that will prevent such errors.
The Debian package epoch
Optional number that should be incremented when changing versioning schemas or fixing mistakes in the version numbers of older packages.
The Debian package version
This variable may contain only alphanumerics (A-Za-z0-9) and the characters . + - ~ (full stop, plus, hyphen, tilde) and should start with a digit. If CPACK_DEBIAN_PACKAGE_RELEASE is not set then hyphens are not allowed.
Note
For backward compatibility with CMake 3.9 and lower a failed test of this variable’s content is not a hard error when both CPACK_DEBIAN_PACKAGE_RELEASE and CPACK_DEBIAN_PACKAGE_EPOCH variables are not set. An author warning is reported instead.
The Debian package release - Debian revision number.
This is the numbering of the DEB package itself, i.e. the version of the packaging and not the version of the content (see CPACK_DEBIAN_PACKAGE_VERSION). One may change the default value if the previous packaging was buggy and/or you want to put here a fancy Linux distro specific numbering.
The Debian package architecture
Sets the Debian dependencies of this package.
Note
If CPACK_DEBIAN_PACKAGE_SHLIBDEPS or more specifically CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS is set for this component, the discovered dependencies will be appended to CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS instead of CPACK_DEBIAN_PACKAGE_DEPENDS. If CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS is an empty string, only the automatically discovered dependencies will be set for this component.
Example:
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libc6 (< 2.4)")
Sets inter component dependencies if listed with CPACK_COMPONENT_<compName>_DEPENDS variables.
The Debian package maintainer
The Debian package description
If after that description is not set, CPACK_PACKAGE_DESCRIPTION_SUMMARY going to be used if set. Otherwise, CPACK_PACKAGE_DESCRIPTION_SUMMARY will be added as the first line of description as defined in Debian Policy Manual.
Set Section control field e.g. admin, devel, doc, ...
See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
The archive format used for creating the Debian package.
Possible value is:
Note
This variable previously defaulted to the paxr value, but dpkg has never supported that tar format. For backwards compatibility the paxr value will be mapped to gnutar and a deprecation message will be emitted.
The compression used for creating the Debian package.
Possible values are:
Set Priority control field e.g. required, important, standard, optional, extra
See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
The URL of the web site for this package, preferably (when applicable) the site from which the original source can be obtained and any additional upstream documentation or information may be found.
Note
The content of this field is a simple URL without any surrounding characters such as <>.
May be set to ON in order to use dpkg-shlibdeps to generate better package dependency list.
Note
You may need set CMAKE_INSTALL_RPATH to an appropriate value if you use this feature, because if you don’t dpkg-shlibdeps may fail to find your own shared libs. See https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
May be set when invoking cpack in order to trace debug information during the CPack DEB generator run.
Sets the Pre-Depends field of the Debian package. Like Depends, except that it also forces dpkg to complete installation of the packages named before even starting the installation of the package which declares the pre-dependency.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
Sets the Enhances field of the Debian package. Similar to Suggests but works in the opposite direction: declares that a package can enhance the functionality of another package.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
Sets the Breaks field of the Debian package. When a binary package (P) declares that it breaks other packages (B), dpkg will not allow the package (P) which declares Breaks be unpacked unless the packages that will be broken (B) are deconfigured first. As long as the package (P) is configured, the previously deconfigured packages (B) cannot be reconfigured again.
See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
Sets the Conflicts field of the Debian package. When one binary package declares a conflict with another using a Conflicts field, dpkg will not allow them to be unpacked on the system at the same time.
See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
Note
This is a stronger restriction than Breaks, which prevents the broken package from being configured while the breaking package is in the “Unpacked” state but allows both packages to be unpacked at the same time.
Sets the Provides field of the Debian package. A virtual package is one which appears in the Provides control field of another package.
See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
Sets the Replaces field of the Debian package. Packages can declare in their control file that they should overwrite files in certain other packages, or completely replace other packages.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
Sets the Recommends field of the Debian package. Allows packages to declare a strong, but not absolute, dependency on other packages.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
Sets the Suggests field of the Debian package. Allows packages to declare a suggested package install grouping.
See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
Allows to generate shlibs control file automatically. Compatibility is defined by CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY variable value.
Note
Libraries are only considered if they have both library name and version set. This can be done by setting SOVERSION property with set_target_properties() command.
Compatibility policy for auto-generated shlibs control file.
Defines compatibility policy for auto-generated shlibs control file. Possible values: “=”, “>=”
See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps
This variable allow advanced user to add custom script to the control.tar.gz. Typical usage is for conffiles, postinst, postrm, prerm.
Usage:
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
Note
The original permissions of the files will be used in the final package unless the variable CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION is set. In particular, the scripts should have the proper executable flag prior to the generation of the package.
This variable indicates if the Debian policy on control files should be strictly followed.
Usage:
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
Note
This overrides the permissions on the original files, following the rules set by Debian policy https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
Sets the Source field of the binary Debian package. When the binary package name is not the same as the source package name (in particular when several components/binaries are generated from one source) the source from which the binary has been generated should be indicated with the field Source.
See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
Note
This value is not interpreted. It is possible to pass an optional revision number of the referenced source package as well.
Dbgsym packages contain debug symbols for debugging packaged binaries.
Dbgsym packaging has its own set of variables:
Enable generation of dbgsym .ddeb package(s).
Note
Binaries must contain debug symbols before packaging so use either Debug or RelWithDebInfo for CMAKE_BUILD_TYPE variable value.
To communicate UNIX file permissions from the install stage to the CPack DEB generator the “cmake_mode_t” NTFS alternate data stream (ADT) is used.
When a filesystem without ADT support is used only owner read/write permissions can be preserved.
The environment variable SOURCE_DATE_EPOCH may be set to a UNIX timestamp, defined as the number of seconds, excluding leap seconds, since 01 Jan 1970 00:00:00 UTC. If set, the CPack DEB generator will use its value for timestamps in the package.