### Install linuxdeployqt Source: https://github.com/probonopd/linuxdeployqt/blob/master/BUILDING.md Install the compiled binary into the Qt installation directory. ```bash sudo make install ``` -------------------------------- ### Install with Make Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Use INSTALL_ROOT to install files into the application directory. ```bash - make INSTALL_ROOT=appdir install ; find appdir/ ``` -------------------------------- ### Install Executable Source: https://github.com/probonopd/linuxdeployqt/blob/master/tools/linuxdeployqt/CMakeLists.txt Installs the 'linuxdeployqt' executable to the runtime destination directory. ```cmake install(TARGETS linuxdeployqt RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR}) ``` -------------------------------- ### Install with Meson and Ninja Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Configure and install projects using meson and ninja. ```bash - meson --prefix /usr build - ninja -C build - DESTDIR=./appdir ninja -C build install ; find build/appdir ``` -------------------------------- ### Install with Autotools Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Configure and install projects using autotools with DESTDIR. ```bash - ./configure --prefix=/usr - make -j$(nproc) - make install DESTDIR=$(readlink -f appdir) ; find appdir/ ``` -------------------------------- ### Build linuxdeployqt from source Source: https://github.com/probonopd/linuxdeployqt/blob/master/BUILDING.md Install required build dependencies and compile the project using qmake and make. ```bash sudo apt-get -y install git g++ libgl1-mesa-dev git clone https://github.com/probonopd/linuxdeployqt.git # Then build in Qt Creator, or use export PATH=$(readlink -f /tmp/.mount_QtCreator-*-x86_64/*/gcc_64/bin/):$PATH cd linuxdeployqt qmake make ``` -------------------------------- ### Select Qt Installation Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Specify the qmake path or library infix to ensure the correct Qt version is used for deployment. ```bash # Use a specific qmake to locate Qt linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -qmake=/opt/Qt/5.15.2/gcc_64/bin/qmake ``` ```bash # For Ubuntu system Qt (distribution packages) linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -qmake=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake ``` ```bash # Handle Qt built with custom library infix # If Qt was configured with: configure -qtlibinfix "Custom" linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -qtlibinfix=Custom ``` -------------------------------- ### Complete Real-World Example: Building a Qt AppImage Source: https://context7.com/probonopd/linuxdeployqt/llms.txt This comprehensive bash script outlines the steps to create an AppImage for a Qt application. It includes cloning the repository, configuring and building the Qt app, setting up the AppDir structure, copying the binary, creating a desktop file and icon, downloading linuxdeployqt, and finally deploying the application into an AppImage with QML support. ```bash #!/bin/bash set -e APP_NAME="MyQtApp" VERSION="1.0.0" # Clone and build git clone https://github.com/example/myqtapp.git cd myqtapp # Configure and build qmake CONFIG+=release make -j$(nproc) # Create AppDir structure mkdir -p ${APP_NAME}.AppDir/usr/{bin,lib,share/{applications,icons/hicolor/256x256/apps}} # Copy binary cp bin/myqtapp ${APP_NAME}.AppDir/usr/bin/ # Create desktop file cat > ${APP_NAME}.AppDir/usr/share/applications/myqtapp.desktop << EOF [Desktop Entry] Type=Application Name=My Qt Application GenericName=Qt Demo Comment=A demonstration Qt application Exec=myqtapp Icon=myqtapp Categories=Utility;Development; Keywords=qt;demo; EOF # Copy icon cp resources/icons/myqtapp.png ${APP_NAME}.AppDir/usr/share/icons/hicolor/256x256/apps/ # Download linuxdeployqt if not present if [ ! -f linuxdeployqt-continuous-x86_64.AppImage ]; then wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" chmod a+x linuxdeployqt-continuous-x86_64.AppImage fi # Deploy with QML support export VERSION ./linuxdeployqt-continuous-x86_64.AppImage \ ${APP_NAME}.AppDir/usr/share/applications/myqtapp.desktop \ -qmldir=./qml \ -extra-plugins=iconengines,imageformats \ -verbose=2 \ -appimage # Result: MyQtApp-1.0.0-x86_64.AppImage echo "Created: ${APP_NAME}-${VERSION}-x86_64.AppImage" ls -lh *.AppImage ``` -------------------------------- ### Bundle LibrePCB with linuxdeployqt Source: https://github.com/probonopd/linuxdeployqt/wiki/Home This example shows how to compile LibrePCB, prepare its AppDir, and use linuxdeployqt to create an AppImage. No wrapper script, LD_LIBRARY_PATH, or qt.conf is used. ```bash # Compile LibrePCB as usual git clone --recursive https://github.com/LibrePCB/LibrePCB.git && cd LibrePCB qmake -r ../librepcb.pro sudo apt-get install libglu1-mesa-dev openssl zlib1g zlib1g-dev make -j 8 # Copy into AppDir FHS-like stucture mkdir -p LibrePCB.AppDir/usr cp -r generated/unix LibrePCB.AppDir/usr/bin cp -r generated/{lib,share} LibrePCB.AppDir/usr/ # Get and run linuxdeployqt wget -c https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage chmod a+x linuxdeployqt-continuous-x86_64.AppImage # Create AppImage using linuxdeployqt ./linuxdeployqt-continuous-x86_64.AppImage ./LibrePCB.AppDir/usr/bin/librepcb ( cd LibrePCB.AppDir/ ; cp ./usr/share/applications/librepcb.desktop . ) ( cd LibrePCB.AppDir/ ; cp ./usr/share/pixmaps/librepcb.svg . ) export VERSION=$(git rev-list --count HEAD).$(git describe --tags | cut -d - -f 3) ./linuxdeployqt-continuous-x86_64.AppImage ./LibrePCB.AppDir/usr/bin/librepcb -appimage # Success! ls -lh LibrePCB*AppImage # -rwxr-xr-x 1 me me 31M Feb 19 15:34 LibrePCB-864.gf0d32a2-x86_64.AppImage ``` -------------------------------- ### Install with CMake Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Configure and install projects using CMake with DESTDIR. ```bash - cmake . -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr - make -j$(nproc) - make DESTDIR=appdir -j$(nproc) install ; find appdir/ ``` -------------------------------- ### Desktop Entry Configuration Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Example content for a .desktop file used by linuxdeployqt. ```ini [Desktop Entry] Type=Application Name=Amazing Qt App Comment=The best Qt Application Ever Exec=your_app Icon=your_app Categories=Office; ``` -------------------------------- ### Build and install patchelf Source: https://github.com/probonopd/linuxdeployqt/blob/master/BUILDING.md Download, configure, and compile the patchelf utility from source. ```bash wget https://nixos.org/releases/patchelf/patchelf-0.9/patchelf-0.9.tar.bz2 tar xf patchelf-0.9.tar.bz2 ( cd patchelf-0.9/ && ./configure && make && sudo make install ) ``` -------------------------------- ### Bundle RedTimer with linuxdeployqt Source: https://github.com/probonopd/linuxdeployqt/wiki/Home This example demonstrates compiling RedTimer, setting up its AppDir, and using linuxdeployqt to generate an AppImage. It highlights manual resource copying and the absence of wrapper scripts or environment variable modifications. ```bash # Compile as usual git clone https://github.com/fathomssen/redtimer.git cd redtimer git submodule update --init qmake -r make -j 4 # Create AppDir and start populating mkdir -p appdir/usr/bin cp gui/redtimer appdir/usr/bin/ cp ./.travis/redtimer.desktop appdir/ cp gui/icons/clock_red.svg appdir/redtimer.svg # Deploy to AppDir wget -c https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage chmod a+x linuxdeployqt-continuous-x86_64.AppImage ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/bin/redtimer -qmldir=gui/ # Generate AppImage ./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/bin/redtimer -qmldir=gui/ -appimage # Result is ./RedTimer-x86_64.AppImage ``` -------------------------------- ### Download and install appimagetool Source: https://github.com/probonopd/linuxdeployqt/blob/master/BUILDING.md Download the appimagetool binary and set executable permissions in the system path. ```bash sudo wget -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" -O /usr/local/bin/appimagetool sudo chmod a+x /usr/local/bin/appimagetool ``` -------------------------------- ### qmake Build Integration Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Integrate with qmake projects by utilizing INSTALL_ROOT and defining install targets in the .pro file. ```bash # Build the project qmake CONFIG+=release make -j$(nproc) ``` ```bash # Install to AppDir using INSTALL_ROOT make INSTALL_ROOT=$(pwd)/AppDir install ``` ```bash # Note: Your .pro file needs install targets like: # target.path = /usr/bin # desktop.path = /usr/share/applications # desktop.files = myapp.desktop # icon.path = /usr/share/icons/hicolor/256x256/apps # icon.files = myapp.png # INSTALLS += target desktop icon ``` ```bash # Deploy and create AppImage linuxdeployqt AppDir/usr/share/applications/myapp.desktop -appimage ``` -------------------------------- ### Remove use_qt_paths Configuration Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Remove CONFIG+=use_qt_paths to prevent incorrect installation paths. ```bash qmake PREFIX=/usr CONFIG+=use_qt_paths ``` -------------------------------- ### Find and Configure Qt Source: https://github.com/probonopd/linuxdeployqt/blob/master/tools/linuxdeployqt/CMakeLists.txt Locates the necessary Qt components (Core) and links them to the target executable. Requires Qt6 or Qt5 to be installed. ```cmake find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core) ``` -------------------------------- ### GitHub Actions Workflow for AppImage Source: https://context7.com/probonopd/linuxdeployqt/llms.txt This workflow automates the build and packaging of an AppImage for a Qt application using GitHub Actions. It installs Qt, builds the application, creates an AppDir, downloads linuxdeployqt, and then creates and uploads the AppImage artifact. ```yaml name: AppImage on: [push, pull_request] jobs: build: runs-on: ubuntu-20.04 # Use older Ubuntu for compatibility steps: - uses: actions/checkout@v3 - name: Install Qt run: | sudo apt-get update sudo apt-get install -y qt5-default libqt5svg5-dev - name: Build run: | qmake CONFIG+=release PREFIX=/usr make -j$(nproc) - name: Create AppDir run: make INSTALL_ROOT=appdir install - name: Download linuxdeployqt run: | wget -c https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage chmod a+x linuxdeployqt*.AppImage - name: Create AppImage run: | export VERSION=${{ github.ref_name }} ./linuxdeployqt*.AppImage appdir/usr/share/applications/*.desktop -appimage - name: Upload AppImage uses: actions/upload-artifact@v3 with: name: AppImage path: '*.AppImage' ``` -------------------------------- ### Get Current Date Source: https://github.com/probonopd/linuxdeployqt/blob/master/CMakeLists.txt This code executes a command to get the current date and time in UTC, formatted as 'YYYY-MM-DD HH:MM:SS Z'. It handles potential errors during execution. ```cmake # get current date execute_process( COMMAND env LC_ALL=C date -u "+%Y-%m-%d %H:%M:%S %Z" OUTPUT_VARIABLE DATE OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE DATE_RESULT ) if(NOT DATE_RESULT EQUAL 0) message(FATAL_ERROR "Failed to determine date string") endif() mark_as_advanced(DATE DATE_RESULT) ``` -------------------------------- ### Update CMake Version Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Install a newer version of CMake for compatibility with specific build requirements. ```bash - sudo rm -rf /usr/bin/cmake /usr/local/cmake-* /usr/local/bin/cmake || true # Needed on Travis CI; don't do this on other systems! - wget "https://github.com/Kitware/CMake/releases/download/v3.13.2/cmake-3.13.2-Linux-x86_64.tar.gz" ; sudo tar xf cmake*.tar.gz --strip-components=1 -C /usr ``` -------------------------------- ### Deploying QML Applications Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Configuring QML import paths and module search directories for Qt Quick applications. ```bash # Deploy with QML imports from a specific directory linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -qmldir=/path/to/your/qml/sources \ -verbose=2 # Multiple QML directories linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -qmldir=./qml \ -qmldir=./imports \ -verbose=2 # Add custom QML module search paths linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -qmldir=./qml \ -qmlimport=/opt/custom-qt-modules/qml \ -verbose=2 ``` -------------------------------- ### CLI Usage and Options Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Basic command-line syntax and utility flags for linuxdeployqt. ```bash # Basic usage syntax linuxdeployqt [options] # View all available options linuxdeployqt --help # Check version linuxdeployqt --version # Show the built-in library exclude list linuxdeployqt -show-exclude-libs ``` -------------------------------- ### Deploying with Desktop Files Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Automated deployment workflow using a desktop file to define application metadata. ```bash # Create the AppDir structure first mkdir -p MyApp.AppDir/usr/{bin,lib,share/{applications,icons/hicolor/256x256/apps}} # Copy your compiled binary cp build/myapp MyApp.AppDir/usr/bin/ # Create a desktop file at MyApp.AppDir/usr/share/applications/myapp.desktop cat > MyApp.AppDir/usr/share/applications/myapp.desktop << 'EOF' [Desktop Entry] Type=Application Name=My Qt Application Comment=A sample Qt application Exec=myapp Icon=myapp Categories=Utility; EOF # Copy your icon (must match Icon= entry without extension) cp resources/myapp.png MyApp.AppDir/usr/share/icons/hicolor/256x256/apps/ # Deploy using the desktop file linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop -verbose=2 ``` -------------------------------- ### Custom AppRun Wrapper Script for linuxdeployqt Source: https://context7.com/probonopd/linuxdeployqt/llms.txt This script demonstrates how to replace the default AppRun with a custom wrapper to set up the environment and execute the main application. It first runs linuxdeployqt, removes the auto-generated AppRun, creates a custom AppRun with environment variables, and then uses appimagetool to create the final AppImage. ```bash # 1. Run linuxdeployqt first (without -appimage) linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop -verbose=2 # 2. Remove the auto-generated AppRun rm MyApp.AppDir/AppRun # 3. Create custom AppRun wrapper cat > MyApp.AppDir/AppRun << 'EOF' #!/bin/bash HERE="$(dirname "$(readlink -f "${0}")")" # Set up custom environment export LD_LIBRARY_PATH="${HERE}/usr/lib:${HERE}/usr/lib/myapp:${LD_LIBRARY_PATH}" export QT_PLUGIN_PATH="${HERE}/usr/plugins" export MYAPP_DATA_DIR="${HERE}/usr/share/myapp" # Optional: Change to app directory cd "${HERE}/usr" # Execute the main application exec "${HERE}/usr/bin/myapp" "$@" EOF chmod +x MyApp.AppDir/AppRun # 4. Create AppImage using appimagetool directly appimagetool MyApp.AppDir ``` -------------------------------- ### linuxdeployqt Command-Line Options Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Lists available flags and arguments for the linuxdeployqt executable. ```text Usage: linuxdeployqt [options] Options: -always-overwrite : Copy files even if the target file exists. -appimage : Create an AppImage (implies -bundle-non-qt-libs). -bundle-non-qt-libs : Also bundle non-core, non-Qt libraries. -exclude-libs= : List of libraries which should be excluded, separated by comma. -ignore-glob= : Glob pattern relative to appdir to ignore when searching for libraries. -executable= : Let the given executable use the deployed libraries too -executable-dir= : Let all the executables in the folder (recursive) use the deployed libraries too -extra-plugins= : List of extra plugins which should be deployed, separated by comma. -no-copy-copyright-files : Skip deployment of copyright files. -no-plugins : Skip plugin deployment. -no-strip : Don't run 'strip' on the binaries. -no-translations : Skip deployment of translations. -qmake= : The qmake executable to use. -qmldir= : Scan for QML imports in the given path. -qmlimport= : Add the given path to QML module search locations. -show-exclude-libs : Print exclude libraries list. -verbose=<0-3> : 0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug. -updateinformation= : Embed update information STRING; if zsyncmake is installed, generate zsync file -version : Print version statement and exit. ``` -------------------------------- ### Deployment Execution Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Command to run linuxdeployqt using a desktop file. ```bash linuxdeployqt-continuous-x86_64.AppImage path/to/AppDir/usr/share/applications/your_app.desktop ``` -------------------------------- ### Bash Wrapper Script for linuxdeployqt Source: https://github.com/probonopd/linuxdeployqt/wiki/Custom-wrapper-script-instead-of-AppRun Use this Bash script as a wrapper for your application. It sets the LD_LIBRARY_PATH to include custom library directories and then executes the main application binary. Ensure the script is placed as `AppRun` in the `appdir`. ```bash #!/bin/bash HERE="$(dirname "$(readlink -f "${0}")")" export LD_LIBRARY_PATH=${HERE}/usr/lib/foobar:$LD_LIBRARY_PATH exec "${HERE}/usr/bin/foo" "$@" ``` -------------------------------- ### Configure Icon and Theme Support Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Add required plugins to enable icon and system theme support during deployment. ```bash -extra-plugins=iconengines,platformthemes/libqgtk3.so ``` -------------------------------- ### Include Additional Executables Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Deploy libraries for helper tools or entire directories of executables alongside the main application. ```bash # Include additional executables linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -executable=MyApp.AppDir/usr/bin/helper-tool \ -executable=MyApp.AppDir/usr/bin/cli-tool ``` ```bash # Include all executables in a directory recursively linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -executable-dir=MyApp.AppDir/usr/libexec/ ``` -------------------------------- ### Define and Configure Executable Target Source: https://github.com/probonopd/linuxdeployqt/blob/master/tools/linuxdeployqt/CMakeLists.txt Creates the main executable target 'linuxdeployqt', specifies its source files, include directories, linked libraries, and compile definitions including the generated excludelist. ```cmake add_executable(linuxdeployqt main.cpp shared.cpp) target_include_directories(linuxdeployqt PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(linuxdeployqt Qt${QT_VERSION_MAJOR}::Core) target_compile_definitions(linuxdeployqt PRIVATE -DEXCLUDELIST="${EXCLUDELIST}") ``` -------------------------------- ### Verify QMake Version Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Check the current qmake path and version to ensure the correct Qt instance is used. ```bash qmake -v QMake version 3.0 Using Qt version 5.7.0 in /tmp/.mount_QtCreator-5.7.0-x86_64/5.7/gcc_64/lib ``` -------------------------------- ### Deploy Extra Qt Plugins Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Specify additional plugins to be deployed using the -extra-plugins argument. ```bash -extra-plugins=sqldrivers/libqmsql.so,iconengines/libqsvgicon.so ``` ```bash -extra-plugins=sqldrivers,iconengines/libqsvgicon.so ``` ```bash -extra-plugins=sqldrivers,iconengines,mediaservice,gamepads ``` -------------------------------- ### Direct Binary Deployment Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Deploying applications by pointing directly to the binary, supporting both non-FHS and FHS-like directory structures. ```bash # Deploy from binary path (non-FHS mode) linuxdeployqt MyApp.AppDir/myapp -verbose=2 # Deploy from binary in FHS-like structure # When binary is in usr/bin/, linuxdeployqt detects FHS mode automatically linuxdeployqt MyApp.AppDir/usr/bin/myapp -verbose=2 ``` -------------------------------- ### Deployment Control Options Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Fine-tune the deployment process by adjusting verbosity, stripping, and file handling behavior. ```bash # Full verbose output for debugging linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop -verbose=3 ``` ```bash # Skip stripping binaries (preserve debug symbols) linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop -no-strip ``` ```bash # Skip translation deployment linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop -no-translations ``` ```bash # Skip copyright file deployment linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop -no-copy-copyright-files ``` ```bash # Force overwrite existing files linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop -always-overwrite ``` -------------------------------- ### Handle Custom Qt Library Infix Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Specify a custom library infix if the Qt distribution was configured with -qtlibinfix. ```bash configure -qtlibinfix "Custom" [...] ``` ```bash linuxdeployqt [...] -qtlibinfix "Custom" [...] ``` -------------------------------- ### Specify Qmake Path Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Explicitly define the qmake path when using distribution packages. ```bash -qmake=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake ``` -------------------------------- ### Creating AppImages Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Generating distributable AppImage files, including options for update information and versioning. ```bash # Create AppImage (implies -bundle-non-qt-libs) linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop -appimage # Create AppImage with update information for delta updates linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -appimage \ -updateinformation="gh-releases-zsync|username|repo|latest|MyApp-*x86_64.AppImage.zsync" # Set VERSION environment variable for AppImage naming export VERSION=1.0.0 linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop -appimage # Output: MyApp-1.0.0-x86_64.AppImage ``` -------------------------------- ### CMake Build Integration Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Automate AppImage creation within a CMake build workflow. ```bash cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr cmake --build build --parallel cmake --install build --prefix appdir/usr ``` ```bash # Find the desktop file and deploy linuxdeployqt appdir/usr/share/applications/*.desktop \ -qmldir=./qml \ -appimage ``` ```bash # Alternative: Use DESTDIR for install make DESTDIR=$(pwd)/appdir install linuxdeployqt appdir/usr/share/applications/*.desktop -appimage ``` -------------------------------- ### Managing Qt Plugins Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Controlling plugin inclusion, including skipping plugins or adding extra directories and specific files. ```bash # Skip all plugin deployment linuxdeployqt MyApp.AppDir/usr/bin/myapp -no-plugins # Deploy extra plugins not automatically detected linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -extra-plugins=sqldrivers/libqsqlite.so,imageformats/libqsvg.so # Deploy entire plugin directories linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -extra-plugins=sqldrivers,iconengines,imageformats # Add icon theme support (for system theme icons) linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -extra-plugins=iconengines,platformthemes/libqgtk3.so ``` -------------------------------- ### AppDir Directory Structure Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Required file system layout for an application bundle. ```text └── usr ├── bin │   └── your_app ├── lib └── share ├── applications │   └── your_app.desktop └── icons └── └── └── apps └── your_app.png ``` -------------------------------- ### Include Tools Subdirectory Source: https://github.com/probonopd/linuxdeployqt/blob/master/CMakeLists.txt This command adds a subdirectory named 'tools/linuxdeployqt' to the build. This is typically used to include other CMakeLists.txt files and their associated targets. ```cmake add_subdirectory(tools/linuxdeployqt) ``` -------------------------------- ### Travis CI Integration Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Automate AppImage generation in Travis CI using a standard YAML configuration. ```yaml # .travis.yml language: cpp dist: xenial # Use oldest supported Ubuntu LTS for compatibility before_install: - sudo apt-get update - sudo apt-get install -y qt5-default libqt5svg5-dev install: - wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" - chmod a+x linuxdeployqt*.AppImage script: - qmake CONFIG+=release PREFIX=/usr - make -j$(nproc) - make INSTALL_ROOT=appdir install - ./linuxdeployqt*.AppImage appdir/usr/share/applications/*.desktop -appimage after_success: - curl --upload-file MyApp*.AppImage https://transfer.sh/ deploy: provider: releases api_key: $GITHUB_TOKEN file_glob: true file: MyApp*.AppImage skip_cleanup: true on: tags: true ``` -------------------------------- ### Expose Version Data as Compiler Definitions Source: https://github.com/probonopd/linuxdeployqt/blob/master/tools/linuxdeployqt/CMakeLists.txt Defines preprocessor macros for build-time information such as version, commit, and build date. ```cmake add_definitions("-DLINUXDEPLOYQT_VERSION=\"${GIT_TAG_NAME}\"") add_definitions("-DLINUXDEPLOYQT_GIT_COMMIT=\"${GIT_COMMIT}\") add_definitions("-DBUILD_DATE=\"${DATE}\") add_definitions("-DBUILD_NUMBER=\"${BUILD_NUMBER}\") ``` -------------------------------- ### Set C++ Standard and Automoc Source: https://github.com/probonopd/linuxdeployqt/blob/master/tools/linuxdeployqt/CMakeLists.txt Configures the build system to use C++11 and enable automatic handling of Qt's meta-object system. ```cmake set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` -------------------------------- ### Bundle and Exclude Libraries Source: https://context7.com/probonopd/linuxdeployqt/llms.txt Control which libraries are included in the deployment package using bundling and exclusion flags. ```bash # Bundle non-Qt libraries (included automatically with -appimage) linuxdeployqt MyApp.AppDir/usr/bin/myapp -bundle-non-qt-libs ``` ```bash # Exclude specific libraries from bundling linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -exclude-libs=libssl.so,libcrypto.so,libGL.so ``` ```bash # Ignore libraries matching glob patterns in appdir linuxdeployqt MyApp.AppDir/usr/share/applications/myapp.desktop \ -ignore-glob=usr/lib/custom/*.so ``` -------------------------------- ### Pull Request Template for linuxdeployqt Integration Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Use this template when submitting a pull request to an upstream project to propose the integration of linuxdeployqt for automated AppImage builds. ```markdown This PR, when merged, will compile this application on [Travis CI](https://travis-ci.org/) upon each `git push`, and upload an [AppImage](http://appimage.org/) to your GitHub Releases page. Providing an [AppImage](http://appimage.org/) would have, among others, these advantages: - Applications packaged as an AppImage can run on many distributions (including Ubuntu, Fedora, openSUSE, CentOS, elementaryOS, Linux Mint, and others) - One app = one file = super simple for users: just download one AppImage file, [make it executable](http://discourse.appimage.org/t/how-to-make-an-appimage-executable/80), and run - No unpacking or installation necessary - No root needed - No system libraries changed - Works out of the box, no installation of runtimes needed - Optional desktop integration with `appimaged` - Optional binary delta updates, e.g., for continuous builds (only download the binary diff) using AppImageUpdate - Can optionally GPG2-sign your AppImages (inside the file) - Works on Live ISOs - Can use the same AppImages when dual-booting multiple distributions - Can be listed in the [AppImageHub](https://appimage.github.io/) central directory of available AppImages - Can double as a self-extracting compressed archive with the `--appimage-extract` parameter - No repositories needed. Suitable/optimized for air-gapped (offline) machines - Decentralized [Here is an overview](https://appimage.github.io/apps) of projects that are already distributing upstream-provided, official AppImages. __PLEASE NOTE:__ For this to work, you need to set up `GITHUB_TOKEN` in Travis CI for this to work; please see https://github.com/probonopd/uploadtool. If you would like to see only one entry for the Pull Request in your project's history, then please enable [this GitHub functionality](https://help.github.com/articles/configuring-commit-squashing-for-pull-requests/) on your repo. It allows you to squash (combine) the commits when merging. If you have questions, AppImage developers are on #AppImage on irc.freenode.net. ``` -------------------------------- ### Remove Unnecessary Build Files Source: https://github.com/probonopd/linuxdeployqt/blob/master/README.md Clean up autogenerated build files from the build directory before running linuxdeployqt. ```bash find $HOME/build-*-*_Qt_* \( -name "moc_*" -or -name "*.o" -or -name "qrc_*" -or -name "Makefile*" -or -name "*.a" \) -exec rm {} \; ``` -------------------------------- ### Find Git and Handle Not Found Source: https://github.com/probonopd/linuxdeployqt/blob/master/CMakeLists.txt This snippet finds the Git executable. If Git is not found, it issues a warning and requires manual setting of GIT_COMMIT and GIT_TAG_NAME. ```cmake cmake_minimum_required(VERSION 3.2) project(linuxdeployqt) find_program(GIT git) if("${GIT}" STREQUAL "GIT-NOTFOUND") message(WARNING "Could not find git, commit and tag info cannot be updated") if(NOT GIT_COMMIT) message(FATAL_ERROR "Commit ID not set, please call with -DGIT_COMMIT=...") endif() if(NOT GIT_TAG_NAME) message(FATAL_ERROR "Tag name not set, please call with -DGIT_TAG_NAME=...") endif() else() # make sure Git revision ID and latest tag is not stored in the CMake cache # otherwise, one would have to reset the CMake cache on every new commit to make sure the Git commit ID is up to date unset(GIT_COMMIT CACHE) unset(GIT_LATEST_TAG CACHE) # read Git revision ID and latest tag number execute_process( COMMAND "${GIT}" rev-parse --short HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE GIT_COMMIT_RESULT ) if(NOT GIT_COMMIT_RESULT EQUAL 0) message(FATAL_ERROR "Failed to determine git commit ID") endif() mark_as_advanced(GIT_COMMIT GIT_COMMIT_RESULT) execute_process( COMMAND "${GIT}" rev-list --tags --skip=1 --max-count=1 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_TAG_ID OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE GIT_TAG_ID_RESULT ) if(NOT GIT_TAG_ID_RESULT EQUAL 0) message(FATAL_ERROR "Failed to determine git tag ID") endif() mark_as_advanced(GIT_TAG_ID GIT_TAG_ID_RESULT) execute_process( COMMAND "${GIT}" describe --tags ${GIT_TAG_ID} --abbrev=0 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_TAG_NAME OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE GIT_TAG_NAME_RESULT ) if(NOT GIT_TAG_NAME_RESULT EQUAL 0) message(FATAL_ERROR "Failed to determine git tag name") endif() mark_as_advanced(GIT_TAG_NAME GIT_TAG_NAME_RESULT) endif() ``` -------------------------------- ### Set Version and Build Number Source: https://github.com/probonopd/linuxdeployqt/blob/master/CMakeLists.txt This snippet sets the version to '1-alpha' and determines the build number. It uses the TRAVIS_BUILD_NUMBER environment variable if available, otherwise defaults to ''. ```cmake # set version and build number set(VERSION 1-alpha) if("$ENV{TRAVIS_BUILD_NUMBER}" STREQUAL "") set(BUILD_NUMBER "") else() set(BUILD_NUMBER "$ENV{TRAVIS_BUILD_NUMBER}") endif() ``` -------------------------------- ### Update Excludelist Source: https://github.com/probonopd/linuxdeployqt/blob/master/tools/linuxdeployqt/CMakeLists.txt Executes a bash script to generate an excludelist. If the script fails, a warning is issued and an outdated copy might be used. This process is marked as advanced. ```cmake message(STATUS "Updating excludelist...") execute_process( COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/../generate-excludelist.sh OUTPUT_VARIABLE EXCLUDELIST TIMEOUT 10 RESULT_VARIABLE EXCLUDELIST_RESULT ) if(NOT EXCLUDELIST_RESULT EQUAL 0) message(WARNING "Updating excludelist failed, using outdated copy") endif() mark_as_advanced(EXCLUDELIST EXCLUDELIST_RESULT) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.