KDE Development on Fedora Atomic

This post is a summary of my setup for KDE development on Fedora Atomic (Kinoite) using toolbox, kdesrc-build and Qt Creator.

Toolbox

Create the toolbox:

toolbox create dev

Note: I’m using the name “dev” to distinguish toolboxes. It is optional, so if you just want to use the default toolbox, you can omit it.

Konsole profile

Create a Konsole profile for easier access to the toolbox:

  • Open Konsole
  • Settings > Manage Profiles… > New …
    • Name: toolbox (dev)
    • Command: toolbox enter dev
    • Initial directory: /home/<user>/kde (or wherever you want to do development)
    • Environment: to distinguish the toolbox Konsole from the system Konsole, e.g. PROMPT_COLOR=31 for a red prompt

Add a .desktop file which you can e.g. add to your favorites in the application launcher:

cp /usr/share/applications/org.kde.konsole.desktop ~/.local/share/applications/org.kde.konsole-toolbox-dev.desktop

Edit ~/.local/share/applications/org.kde.konsole-toolbox-dev.desktop to run the toolbox (dev) profile:

Name=Konsole - toolbox (dev)
Exec=konsole --profile 'toolbox (dev)'

kdesrc-build

Enter the dev toolbox (i.e. launch “Konsole - toolbox (dev)” or run toolbox enter dev).

Install basic tools:

sudo dnf install git perl perl-IPC-Cmd perl-MD5 perl-FindBin
sudo dnf install breeze-icon-theme

Configure git:

git config --global user.name "Your Name"
git config --global user.email "you@email.com"

Setup kdesrc-build:

mkdir -p ~/kde/src
cd ~/kde/src/
git clone https://invent.kde.org/sdk/kdesrc-build.git && cd kdesrc-build

To use a different directory instead of ~/kde, generate the config and change install-dir, source-dir and build-dir in ~/.config/kdesrc-buildrc .
If the default (~/kde) is ok for you, you can skip this step.

./kdesrc-build --generate-config

Perform the initial setup:

./kdesrc-build --initial-setup
mkdir -p ~/.local/bin
ln -sf ~/kde/src/kdesrc-build/kdesrc-build ~/.local/bin

Build and run an application:

./kdesrc-build kcalc
./kdesrc-build --run kcalc

Edit ~/.bashrc to setup the environment when entering the toolbox:

# Source KDE environment in dev toolbox
if [ -f /run/.toolboxenv ]; then
    source /run/.containerenv
    if [ "$name" == "dev" ]; then
        source ~/.config/kde-env-master.sh
    fi
fi

Close the toolbox and enter again to apply the change.

Qt Creator

Install the IDE:

sudo dnf install qt-creator

Add a .desktop file to start it from outside the toolbox:

cp /usr/share/applications/org.qt-project.qtcreator.desktop ~/.local/share/applications/qtcreator.desktop

Edit ~/.local/share/applications/org.qt-project.qtcreator.desktop to run Qt Creator in the dev toolbox and fix the window icons:

Exec=toolbox run -c dev qtcreator %F
Icon=qtcreator

Add kdesrc-build kit:

  • Edit > Preferences… > Kits
    • Add
      • Name: kdesrc-build
      • Environment:
        • set environement variables which are exported in ~/.config/kde-env-master.sh, you can fetch them with:
          env | grep -E "^CMAKE_PREFIX_PATH|^PATH|^PKG_CONFIG_PATH|^PYTHONPATH|^QML2_IMPORT_PATH|^QT_PLUGIN_PATH|^XDG_DATA_DIRS|^XDG_CONFIG_DIRS|^MANPATH"
          
        • add QT_FORCE_STDERR_LOGGING=1 and QT_LOGGING_RULES=*.debug=true; qt.*.debug=false to see qml errors
      • CMake Configuration > Change…
        • replace -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} with -DCMAKE_PREFIX_PATH:PATH=%{Env:CMAKE_PREFIX_PATH};%{Qt:QT_INSTALL_PREFIX}
        • add -DQML_IMPORT_PATH:PATH=%{Env:QML2_IMPORT_PATH} such that the editor can resolve qml imports
    • Make Default

Use correct formatting:

  • Edit > Preferences… > C++
    • Formatting mode: “Full formatting”
    • check “Format while typing”
    • check “Format edited code on file save”

Set default source and build directories:

  • Edit > Preferences… > Build & Run
    • General
      • Directory: ~/kde/src (or your custom source-dir from ~/.config/kdesrc-buildrc)
    • Default Build Properties
      • Default build directory: ~/kde/build/%{JS: Util.asciify("%{Project:Name}-%{BuildConfig:Name}")} (or your custom build-dir from ~/.config/kdesrc-buildrc)

Open project:

  • Welcome > Open Project…
  • Open top-level CMakeLists.txt of the project
  • Select only the “kdesrc-build” kit and choose the desired build types
  • Configure Project

VSCodium

Install the IDE:

sudo rpmkeys --import https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg
printf "[gitlab.com_paulcarroty_vscodium_repo]\nname=download.vscodium.com\nbaseurl=https://download.vscodium.com/rpms/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg\nmetadata_expire=1h" | sudo tee -a /etc/yum.repos.d/vscodium.repo
sudo dnf install codium

Add a .desktop file to start it from outside the toolbox:

cp /usr/share/applications/codium.desktop ~/.local/share/applications/codium.desktop
mkdir ~/.local/share/pixmaps/
cp /usr/share/pixmaps/vscodium.png ~/.local/share/pixmaps/

Edit ~/.local/share/applications/codium.desktop to run VSCodium in the dev toolbox and fix the window icons:

Exec=toolbox run -c dev /usr/share/codium/codium --unity-launch %F

If you use Wayland, add --ozone-platform=wayland to avoid stutter/freezing mouse pointer.

Create config files:

  • Edit ~/.config/kdesrc-buildrc
    compile-commands-linking true
    compile-commands-export true
    generate-vscode-project-config true
    
  • Run kdesrc-build for the project

Install extensions:

  • CMake Tools
  • C/C++ Extension Pack
  • Qt tools
  • QML
  • Code Spell Checker
  • GitLens
  • GitLab Workflow
    • Ctrl + Shift + P > Configure Runtime Arguments
      add:
      "password-store":"gnome-libsecret"
      
      This avoids the “You’re running in a KDE environment but the OS keyring is not available for encryption. Ensure you have kwallet running.” error.

Enable debug output:

  • Ctrl + P > launch.json
    add:
    "env": {
        "QT_FORCE_STDERR_LOGGING": "1",
        "QT_LOGGING_RULES": "*.debug=true; qt.*.debug=false"
    }
    

Open project:

  • File → Open Folder…
  • Open top-level folder of the project

see KDE Community Wiki - Visual Studio Code

Tools

sudo dnf install meld # diff/merge
sudo dnf install clang-tools-extra # clang-format

Links

2 Likes

Related: Get Involved/development/More - KDE Community Wiki

Is there any particular reason for using toolbox over distrobox?

1 Like

Not really. toolbox is just there by default and it get’s the job done so I didn’t bother. Apart from that, the steps should work pretty much the same in distrobox (obviously, you could e.g. use distrobox export instead of creating the .desktop manually but that’s about it).

I actually didn’t see the wiki entry before. Might make sense to enhance it. On the other hand, not sure if it might not get too bloated with opinionated stuff like Qt Creator (not everybody will want to use that).

1 Like