KDE Packaging

This document outlines the best practices for packaging software using the KDE frameworks, for use in Fedora.

Build Dependencies

If using cmake, the following BuildRequires are a MUST:

BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: kf6-rpm-macros

kf6-rpm-macros needs to be changed to kf5-rpm-macros if building for Plasma 5 instead of Plasma 6.

Available Macros

The following macros are used in the building of KDE packages. Note that the version of macros (i.e. %cmake_kf5 and %cmake_kf6) can be changed depending on which version of Plasma you are building for.

%cmake_kf6

Not unlike %cmake, this macro defines CFLAGS, LDFLAGS, etc. and calls %__cmake with appropriate parameters (-DCMAKE_INSTALL_PREFIX:PATH=/usr and such), but with additional KDE-specific flags and parameters. You can pass -Doption=value to this macro in order to set options for the buildsystem.

%stable_kf6

Used in the package’s source links, if the package is released on the official KDE download server. Outputs either stable or unstable depending on the version of the package.

Here’s an example of how it would look like:

Source0: http://download.kde.org/%{stable_kf6}/release-service/%{version}/src/%{name}-%{version}.tar.xz
%find_lang_kf6

This macro is sometimes used instead of %find_lang in packages using language files ending in _qt.qm.

Macros for paths set and used by build systems

The following table lists macros which are widely used in fedora .spec files. Those macros are provided by the kf5-rpm-macros (For Plasma 5) and kf6-rpm-macros (For Plasma 6) packages.

For Plasma 5, the following macros can simply have their version number changed to reflect the Plasma 5 version (For example, %{_kf6_datadir} would become %{_kf5_datadir}).

macro definition comment

%{_kf6_prefix}

%{_prefix}

%{_kf6_archdatadir}

%{_qt6_archdatadir}

default: /usr/lib64/qt6

%{_kf6_bindir}

%{_kf6_prefix}/bin

%{_kf6_datadir}

%{_datadir}

default: /usr/share

%{_kf6_includedir}

%{_includedir}/KF6

default: /usr/include/KF6

%{_kf6_libdir}

%{_exec_prefix}/%{_lib}

default: /usr/%{_lib}

%{_kf6_libexecdir}

%{_libexecdir}/kf6

default: /usr/libexec/kf6

%{_kf6_metainfodir}

%{_metainfodir}

default: /usr/share/metainfo

%{_kf6_qtplugindir}

%{_qt6_plugindir}

default: +/usr/%{_lib}+/qt6/plugins

%{_kf6_plugindir}

%{_qt6_plugindir}/kf6

default: +/usr/%{_lib}+/qt6/plugins/kf6

%{_kf6_sysconfdir}

%{_sysconfdir}

default: /etc

%{_kf6_mandir}

%{_kf6_datadir}/man

default: /usr/share/man

%{_kf6_qmldir}

%{_kf6_archdatadir}/qml

default: /usr/lib64/qt6/qml