Introduction

Qt is a framework for C++ development. To create an AppImage from a Qt project we will use linuxdeploy and its qt plugin.

Building an AppImage for a Qt project is not different from building it for a regular C++ a application. Therefore we recommend you to consult the instruction for C/C++ applications first.

linuxdeploy-plugin-qt

Once you have your AppDir created, you can use the linuxdeploy-plugin-qt to include the required Qt plugins and QML dependencies if any.

linuxdeploy --appdir=AppDir --desktop-file=<path to your app desktop file> --plugin qt --output appimage

Build pipeline

Build dependencies are specified at conanfile.txt as follows

[requires]
zlib/1.2.11@conan/stable
libpng/1.6.36@bincrafters/stable
qt/5.12.3@appimage-conan-community/stable

[build_requires]
cmake_installer/3.14.3@conan/stable
linuxdeploy/continuous@appimage-conan-community/stable
linuxdeploy-plugin-qt/continuous@appimage-conan-community/stable
linuxdeploy-plugin-appimage/continuous@appimage-conan-community/stable

[options]
qt:qtdeclarative=True
qt:qtquickcontrols=True
qt:qtquickcontrols2=True
qt:qtx11extras=True

[generators]
virtualrunenv
cmake_paths

Notice that Qt modules must be enable explicitly, check the conan-qt documentation for more details

And .gitlab-ci.yml will end like this:

## AppImage
build:AppImage:
  image: conanio/gcc48:1.14.3
  stage: build
  before_script:
    # Install additional dependencies
    - sudo apt update -y
    - sudo apt install libfontconfig1-dev -y
    # Upgrade Conan version
    - sudo pip install --upgrade conan
    # Automatic detection of your arch, compiler, etc.
    - conan user
    # Add AppImage specific repositories
    - conan remote add appimage-conan-community https://api.bintray.com/conan/appimage-conan-community/public-conan --insert=0
    # Prepare build environment
    - conan install . --build missing

  script:
    # enter virtual env
    - . activate_run.sh
    # Configure project
    - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PROJECT_qt-appimage-template_INCLUDE=$PWD/conan_paths.cmake .
    # Create AppDir
    - DESTDIR=AppDir make install
    # run linuxdeploy with qt plugin
    - export QML_SOURCES_PATHS=$PWD
    - linuxdeploy --appdir=AppDir --desktop-file=AppDir/usr/share/applications/QtQuickControls2Application.desktop --plugin qt --output appimage
    # exit virtual env    
    - . deactivate_run.sh

  artifacts:
    paths:
      - Qt_AppImage_Template*.AppImage*

Results

Once the build is done you can find the resulting file in the jobs artifacts view.

You may also want to get a reference to the latest produced artifact in order to show it in your applications site downloads page or in the pling product page. Use the following snippet to get your own download link address:

"https://www.opencode.net/<user name>/<project name>/-/jobs/artifacts/master/raw/<artifact file path>?job=<job name>"

Be sure to replace the user name, project name, artifact file path, and job name.