appimage.rst 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. CPack AppImage Generator
  2. ------------------------
  3. .. versionadded:: 4.2
  4. The CPack `AppImage`_ generator enables bundling an application into the
  5. AppImage format. It uses ``appimagetool`` to pack the application
  6. and ``patchelf`` to set the application ``RPATH`` to a relative path
  7. based on where the AppImage will be mounted.
  8. .. _`AppImage`: https://appimage.org
  9. The ``appimagetool`` does not scan for libraries dependencies. It only
  10. packs the installed content and checks if the provided ``.desktop`` file
  11. was properly created. For best compatibility, it's recommended to build on
  12. an old LTS distribution and to include any dependencies in the generated file.
  13. The snippet below can be added to your ``CMakeLists.txt`` file.
  14. Replace ``my_application_target`` with your application target.
  15. The example will do a best effort to identify the libraries your
  16. application links to and copy them to the install location.
  17. .. code-block:: cmake
  18. install(CODE [[
  19. file(GET_RUNTIME_DEPENDENCIES
  20. EXECUTABLES $<TARGET_FILE:my_application_target>
  21. RESOLVED_DEPENDENCIES_VAR resolved_deps
  22. )
  23. foreach(dep ${resolved_deps})
  24. # copy the symlink
  25. file(COPY ${dep} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
  26. # Resolve the real path of the dependency (follows symlinks)
  27. file(REAL_PATH ${dep} resolved_dep_path)
  28. # Copy the resolved file to the destination
  29. file(COPY ${resolved_dep_path} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
  30. endforeach()
  31. ]])
  32. The CPack AppImage generator will generate a default `AppRun`_ based on the
  33. provided ``.desktop`` entry. Alternatively, if a custom ``AppRun`` is
  34. installed, e.g., via the :command:`install` command, it will be used instead
  35. of the generated one.
  36. .. _`AppRun`: https://docs.appimage.org/introduction/software-overview.html#apprun
  37. For Qt-based projects, it is recommended to call
  38. ``qt_generate_deploy_app_script()`` or ``qt_generate_deploy_qml_app_script()``
  39. and install the files generated by the script. This will install the
  40. Qt plugins.
  41. You must also set :variable:`CPACK_PACKAGE_ICON` with the same value
  42. listed in the Desktop file.
  43. Variables Specific to CPack AppImage Generator
  44. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  45. .. variable:: CPACK_APPIMAGE_TOOL_EXECUTABLE
  46. Name of the ``appimagetool`` executable. If not given as an absolute path,
  47. logic based on :command:`find_program` will be used internally with this
  48. value to find the executable.
  49. :Default: ``appimagetool``
  50. .. variable:: CPACK_APPIMAGE_PATCHELF_EXECUTABLE
  51. Name of the ``patchelf`` executable. If not given as an absolute path,
  52. logic based on :command:`find_program` will be used internally with this
  53. value to find the executable.
  54. :Default: ``patchelf``
  55. .. variable:: CPACK_APPIMAGE_DESKTOP_FILE
  56. Name of the freedesktop.org desktop file to be installed. If not specified,
  57. the first ``.desktop`` file found in the list of files to be installed will
  58. be used. There must be a valid ``.desktop`` file for the package, and it
  59. must include an ``Icon`` entry that matches :variable:`CPACK_PACKAGE_ICON`
  60. without the file extension. The actual installed location of the icon
  61. should follow the freedesktop.org specification.
  62. :Default: Unset
  63. .. variable:: CPACK_APPIMAGE_UPDATE_INFORMATION
  64. Embed the value of this variable as the update information. See the
  65. ``appimagetool`` source code for the supported values and formats of the
  66. ``--updateinformation`` option. It is highly recommended to have
  67. the ``zsyncmake`` tool installed if using ``zsync`` update information.
  68. :Default: Unset
  69. .. variable:: CPACK_APPIMAGE_GUESS_UPDATE_INFORMATION
  70. When this variable is true, add the ``--guess`` option to the
  71. ``appimagetool`` invocation. This directs the tool to try to guess
  72. appropriate update information based on GitHub or GitLab environment
  73. variables.
  74. :Default: Unset
  75. .. variable:: CPACK_APPIMAGE_COMPRESSOR
  76. Override the ``appimagetool``'s default type of squashfs compression (zstd).
  77. This corresponds to the ``appimagetool --comp`` option.
  78. :Default: Unset
  79. .. variable:: CPACK_APPIMAGE_MKSQUASHFS_OPTIONS
  80. List of arguments to pass through to ``mksquashfs``. Each of these will be
  81. preceded by ``--mksquashfs-opt`` on the ``appimagetool`` command line.
  82. :Default: Unset
  83. .. variable:: CPACK_APPIMAGE_NO_APPSTREAM
  84. If set to true, do not check AppStream metadata. This passes the
  85. ``--no-appstream`` option to ``appimagetool``.
  86. :Default: Unset
  87. .. variable:: CPACK_APPIMAGE_EXCLUDE_FILE
  88. Use the specified file as an exclude file for ``mksquashfs``,
  89. in addition to ``.appimageignore``. This uses the ``--exclude-file``
  90. option to ``appimagetool``.
  91. :Default: Unset
  92. .. variable:: CPACK_APPIMAGE_RUNTIME_FILE
  93. Specify a runtime file to use instead of letting the ``appimagetool``
  94. download a runtime to embed in the generated AppImage.
  95. :Default: Unset
  96. .. variable:: CPACK_APPIMAGE_SIGN
  97. When set to true, sign the generated AppImage with gpg[2].
  98. :variable:`CPACK_APPIMAGE_SIGN_KEY` should also be specified if using this
  99. option.
  100. :Default: Unset
  101. .. variable:: CPACK_APPIMAGE_SIGN_KEY
  102. Key ID to use for gpg[2] signatures when signing is enabled with
  103. :variable:`CPACK_APPIMAGE_SIGN`.
  104. :Default: Unset