CPack: Add appimagetool environment options

The following options were added to complement what is possible
to control of appimagetool:
 - CPACK_APPIMAGE_ARCH
 - CPACK_APPIMAGE_SIGN_PASSPHRASE
 - CPACK_APPIMAGE_VERSION

Issue: #27556
This commit is contained in:
Daniel Nicoletti authored and Brad King committed 2026-11-02 16:23:36 -05:00
1 parent d9f1f4c346
commit 824564c7f0
3 files changed
+84

No files matched your search

+39
View File
@@ -58,6 +58,14 @@ Qt plugins.
You must also set :variable:`CPACK_PACKAGE_ICON` with the same value
listed in the Desktop file.
.. note::
The ``appimagetool`` uses environment variables to define its behavior.
These variables are exposed here for convenience, but it is also possible
to pass environment variables to it by setting the environment of a
:ref:`Package Preset` in a ``CMakePresets.json`` file, see
:manual:`cmake-presets(7)`.
Variables Specific to CPack AppImage Generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -166,3 +174,34 @@ Variables Specific to CPack AppImage Generator
:variable:`CPACK_APPIMAGE_SIGN`.
:Default: Unset
.. variable:: CPACK_APPIMAGE_SIGN_PASSPHRASE
.. versionadded:: 4.6
If the :variable:`CPACK_APPIMAGE_SIGN_KEY` is encrypted and requires a
passphrase to be used for signing (and, for some reason, GnuPG cannot be
used interactively, e.g., in a CI environment), this environment variable
can be used to safely pass the key.
:Default: Unset
.. variable:: CPACK_APPIMAGE_ARCH
.. versionadded:: 4.6
Needs to be set whenever :variable:`CMAKE_SYSTEM_PROCESSOR` is not transformed
to a proper architecture and ``appimagetool`` cannot automatically determine the
architecture of the binaries inside the AppDir to choose a suitable runtime
(e.g., when binaries for multiple architectures or just shell scripts are
contained in there).
:Default: CMAKE_SYSTEM_PROCESSOR
.. variable:: CPACK_APPIMAGE_VERSION
.. versionadded:: 4.6
This value will be inserted by appimagetool into the root desktop file.
:Default: :variable:`CPACK_PACKAGE_VERSION`
+7
View File
@@ -0,0 +1,7 @@
cpack-appimage
--------------
* The :cpack_gen:`CPack AppImage Generator` gained
:variable:`CPACK_APPIMAGE_VERSION`,
:variable:`CPACK_APPIMAGE_ARCH`, and
:variable:`CPACK_APPIMAGE_SIGN_PASSPHRASE` options.
+38
View File
@@ -58,6 +58,30 @@ int cmCPackAppImageGenerator::InitializeInternal()
return 0;
}
if (cmValue packageVersion = this->GetOption("CPACK_PACKAGE_VERSION")) {
this->SetOptionIfNotSet("CPACK_APPIMAGE_VERSION", packageVersion);
}
if (!this->IsSet("CPACK_APPIMAGE_ARCH")) {
if (cmValue systemProcessor = this->GetOption("CMAKE_SYSTEM_PROCESSOR")) {
if (systemProcessor == "x86_64" || systemProcessor == "amd64") {
this->SetOption("CPACK_APPIMAGE_ARCH", "x86_64");
} else if (systemProcessor == "i386" || systemProcessor == "i686" ||
systemProcessor == "x86") {
this->SetOption("CPACK_APPIMAGE_ARCH", "i686");
} else if (systemProcessor == "aarch64" || systemProcessor == "arm64") {
this->SetOption("CPACK_APPIMAGE_ARCH", "aarch64");
} else if (cmSystemTools::StringStartsWith(systemProcessor, "arm")) {
this->SetOption("CPACK_APPIMAGE_ARCH", "armhf");
} else {
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"Could not transform CMAKE_SYSTEM_PROCESSOR, counting "
"on appimagetool architecture detection."
<< std::endl);
}
}
}
return Superclass::InitializeInternal();
}
@@ -298,6 +322,13 @@ int cmCPackAppImageGenerator::PackageFiles()
}
};
auto addEnvOption = [this](std::string const& op, std::string envName) {
auto opt = this->GetOption(op);
if (opt) {
cmSystemTools::PutEnv(cmStrCat(envName, '=', *opt));
}
};
addOption("CPACK_APPIMAGE_UPDATE_INFORMATION", "--updateinformation");
addOptionFlag("CPACK_APPIMAGE_GUESS_UPDATE_INFORMATION", "--guess");
@@ -316,6 +347,13 @@ int cmCPackAppImageGenerator::PackageFiles()
addOption("CPACK_APPIMAGE_SIGN_KEY", "--sign-key");
addEnvOption("CPACK_APPIMAGE_ARCH", "ARCH");
addEnvOption("CPACK_APPIMAGE_SIGN_PASSPHRASE",
"APPIMAGETOOL_SIGN_PASSPHRASE");
addEnvOption("CPACK_APPIMAGE_VERSION", "VERSION");
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"Running AppImageTool: "
<< cmSystemTools::PrintSingleCommand(command) << std::endl);