Get Involved/development/More

From KDE Community Wiki
Revision as of 00:57, 26 June 2023 by Ashark (talk | contribs) (→‎Build Qt6 using kdesrc-build: cannot use comments on the same line as include line)

This page is the continuation with more advanced topics of the page Get_Involved/development.

This paged is not meant for people that are starting to program for KDE.

Develop in a Linux container

When you start programming for KDE, it is recommended that you use kdesrc-build in your main operating system or in a virtual machine running on a rolling-release Linux distribution (Arch, openSUSE Tumbleweed, KDE neon) or running on e.g. the latest version of Fedora KDE Spin or Kubuntu.

As an alternative, you can run kdesrc-build in a Linux container (docker, podman, toolbx, distrobox).

Option 1. The KDE PIM Docker image

You can install Docker and the KDE PIM Docker image. It provides a development environment that is isolated from your day-to-day system. It is based on KDE Neon Unstable.

Option 2. distrobox

Or, you can just create a long lived (pet not cattle) container using distrobox and podman (or docker). See https://www.youtube.com/watch?v=9JEALbcmcCg and https://github.com/89luca89/distrobox to learn more about distrobox and how to use it in general.

First, install distrobox and podman from your distribution repositories. Then run:

distrobox enter

This should create a container based on your current system and enter it. It is preferable to use one of the Linux distributions that is better suited for kdesrc-build, as mentioned in this wiki page, so if your distribution does not provide very up-to-date packages, you can download and use a different container image for your distrobox from Dockerhub. For example, with openSUSE Tumbleweed:

podman pull opensuse/tumbleweed
distrobox create --image opensuse/tumbleweed --name tumbleweed
distrobox enter tumbleweed

Then it's a matter of downloading and running kdesrc-build as detailed in Set up kdesrc-build:

mkdir -p ~/kde/src
cd ~/kde/src
git clone https://invent.kde.org/sdk/kdesrc-build.git
./kdesrc-build --initial-setup
source ~/.bashrc

From this point on, one important thing to bear in mind is that a distrobox container is transparent in its user space and containerized in its root space: when you are inside a distrobox container, you can see the content of system's home folder, but not your system's root folders, only the container's root folders. This means that you can install packages inside the container using root privileges and access those packages to compile your programs stored in your home, without ever installing those packages in your actual system!

You can take advantage of this by installing, for instance, Qt development packages used for kdesrc-build from inside the container. This way, it is not necessary to compile Qt with kdesrc-build. This is particularly convenient if you want to compile KDE software with Qt6 quickly.

Likewise, you should install the required dependencies from inside the distrobox rather than from your system's repositories. Then you can start compiling as usual.

After compiling your program with kdesrc-build from inside the distrobox, you can run it with kdesrc-build run, and despite it originating from inside a container and using the libraries from the container, it will run just fine as a GUI application on your system!

The only few gotchas to using this method are:

  • You cannot use a full Plasma Desktop session made from git.
  • You will need qqc2-desktop-style and Breeze to show the correct theme for your applications.
  • You will need the QtWayland library and its respective development package to run your applications natively on a Wayland session.

Other operating systems

FreeBSD

Install the latest release of FreeBSD with KDE Plasma Desktop on your hardware computer or in a virtual machine.

Your user should be member of the "wheel" user group (e.g. this can be configured in the FreeBSD installer, when creating your user you can select additional user groups for your user). Your user should be able to use sudo:

pkg install sudo
visudo
# Uncomment the line: %wheel ALL=(ALL:ALL) ALL

Then set up kdesrc-build using the same procedure as when installing kdesrc-build on a Linux operating system. FreeBSD is currently supported by kdesrc-build. See https://www.youtube.com/watch?v=v2wq0eTnUuc https://www.youtube.com/watch?v=MT-AN4J-hn8

Microsoft Windows

You can build and develop KDE projects using the Microsoft Windows operating system.

Apple macOS

You can build and develop KDE projects using the Apple macOS operating system.

What to do if CMake configure fails because a build dependency is missing

If you run kdesrc-build in order to build a KDE git repository. And if building fails with a CMake error. Then, that is most often caused by the fact that you do not have installed some binary packages from your Linux OS.

See below for some ideas about how to find out what Linux packages you need to install.

Debian/Kubuntu/KDE neon

