CPack DEB Generator¶
The built in (binary) CPack DEB generator (Unix only)
Variables specific to CPack Debian (DEB) generator¶
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:
https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/Configuration
https://gitlab.kitware.com/cmake/community/-/wikis/doc/cpack/PackageGenerators#deb-unix-only
List of CPack DEB generator specific variables:
- CPACK_DEB_COMPONENT_INSTALL¶
Enable component packaging for CPackDEB
- Mandatory:
No
- Default:
OFF
If enabled (
ON) multiple packages are generated. By default a single package containing files of all components is generated.
- CPACK_DEBIAN_PACKAGE_NAME¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME¶
Set Package control field (variable is automatically transformed to lower case).
- Mandatory:
Yes
- Default:
CPACK_PACKAGE_NAMEfor non-component based installationsCPACK_DEBIAN_PACKAGE_NAMEsuffixed with-<COMPONENT>for component-based installations.
在 3.5 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAMEvariables.See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-source
- CPACK_DEBIAN_FILE_NAME¶
- CPACK_DEBIAN_<COMPONENT>_FILE_NAME¶
在 3.6 版被加入.
Package file name.
- Mandatory:
Yes
- Default:
<CPACK_PACKAGE_FILE_NAME>[-<component>].deb
This may be set to:
DEB-DEFAULTTell CPack to automatically generate the package file name in deb format:
<PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
This setting recommended as the preferred behavior, but for backward compatibility with the CPack DEB generator in CMake prior to version 3.6, this is not the default. Without this, 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.
<file-name>[.deb]Use the given file name.
在 3.29 版的變更: The
.debsuffix will be automatically added if the file name does not end in.debor.ipk. Previously the suffix was required.<file-name>.ipk在 3.10 版被加入.
Use the given file name. The
.ipksuffix is used by the OPKG packaging system.
- CPACK_DEBIAN_PACKAGE_EPOCH¶
在 3.10 版被加入.
The Debian package epoch
- Mandatory:
No
- Default:
None
Optional number that should be incremented when changing versioning schemas or fixing mistakes in the version numbers of older packages.
- CPACK_DEBIAN_PACKAGE_VERSION¶
The Debian package version
- Mandatory:
Yes
- Default:
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_RELEASEis not set then hyphens are not allowed.備註
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_RELEASEandCPACK_DEBIAN_PACKAGE_EPOCHvariables are not set. An author warning is reported instead.
- CPACK_DEBIAN_PACKAGE_RELEASE¶
在 3.6 版被加入.
The Debian package release - Debian revision number.
- Mandatory:
No
- Default:
None
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.
- CPACK_DEBIAN_PACKAGE_ARCHITECTURE¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE¶
The Debian package architecture
- Mandatory:
Yes
- Default:
Output of
dpkg --print-architecture(ori386ifdpkgis not found)
在 3.6 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTUREvariables.
- CPACK_DEBIAN_PACKAGE_DEPENDS¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS¶
Sets the Debian dependencies of this package.
- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_DEPENDSfor component-based installations.
在 3.3 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDSvariables.備註
If
CPACK_DEBIAN_PACKAGE_SHLIBDEPSor more specificallyCPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPSis set for this component, the discovered dependencies will be appended toCPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDSinstead ofCPACK_DEBIAN_PACKAGE_DEPENDS. IfCPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDSis an empty string, only the automatically discovered dependencies will be set for this component.在 3.31 版的變更: The variable is always expanded as a list. Before it was expanded only if used in cooperation with
CPACK_DEB_COMPONENT_INSTALL,CPACK_DEBIAN_PACKAGE_SHLIBDEPSorCPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS. This meant that if a component had no shared libraries discovered (e.g. a package composed only of scripts) you had to join the list by yourself to obtain a valid Depends field.Example:
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libc6 (< 2.4)") list(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS cmake)
- CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS¶
在 3.6 版被加入.
Sets inter-component dependencies if listed with
CPACK_COMPONENT_<compName>_DEPENDSvariables.- Mandatory:
No
- Default:
None
- CPACK_DEBIAN_PACKAGE_MAINTAINER¶
The Debian package maintainer
- Mandatory:
Yes
- Default:
CPACK_PACKAGE_CONTACT
- CPACK_DEBIAN_PACKAGE_DESCRIPTION¶
- CPACK_DEBIAN_<COMPONENT>_DESCRIPTION¶
The Debian package description
- Mandatory:
Yes
- Default:
CPACK_DEBIAN_<COMPONENT>_DESCRIPTION(component based installers only) if set, orCPACK_DEBIAN_PACKAGE_DESCRIPTIONif set, orCPACK_COMPONENT_<compName>_DESCRIPTION(component based installers only) if set, orCPACK_PACKAGE_DESCRIPTIONif set, orcontent of the file specified in
CPACK_PACKAGE_DESCRIPTION_FILEif set
If after that description is not set,
CPACK_PACKAGE_DESCRIPTION_SUMMARYgoing to be used if set. Otherwise,CPACK_PACKAGE_DESCRIPTION_SUMMARYwill be added as the first line of description as defined in Debian Policy Manual.在 3.3 版被加入: Per-component
CPACK_COMPONENT_<compName>_DESCRIPTIONvariables.在 3.16 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_DESCRIPTIONvariables.在 3.16 版被加入: The
CPACK_PACKAGE_DESCRIPTION_FILEvariable.
- CPACK_DEBIAN_PACKAGE_SECTION¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION¶
Set Section control field e.g. admin, devel, doc, ...
- Mandatory:
Yes
- Default:
devel
在 3.5 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTIONvariables.See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
- CPACK_DEBIAN_ARCHIVE_TYPE¶
在 3.7 版被加入.
在 3.14 版之後被棄用.
The archive format used for creating the Debian package.
- Mandatory:
Yes
- Default:
gnutar
Possible value is:
gnutar備註
This variable previously defaulted to the
paxrvalue, butdpkghas never supported that tar format. For backwards compatibility thepaxrvalue will be mapped tognutarand a deprecation message will be emitted.
- CPACK_DEBIAN_COMPRESSION_TYPE¶
在 3.1 版被加入.
The compression used for creating the Debian package.
- Mandatory:
Yes
- Default:
gzip
Possible values are:
lzmaLempel–Ziv–Markov chain algorithm
xzXZ Utils compression
bzip2bzip2 Burrows–Wheeler algorithm
gzipGNU Gzip compression
zstd在 3.22 版被加入.
Zstandard compression
- CPACK_DEBIAN_PACKAGE_PRIORITY¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY¶
Set Priority control field e.g. required, important, standard, optional, extra
- Mandatory:
Yes
- Default:
optional
在 3.5 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITYvariables.See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
- CPACK_DEBIAN_PACKAGE_HOMEPAGE¶
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.
- Mandatory:
No
- Default:
在 3.12 版被加入: The
CMAKE_PROJECT_HOMEPAGE_URLvariable.備註
The content of this field is a simple URL without any surrounding characters such as <>.
- CPACK_DEBIAN_PACKAGE_SHLIBDEPS¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS¶
May be set to ON in order to use
dpkg-shlibdepsto generate better package dependency list.- Mandatory:
No
- Default:
CPACK_DEBIAN_PACKAGE_SHLIBDEPSif set orOFF
備註
You may need set
CMAKE_INSTALL_RPATHto an appropriate value if you use this feature, because if you don'tdpkg-shlibdepsmay fail to find your own shared libs. See https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling備註
You can also set
CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRSto an appropriate value if you use this feature, in order to pleasedpkg-shlibdeps. However, you should only do this for private shared libraries that could not get resolved otherwise.在 3.3 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPSvariables.在 3.6 版被加入: Correct handling of
$ORIGINinCMAKE_INSTALL_RPATH.
- CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS¶
在 3.20 版被加入.
May be set to a list of directories that will be given to
dpkg-shlibdepsvia its-loption. These will be searched bydpkg-shlibdepsin order to find private shared library dependencies.- Mandatory:
No
- Default:
None
備註
You should prefer to set
CMAKE_INSTALL_RPATHto an appropriate value if you usedpkg-shlibdeps. The current option is really only needed for private shared library dependencies.
- CPACK_DEBIAN_PACKAGE_DEBUG¶
May be set when invoking cpack in order to trace debug information during the CPack DEB generator run.
- Mandatory:
No
- Default:
None
- CPACK_DEBIAN_PACKAGE_PREDEPENDS¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDS¶
Sets the
Pre-Dependsfield of the Debian package. LikeDepends, except that it also forcesdpkgto complete installation of the packages named before even starting the installation of the package which declares the pre-dependency.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_PREDEPENDSfor component-based installations.
在 3.4 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDSvariables.See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
- CPACK_DEBIAN_PACKAGE_ENHANCES¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCES¶
Sets the
Enhancesfield of the Debian package. Similar toSuggestsbut works in the opposite direction: declares that a package can enhance the functionality of another package.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_ENHANCESfor component-based installations.
在 3.4 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCESvariables.See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
- CPACK_DEBIAN_PACKAGE_BREAKS¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS¶
Sets the
Breaksfield of the Debian package. When a binary package (P) declares that it breaks other packages (B),dpkgwill not allow the package (P) which declaresBreaksbe 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.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_BREAKSfor component-based installations.
在 3.4 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKSvariables.See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
- CPACK_DEBIAN_PACKAGE_CONFLICTS¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS¶
Sets the
Conflictsfield of the Debian package. When one binary package declares a conflict with another using aConflictsfield,dpkgwill not allow them to be unpacked on the system at the same time.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_CONFLICTSfor component-based installations.
在 3.4 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTSvariables.See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
備註
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.
- CPACK_DEBIAN_PACKAGE_PROVIDES¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDES¶
Sets the
Providesfield of the Debian package. A virtual package is one which appears in theProvidescontrol field of another package.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_PROVIDESfor component-based installations.
在 3.4 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDESvariables.See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
- CPACK_DEBIAN_PACKAGE_REPLACES¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES¶
Sets the
Replacesfield 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.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_REPLACESfor component-based installations.
在 3.4 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACESvariables.See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
- CPACK_DEBIAN_PACKAGE_RECOMMENDS¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS¶
Sets the
Recommendsfield of the Debian package. Allows packages to declare a strong, but not absolute, dependency on other packages.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_RECOMMENDSfor component-based installations.
在 3.4 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDSvariables.See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
- CPACK_DEBIAN_PACKAGE_SUGGESTS¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS¶
Sets the
Suggestsfield of the Debian package. Allows packages to declare a suggested package install grouping.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_SUGGESTSfor component-based installations.
在 3.4 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTSvariables.See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
- CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS¶
在 3.6 版被加入.
- Mandatory:
No
- Default:
OFF
Allows to generate shlibs control file automatically. Compatibility is defined by
CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICYvariable value.備註
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.
- CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY¶
在 3.6 版被加入.
Compatibility policy for auto-generated shlibs control file.
- Mandatory:
No
- Default:
=
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
- CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA¶
This variable allow advanced user to add custom script to the control.tar.gz. Typical usage is for conffiles, postinst, postrm, prerm.
- Mandatory:
No
- Default:
None
Usage:
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
在 3.4 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRAvariables.
- CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_STRICT_PERMISSION¶
在 3.4 版被加入.
This variable indicates if the Debian policy on control files should be strictly followed.
- Mandatory:
No
- Default:
FALSE
Usage:
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
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
備註
The original permissions of the files will be used in the final package unless this variable is set to
TRUE. In particular, the scripts should have the proper executable flag prior to the generation of the package.
- CPACK_DEBIAN_PACKAGE_SOURCE¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_SOURCE¶
在 3.5 版被加入.
Sets the
Sourcefield 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 fieldSource.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_SOURCEfor component-based installations.
See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-source
備註
This value is not interpreted. It is possible to pass an optional revision number of the referenced source package as well.
- CPACK_DEBIAN_PACKAGE_MULTIARCH¶
- CPACK_DEBIAN_<COMPONENT>_PACKAGE_MULTIARCH¶
Sets the
Multi-Archfield of the Debian package. Packages can declare in their control file how they should handle situations, where packages for different architectures are being installed on the same machine.- Mandatory:
No
- Default:
An empty string for non-component based installations
CPACK_DEBIAN_PACKAGE_MULTIARCHfor component-based installations.
在 3.31 版被加入: Per-component
CPACK_DEBIAN_<COMPONENT>_PACKAGE_MULTIARCHvariables.See https://wiki.debian.org/MultiArch/Hints
備註
This value is validated. It must be one of the following values:
same,foreign,allowed.
Packaging of debug information¶
在 3.13 版被加入.
Dbgsym packages contain debug symbols for debugging packaged binaries.
Dbgsym packaging has its own set of variables:
- CPACK_DEBIAN_DEBUGINFO_PACKAGE¶
- CPACK_DEBIAN_<component>_DEBUGINFO_PACKAGE¶
Enable generation of dbgsym .ddeb package(s).
- Mandatory:
No
- Default:
OFF
備註
Setting this also strips the ELF files in the generated non-dbgsym package, which results in debuginfo only being available in the dbgsym package.
備註
Binaries must contain debug symbols before packaging so use either Debug
or RelWithDebInfo for CMAKE_BUILD_TYPE variable value.
Additionally, if CPACK_STRIP_FILES is set, the files will be stripped before
they get to the DEB generator, so will not contain debug symbols and
a dbgsym package will not get built. Do not use with CPACK_STRIP_FILES.
Building Debian packages on Windows¶
在 3.10 版被加入.
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.
Reproducible packages¶
在 3.13 版被加入.
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.