File: appimage.rst

package info (click to toggle)
cmake 4.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,336 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (155 lines) | stat: -rw-r--r-- 5,319 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
CPack AppImage Generator
------------------------

.. versionadded:: 4.2

The CPack `AppImage`_ generator enables bundling an application into the
AppImage format. It uses ``appimagetool`` to pack the application
and ``patchelf`` to set the application ``RPATH`` to a relative path
based on where the AppImage will be mounted.

.. _`AppImage`: https://appimage.org

The ``appimagetool`` does not scan for libraries dependencies.  It only
packs the installed content and checks if the provided ``.desktop`` file
was properly created.  For best compatibility, it's recommended to build on
an old LTS distribution and to include any dependencies in the generated file.

The snippet below can be added to your ``CMakeLists.txt`` file.
Replace ``my_application_target`` with your application target.
The example will do a best effort to identify the libraries your
application links to and copy them to the install location.

.. code-block:: cmake

  install(CODE [[
      file(GET_RUNTIME_DEPENDENCIES
          EXECUTABLES $<TARGET_FILE:my_application_target>
          RESOLVED_DEPENDENCIES_VAR resolved_deps
      )

      foreach(dep ${resolved_deps})
          # copy the symlink
          file(COPY ${dep} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)

          # Resolve the real path of the dependency (follows symlinks)
          file(REAL_PATH ${dep} resolved_dep_path)

          # Copy the resolved file to the destination
          file(COPY ${resolved_dep_path} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
      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
Qt plugins.

You must also set :variable:`CPACK_PACKAGE_ICON` with the same value
listed in the Desktop file.

Variables Specific to CPack AppImage Generator
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. variable:: CPACK_APPIMAGE_TOOL_EXECUTABLE

  Name of the ``appimagetool`` executable.  If not given as an absolute path,
  logic based on :command:`find_program` will be used internally with this
  value to find the executable.

  :Default: ``appimagetool``

.. variable:: CPACK_APPIMAGE_PATCHELF_EXECUTABLE

  Name of the ``patchelf`` executable.  If not given as an absolute path,
  logic based on :command:`find_program` will be used internally with this
  value to find the executable.

  :Default: ``patchelf``

.. variable:: CPACK_APPIMAGE_DESKTOP_FILE

  Name of the freedesktop.org desktop file to be installed.  If not specified,
  the first ``.desktop`` file found in the list of files to be installed will
  be used.  There must be a valid ``.desktop`` file for the package, and it
  must include an ``Icon`` entry that matches :variable:`CPACK_PACKAGE_ICON`
  without the file extension.  The actual installed location of the icon
  should follow the freedesktop.org specification.

  :Default: Unset

.. variable:: CPACK_APPIMAGE_UPDATE_INFORMATION

  Embed the value of this variable as the update information.  See the
  ``appimagetool`` source code for the supported values and formats of the
  ``--updateinformation`` option.  It is highly recommended to have
  the ``zsyncmake`` tool installed if using ``zsync`` update information.

  :Default: Unset

.. variable:: CPACK_APPIMAGE_GUESS_UPDATE_INFORMATION

  When this variable is true, add the ``--guess`` option to the
  ``appimagetool`` invocation.  This directs the tool to try to guess
  appropriate update information based on GitHub or GitLab environment
  variables.

  :Default: Unset

.. variable:: CPACK_APPIMAGE_COMPRESSOR

  Override the ``appimagetool``'s default type of squashfs compression (zstd).
  This corresponds to the ``appimagetool --comp`` option.

  :Default: Unset

.. variable:: CPACK_APPIMAGE_MKSQUASHFS_OPTIONS

  List of arguments to pass through to ``mksquashfs``.  Each of these will be
  preceded by ``--mksquashfs-opt`` on the ``appimagetool`` command line.

  :Default: Unset

.. variable:: CPACK_APPIMAGE_NO_APPSTREAM

  If set to true, do not check AppStream metadata.  This passes the
  ``--no-appstream`` option to ``appimagetool``.

  :Default: Unset

.. variable:: CPACK_APPIMAGE_EXCLUDE_FILE

  Use the specified file as an exclude file for ``mksquashfs``,
  in addition to ``.appimageignore``.  This uses the ``--exclude-file``
  option to ``appimagetool``.

  :Default: Unset

.. variable:: CPACK_APPIMAGE_RUNTIME_FILE

  Specify a runtime file to use instead of letting the ``appimagetool``
  download a runtime to embed in the generated AppImage.

  :Default: Unset

.. variable:: CPACK_APPIMAGE_SIGN

  When set to true, sign the generated AppImage with gpg[2].
  :variable:`CPACK_APPIMAGE_SIGN_KEY` should also be specified if using this
  option.

  :Default: Unset

.. variable:: CPACK_APPIMAGE_SIGN_KEY

  Key ID to use for gpg[2] signatures when signing is enabled with
  :variable:`CPACK_APPIMAGE_SIGN`.

  :Default: Unset