E.g. I am on Kubuntu 22.10, kdesrc-build frameworks fails, module kcoreaddons has CMake (configure) error Could NOT find Qt6LinguistTools (missing: Qt6LinguistTools_DIR).

Option 1:

Search on the internet for ubuntu packages Qt6LinguistTools it returns https://packages.ubuntu.com/kinetic/amd64/qt6-tools-dev Expand "amd64 [list of files]": /usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsConfig.cmake

sudo apt install qt6-tools-dev

Option 2:

sudo apt install apt-file
sudo apt-file update
apt-file find Qt6LinguistToolsConfig.cmake
# qt6-tools-dev: /usr/lib/x86_64-linux-gnu/cmake/Qt6LinguistTools/Qt6LinguistToolsConfig.cmake
sudo apt install qt6-tools-dev

If the error is:

The imported target "Qt6::qtwaylandscanner" references the file
     "/usr/lib/qt6/libexec/qtwaylandscanner"
but this file does not exist.

Then:

apt-file find /usr/lib/qt6/libexec/qtwaylandscanner
# qt6-wayland-dev-tools: /usr/lib/qt6/libexec/qtwaylandscanner
sudo apt install qt6-wayland-dev-tools

Option 3:

apt search linguist | grep qt6
# linguist-qt6/kinetic 6.3.1-2 amd64
sudo apt install linguist-qt6

More examples:

# Error "Could not find OsmTools (missing: OSMCONVERT_EXECUTABLE
apt-file search -i OSMCONVERT
# Returns "osmctools: /usr/bin/osmconvert".
sudo apt install osmctools

Fedora

sudo dnf provides "NameOrPathOfFileThatIsMissing"

See https://invent.kde.org/redstrate/cmake-package-installer/-/blob/master/src/main.rs

Advanced kdesrc-build

