Merge topic 'cpack-appimage-user-apprun' into release-4.2

078f28f16b CPack/AppImage: Add support for a custom AppRun file

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11577
This commit is contained in:
Brad King
2026-01-12 14:18:18 +00:00
committed by Kitware Robot
3 changed files with 21 additions and 2 deletions

View File

@@ -40,6 +40,13 @@ application links to and copy them to the install location.
endforeach()
]])
The CPack AppImage generator will generate a default `AppRun`_ based on the
provided ``.desktop`` entry. Alternatively, if a custom ``AppRun`` is
installed, e.g., via the :command:`install` command, it will be used instead
of the generated one.
.. _`AppRun`: https://docs.appimage.org/introduction/software-overview.html#apprun
For Qt-based projects, it is recommended to call
``qt_generate_deploy_app_script()`` or ``qt_generate_deploy_qml_app_script()``
and install the files generated by the script. This will install the

View File

@@ -18,6 +18,7 @@
#include "cmCPackLog.h"
#include "cmELF.h"
#include "cmGeneratedFileStream.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmValue.h"
@@ -182,8 +183,18 @@ int cmCPackAppImageGenerator::PackageFiles()
}
std::string const appRunFile = this->toplevel + "/AppRun";
{
// AppRun script will run our application
if (cmSystemTools::PathExists(appRunFile)) {
// User provided an AppRun file
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
cmStrCat("Found AppRun file: \"", appRunFile, '"')
<< std::endl);
} else {
// Generate a default AppRun script that will run our application
cmCPackLogger(
cmCPackLog::LOG_OUTPUT,
cmStrCat("No AppRun found, generating a default one that will run: \"",
application, '"')
<< std::endl);
cmGeneratedFileStream appRun(appRunFile);
appRun << R"sh(#! /usr/bin/env bash

View File

@@ -7,6 +7,7 @@ CPack: Found Desktop file: "[^"]*/_CPack_Packages/Linux/AppImage/GeneratorTest-1
CPack: Desktop file destination: "[^"]*/_CPack_Packages/Linux/AppImage/GeneratorTest-1\.2\.3-Linux/com\.example\.app\.desktop"
CPack: Icon file: "[^"]*/_CPack_Packages/Linux/AppImage/GeneratorTest-1\.2\.3-Linux/share/icons/hicolor/64x64/apps/ApplicationIcon\.png"
CPack: Icon link destination: "[^"]*/_CPack_Packages/Linux/AppImage/GeneratorTest-1\.2\.3-Linux/ApplicationIcon\.png"
CPack: No AppRun found, generating a default one that will run: "bin/app"
CPack: Running AppImageTool: "[^"]*" "[^"]*/_CPack_Packages/Linux/AppImage/GeneratorTest-1\.2\.3-Linux" "\.\./GeneratorTest-1\.2\.3-Linux\.AppImage" "--runtime-file" "[^"]*"
[^
]*/_CPack_Packages/Linux/AppImage/GeneratorTest-1\.2\.3-Linux should be packaged as \.\./GeneratorTest-1\.2\.3-Linux\.AppImage