After you have edited a git repository and you want to build it, --no-src will make sure that kdesrc-build does not overwrite your changes with the latest source code from the official git repository (remote "origin" / https://invent/kde.org).

--no-include-dependencies only builds the git repository that you give as parameter to kdesrc-build.

--debug shows verbose output.

--refresh-build forces a rebuild (not an incremental build) and a full reinstall.

E.g. you have edited kcalc. You run:

kdesrc-build kcalc --no-src --no-include-dependencies --refresh-build --debug |& tee ~/a.txt

For details, see:

kdesrc-build --help

Note: the resources below might not be up to date.

See the kdesrc-build manual, Readme #1, Readme #2, Document #3 for more kdesrc-build information and options.

Build Qt using kdesrc-build

Set up kdesrc-build from scratch as usual.

Open the configuration file ~/.config/kdesrc-buildrc and confirm that qtdir and the lines include...qt5-build-include and include...custom-qt5-libs-build-include are not commented out (i.e. there should not be a # in front of the lines). E.g. (replace "username" with your Linux user's name):

qtdir ~/kde/usr # Where to make install Qt5
include /home/username/kde/src/kdesrc-build/qt5-build-include
include /home/username/kde/src/kdesrc-build/custom-qt5-libs-build-include

Run in a terminal:

kdesrc-build qt5-set
kdesrc-build frameworks

kf5-qt5 vs. kf5-qt6 vs. kf6-qt6

For now, the KDE git repositories from https://invent.kde.org/frameworks and https://invent.kde.org/plasma/ can build correctly and run correctly using "kdesrc-build kf6-qt6".

The KDE git repositories that can build correctly and run correctly using "kdesrc-build kf6-qt6" have two long lived git branches:

  • A long lived git branch that does not contain the deprecated symbols from kf5-qt5, named e.g. "master".
  • And another long lived git branch for qt5-kf5 and qt6-kf5, where the deprecated symbols still exist.

What is "kf5-qt5"? You just set up kdesrc-build following the procedure. The resulting kdesrc-build installation will be of type kf5-qt5. In kdesrc-buildrc in the "global" section you will have "branch-group kf5-qt5". The git repositories that have only one long lived git branch e.g. named "master" will use that. The git repositories that have a second long lived git branch where the deprecated symbols still exist e.g. named "kf5" will use that.

What is "kf5-qt6"? "kf5-qt6" is not supported and should not be used. You just set up kdesrc-build following the procedure. The resulting kdesrc-build installation will be of type kf5-qt5. In kdesrc-buildrc in the "global" section you will have "branch-group kf5-qt5", you keep this unchanged. You edit kdesrc-buildrc to make kdesrc-build use Qt6 instead of Qt5. The git repositories that have only one long lived git branch e.g. named "master" will use that. The git repositories that have a second long lived git branch where the deprecated symbols still exist e.g. named "kf5" will use that.

What is "kf6-qt6"? You just set up kdesrc-build following the procedure. The resulting kdesrc-build installation will be of type kf5-qt5. In kdesrc-buildrc in the "global" section you will have "branch-group kf5-qt5", you replace that with "branch-group kf6-qt6". You edit kdesrc-buildrc to make kdesrc-build use Qt6 instead of Qt5. The git repositories that have only one long lived git branch e.g. named "master" will use that. The git repositories that have a second long lived git branch, will use the git branch where the deprecated symbols do not exist e.g. named "master".

Why kdesrc-build kf6-qt6 cannot build and run neochat correctly?

neochat does not have a second long lived git branch where the deprecated symbols do not exist.

kdesrc-build neochat for kf6-qt6 succeeds, but then kdesrc-run neochat for kf6-qt6 fails because

qrc:/RoomListContextMenu.qml:200:27: Invalid property assignment: unsupported type "QQuickIcon"
Segmentation fault (core dumped)
# The file ~/kde/src/neochat/src/qml/Menu/RoomListContextMenu.qml at line 200 says:
Kirigami.BasicListItem {
    text: i18n("Mark as Read")
    icon: "checkmark"

The symbol Kirigami.BasicListItem.icon of type string is deprecated and exists in kf5-qt5. In kf6-qt6 we use the symbol of type string Kirigami.BasicListItem.icon.name.

kdesrc-build, Qt6 and KDE Frameworks 6

Using kdesrc-buildrc-kf6-sample

KDE projects are currently transitioning to use Qt6. You can build the in-development Qt6 versions using kdesrc-build by adjusting the .config/kdesrc-buildrc file. You can find a sample kdesrc-buildrc file here.

The important differences to Qt5 are:

branch-group kf6-qt6: This will check out the correct git branches.

prefix ~/kde6/usr: It is recommended to use a different prefix for Qt6-based builds than for the Qt5-based builds

Save the file e.g. as /home/user/kde6/kdesrc-buildrc.

Then you can use kdesrc-build --rc-file=/home/user/kde6/kdesrc-buildrc ... to build things against Qt6

Editing ~/.config/kdesrc-buildrc

Set up kdesrc-build following the "Set up kdesrc-build" procedure. The resulting kdesrc-build installation will be of type kf5-qt5. In kdesrc-buildrc in the "global" section you will have "branch-group kf5-qt5".

Edit the file ~/.config/kdesrc-buildrc

  • Replace all "5" with "6".
  • Replace:
cmake-options -DCMAKE_BUILD_TYPE=RelWithDebInfo

with:

cmake-options -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DBUILD_WITH_QT6=ON

Installing the Qt6 Development Packages

  • Ubuntu: sudo apt install qt6-tools-dev qt6-declarative-dev libqt6core5compat6-dev qt6-wayland-dev qt6-wayland-dev-tools qt6-base-private-dev libqt6svg6-dev libqt6opengl6-dev libqt6shadertools6-dev
  • openSUSE Tumbleweed: sudo zypper in patterns-kde-devel_qt6 qt6-wayland-private-devel
  • Arch Linux: sudo pacman -S poppler-qt6 qca-qt6 qt6-5compat qt6-base qt6-charts qt6-declarative qt6-multimedia qt6-multimedia-ffmpeg qt6-positioning qt6-tools qt6-translations qt6-wayland qt6-webchannel qt6-webengine qt6-websockets qt6-webview qtkeychain-qt6 qcoro-qt6 qt6-svg qt6-shadertools
  • Fedora: sudo dnf install qt6-*
  • FreeBSD: sudo pkg install qt6

Build Qt6 using kdesrc-build

A screen recording version is available https://www.youtube.com/watch?v=TDzX0376QyA

Note: If you cannot build the KDE frameworks using kdesrc-build and using the Qt6 provided by your OS (Linux distribution). Because the Qt6 is not complete. You might want to build Qt6 using kdesrc-build.

Note: Building Qt6 using kdesrc-build is an advanced topic.

Set up kdesrc-build clean from scratch following the same procedure as when using "Qt5 and KDE Frameworks 5".

Edit two files.

~/.config/kdesrc-buildrc:

# This file controls options to apply when configuring/building modules, and
# controls which modules are built in the first place.
# List of all options: https://docs.kde.org/trunk5/en/kdesrc-build/kdesrc-build/conf-options-table.html

global
    branch-group kf6-qt6

    # Finds and includes *KDE*-based dependencies into the build.  This makes
    # it easier to ensure that you have all the modules needed, but the
    # dependencies are not very fine-grained so this can result in quite a few
    # modules being installed that you didn't need.
    include-dependencies true

    # Install directory for KDE software
    kdedir ~/kde/usr

    # Directory for downloaded source code
    source-dir ~/kde/src

    # Directory to build KDE into before installing
    # relative to source-dir by default
    build-dir ~/kde/build

    qtdir  ~/kde/usr # Where to install Qt5 if kdesrc-build supplies it

    cmake-options -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DBUILD_WITH_QT6=ON

    # kdesrc-build sets 2 options which is used in options like make-options or set-env
    # to help manage the number of compile jobs that happen during a build:
    #
    # 1. num-cores, which is just the number of detected CPU cores, and can be passed
    #    to tools like make (needed for parallel build) or ninja (completely optional).
    #
    # 2. num-cores-low-mem, which is set to largest value that appears safe for
    #    particularly heavyweight modules based on total memory, intended for
    #    modules like qtwebengine
    num-cores 16
    num-cores-low-mem 12

    # kdesrc-build can install a sample .xsession file for "Custom"
    # (or "XSession") logins,
    install-session-driver false

    # or add a environment variable-setting script to
    # ~/.config/kde-env-master.sh
    install-environment-driver true

    # Stop the build process on the first failure
    stop-on-failure true

    # Use a flat folder layout under ~/kde/src and ~/kde/build
    # rather than nested directories
    directory-layout flat

    # Build with LSP support for everything that supports it
    compile-commands-linking true
    compile-commands-export true

    git-repository-base qt6-copy https://invent.kde.org/qt/qt/
end global

# With base options set, the remainder of the file is used to define modules to build, in the
# desired order, and set any module-specific options.
#
# Modules may be grouped into sets, and this is the normal practice.
#
# You can include other files inline using the "include" command. We do this here
# to include files which are updated with kdesrc-build.

# Common options that should be set for some KDE modules no matter how
# kdesrc-build finds them. Do not comment these out unless you know
# what you are doing.
include /home/username/kde/src/kdesrc-build/kf6-common-options-build-include

# Qt and some Qt-using middleware libraries. Uncomment if your distribution's Qt
# tools are too old but be warned that Qt take a long time to build!
# comment next line after building, to not accidently rebuild qt6
include /home/username/kde/src/kdesrc-build/qt6-build-include
# keep next line uncommented for both builds (kf6 and qt6)
include /home/username/kde/src/kdesrc-build/custom-qt6-libs-build-include

# KF6 and Plasma :)
# keep next line commented for building qt6 build; later uncomment for kf6 build
#include /home/username/kde/src/kdesrc-build/kf6-qt6-build-include

# To change options for modules that have already been defined, use an
# 'options' block. See kf6-common-options-build-include for an example

~/kde/src/kdesrc-build/qt6-build-include:

# Downloads and installs Qt6 from the KDE mirror, using Qt6's CMake support
# exclusively.  Consider this an unofficial build that won't be supported by Qt
# upstream since we don't go through the init-repository script.
# It is probably better to install from your local distribution devel packages
# if possible!
module-set qt6-set
    override-build-system qt6 # technically optional for now

    repository qt6-copy # as defined in kdesrc-buildrc-kf6-sample
    branch     6.4

    # Controls where Qt6 is installed
    prefix ${qtdir}

    # These have been manually placed in dependency order based on the
    # .gitmodules file in https://code.qt.io/cgit/qt/qt5.git/tree/.gitmodules
    # in "essential" or "addons" categories with some additions
    # qtdoc should be last to give it best opportunity to make needed docs
    use-modules qtbase qttools qtshadertools qtdeclarative qtsvg  \
        qtimageformats qtmultimedia qtwayland                    \
        qtwebsockets qtwebchannel qtwebengine qtwebview qtsensors            \
        qtnetworkauth qt5compat qtdoc qtpositioning              \
        qtlocation qtvirtualkeyboard

    # if you want qtwebengine, add it to use-modules after "qtwebchannel" and
    # comment this out. Note qtwebengine has significant and different build
    # requirements of its own.
    #ignore-modules qtwebengine

    # Archiving API requires zstd support which may not be present in your CMake
    cmake-options -DQT_BUILD_TESTS=FALSE -DCMAKE_BUILD_TYPE=RelWithDebInfo \
                  -DQT_AVOID_CMAKE_ARCHIVING_API=TRUE

    cmake-generator Ninja # comment out if you want the default CMake generator
end module-set

options qtwebengine
    # qtwebengine build system is weird, involving make as the top-level driver
    # and then calling ninja for the bulk of the build.  qtwebengine is a bulky
    # module and having ninja use all cores at once may run out of memory if
    # not careful, so we use make to pass less aggressive Ninja flags.
    # num-cores-low-mem needs to be defined in your kdesrc-buildrc.
    make-options NINJAFLAGS=-j${num-cores-low-mem}
end options

# vim: set ft=kdesrc-buildrc:

Portable installation of kdesrc-build

The current directory (pwd) is important when running kdesrc-build. If there exists a file kdesrc-buildrc in the the current directory (pwd), kdesrc-build will prefer that file over ~/.config/kdesrc-buildrc.

If you are interested in or need separate builds of KDE software, like when building with Qt5 or Qt6, you can create a self-contained, portable installation of kdesrc-build in its own folder. This way, you can manage your kdesrc-build configuration files each in their own environment without mixing configurations or having to rebuild the universe every time you want to test a different one.

# To not lose your previous build, make a backup:
mv ~/.config/kdesrc-buildrc ~/.config/kdesrc-buildrc~bak && mv ~/kde ~/kde~bak
# Edit ~/.bashrc file and remove the kdesrc-build block.
# Set up kdesrc-build by following just the chapter https://community.kde.org/Get_Involved/development#Set_up_kdesrc-build
# Make sure to answer "No" when it asks if you want to add the kdesrc-build block to ~/.bashrc.
# Do not source ~/.bashrc.
# Edit ~/.bashrc file and remove the kdesrc-build block.
# Reboot the computer or relogin such that the $PATH environment variable
# does not contain the string "~/kde" or sub directories of "~/kde".
# You should not have built anything using kdesrc-build yet.
# Then move the generated kdesrc-buildrc to inside the new ~/kde folder:
mv ~/.config/kdesrc-buildrc ~/kde
# This will make kdesrc-build use this file even if ~/.config/kdesrc-buildrc exists.
# Then link kdesrc-build and kdesrc-run to the root of the ~/kde folder:
cd ~/kde
ln -s src/kdesrc-build/kdesrc-build .
ln -s src/kdesrc-build/kdesrc-run .
# Edit the file paths in ~/kde/kdesrc-buildrc
cd ~/kde
# Calling ~/kde/kdesrc-build will then only use the current folder's kdesrc-buildrc:
./kdesrc-build frameworks
mv ~/kde ~/kde.5 # Or to any other directory.
# Edit the file paths in the file ~/kde.5/kdesrc-buildrc
cd ~/kde.5
./kdesrc-build frameworks --refresh-build # Because binary files contain file full paths starting with "~/kde".

Two independent kdesrc-build installations on the same machine: kf6-qt6 and kf5-qt5

Make a backup of your existing kdesrc-build setup. mv ~/.config/kdesrc-buildrc ~/.config/kdesrc-buildrc~bak && mv ~/kde ~/kde~bak

Set up a portable kdesrc-build from scratch in the directory ~/kde. See the chapter #Portable installation of kdesrc-build for details. But do not run kdesrc-build to build anything.

In the directory ~/kde there will be a new kdesrc-build installation of type kf5-qt5.

At the end of this procedure there will be two independent and portable kdesrc-build installations:

  • ~/kde5 - kf5-qt5
  • ~/kde6 - kf6-qt6
# kf5-qt5 kdesrc-build installation.
cp ~/kde ~/kde5 # Or to any other directory.
# Edit the file paths in the file ~/kde5/kdesrc-buildrc to point to "~/kde5" instead of "~/kde".
cd ~/kde5
./kdesrc-build frameworks --refresh-build # Because binary files contain file full paths starting with "~/kde".
# Now you have a kdesrc-build kf5-qt5 installation in ~/kde5

# kf6-qt6 kdesrc-build installation.
mv ~/kde ~/kde6 # Or to any other directory.
# Edit the file ~/kde6/kdesrc-buildrc such that the kdesrc-build installation becomes one of type kf6-qt6.
# See this wiki page for examples on how to convert a kf5-qt5 kdesrc-build installation to a kf6-qt6 kdesrc-build installation.
# Edit the file paths in the file ~/kde6/kdesrc-buildrc to point to "~/kde6" instead of "~/kde".
cd ~/kde6
./kdesrc-build frameworks --refresh-build # Because binary files contain file full paths starting with "~/kde".
# Now you have a kdesrc-build kf6-qt6 installation in ~/kde6

Usage:

# Use different terminal windows or tabs (e.g. different Konsole tabs) for
# kf5-qt5 and kf6-qt6

# Go to the terminal window or tab for kf5-qt5.
cd ~/kde5
./kdesrc-build kcalc
./kdesrc-run kcalc

# Go to the terminal window or tab for kf6-qt6.
cd ~/kde6
./kdesrc-build plasma-systemmonitor
./kdesrc-run plasma-systemmonitor

What is the command line of the processes started by kdesrc-build

E.g. what are the command lines that are run by kdesrc-build in order to run the CMake configure step for the kconfig KDE git repository?

kdesrc-build kconfig --no-src --no-include-dependencies --debug --refresh-build |& tee ~/a.txt
kate ~/a.txt &

Returns:

Building kconfig (build system KDE CMake) from frameworks (1/1)
	Queueing PKG_CONFIG_PATH to be set to /home/username/kde/usr/lib/pkgconfig
	Queueing LD_LIBRARY_PATH to be set to /home/username/kde/usr/lib
	Queueing PATH to be set to /home/username/kde/usr/bin:/home/username/kde/src/kdesrc-build:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
	Not prepending /home/username/kde/usr/lib/pkgconfig to PKG_CONFIG_PATH as it appears to already be defined in PKG_CONFIG_PATH.
	Queueing PKG_CONFIG_PATH to be set to /home/username/kde/usr/lib/pkgconfig
	Not prepending /home/username/kde/usr/lib to LD_LIBRARY_PATH as it appears to already be defined in LD_LIBRARY_PATH.
	Queueing LD_LIBRARY_PATH to be set to /home/username/kde/usr/lib
	Not prepending /home/username/kde/usr/bin to PATH as it appears to already be defined in PATH.
	Queueing PATH to be set to /home/username/kde/usr/bin:/home/username/kde/src/kdesrc-build:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
	Queueing CMAKE_PREFIX_PATH to be set to /home/username/kde/usr
	Queueing CMAKE_MODULE_PATH to be set to /home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake
	Queueing XDG_DATA_DIRS to be set to /home/username/kde/usr/share:/usr/share/plasma:/home/username/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop
	Source update complete for kconfig: Skipped
	cd /home/username/kde/build

	Preparing build system for kconfig.
	Removing files in build directory for kconfig
	Old build system cleaned, starting new build system.
	cd /home/username/kde/build/kconfig

	Running cmake targeting Unix Makefiles...
run_logged_p(): Module kconfig, Command: {'cmake', '-B', '.', '-S', '/home/username/kde/src/kconfig', '-G', 'Unix Makefiles', '-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON', '-DCMAKE_BUILD_TYPE=Debug', '-DQT_MAJOR_VERSION=6', '-DBUILD_WITH_QT6=ON', '-DBUILD_TESTING=TRUE', '-DBUILD_WITH_QT6=ON', '-DEXCLUDE_DEPRECATED_BEFORE_AND_AT=5.99.0', '-DCMAKE_CXX_FLAGS:STRING=-pipe', '-DCMAKE_INSTALL_PREFIX=/home/username/kde/usr'} from /home/username/kde/build/kconfig
	cd /home/username/kde/build/kconfig

log_command(): Module kconfig, Command: cmake -B . -S /home/username/kde/src/kconfig -G Unix Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DBUILD_WITH_QT6=ON -DBUILD_TESTING=TRUE -DBUILD_WITH_QT6=ON -DEXCLUDE_DEPRECATED_BEFORE_AND_AT=5.99.0 -DCMAKE_CXX_FLAGS:STRING=-pipe -DCMAKE_INSTALL_PREFIX=/home/username/kde/usr
run_logged_p(): kconfig cmake complete: 0

Therefore, kdesrc-build has run the following commands:

# Preparing build system for kconfig. Removing files in build directory for kconfig. Old build system cleaned, starting new build system.
rm -rf /home/username/kde/build/kconfig
mkdir -p /home/username/kde/build/kconfig

# Queueing X to be set to ...
PKG_CONFIG_PATH=/home/username/kde/usr/lib/pkgconfig
LD_LIBRARY_PATH=/home/username/kde/usr/lib
PATH=/home/username/kde/usr/bin:/home/username/kde/src/kdesrc-build:/home/username/.local/bin:/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
CMAKE_PREFIX_PATH=/home/username/kde/usr
CMAKE_MODULE_PATH=/home/username/kde/usr/lib64/cmake:/home/username/kde/usr/lib/cmake
XDG_DATA_DIRS=/home/username/kde/usr/share:/usr/share/plasma:/home/username/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop

cd /home/username/kde/build/kconfig

cmake -B . -S /home/username/kde/src/kconfig -G Unix\ Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE=Debug -DQT_MAJOR_VERSION=6 -DBUILD_WITH_QT6=ON -DBUILD_TESTING=TRUE -DBUILD_WITH_QT6=ON -DEXCLUDE_DEPRECATED_BEFORE_AND_AT=5.99.0 -DCMAKE_CXX_FLAGS:STRING=-pipe -DCMAKE_INSTALL_PREFIX=/home/username/kde/usr

How to write the entire verbose STDOUT and STDERR of kdesrc-build to a file

script -eq -c "kdesrc-build kconfig --no-src --no-include-dependencies --refresh-build --debug" ~/a.txt

Note: you can remove the terminal ANSI color codes using e.g. ansi2txt, available e.g. in the package colorized-logs. E.g.

sudo apt install colorized-logs
cat ~/a.txt | ansi2txt > ~/a_script.txt

script -eq -c "command" ~/a.txt is better than command |& tee ~/a.txt because kdesrc-build behaves differently if it is run in a user interactive terminal session (isatty).

If using tee, part of the output of kdesrc-build will not be written to file. E.g. the output of the cmake step, the final part of the make -j step, the final part of the make install step.

Other CPU architectures than x86_64/amd64 and x86

You can build and develop KDE projects using a Linux OS installed on an ARM architecture CPU.

kdesrc-build issues

"kdesrc-build kfilemetadata" fails because of appimage

This happens on KDE neon.

Solution:

sudo apt remove libappimage-dev

wayland-protocols is too old, e.g. "kdesrc-build kidletime" fails

mkdir -p ~/kde/misc && cd ~/kde/misc
wget https://gitlab.freedesktop.org/wayland/wayland-protocols/-/releases/1.31/downloads/wayland-protocols-1.31.tar.xz
tar -xJvf wayland-protocols-*.tar.xz && mv wayland-protocols-*/ wayland-protocols
cd wayland-protocols
meson setup builddir --prefix $HOME/kde/usr
meson compile -C builddir
meson install -C builddir

"kdesrc-build kpat" fails because of black-hole-solitaire

This happens on Debian/Ubuntu/Kubuntu. Because there is no Linux distribution binary package for https://github.com/shlomif/black-hole-solitaire.

Solution: append at the end of kdesrc-buildrc file:

options kpat
    cmake-options -DWITH_BH_SOLVER=OFF
end options

"kdesrc-build frameworks" fails because of qtwebkit

Some Linux OSes do not have a package for qtwebkit anymore. E.g. the Arch Linux family.

When you want to build all of the KDE Frameworks 5, use the kdesrc-build command line from https://community.kde.org/Get_Involved/development#KDE_Frameworks [broken anchor].

libdisplay-info is not available

If your Linux OS does not have a package for libdisplay-info. Append at the end of the file kdesrc-buildrc:

module libdisplay-info
  repository https://gitlab.freedesktop.org/emersion/libdisplay-info.git
end module