To build KDE 6 on Ubuntu 22.04, other than steps on https://community.kde.org/Get_Involved/development/Build_software_with_kdesrc-build, there are other things need to be noticed:

export PKG_CONFIG_PATH=/opt/kde/usr/lib/pkgconfig:$PKG_CONFIG_PATH
  • KWin requires libdisplay-info, install it from newer repo, e.g. Debian Sid; or check the link above
  • KWin requires Qt6 built with atspi_accessibility, which requires ATSPI2, so need to install libatspi2.0-dev before build Qt6
  • plasma-desktop: SDL2 in Ubuntu 22.04 not new enough to have SDL_JoystickPath, disable game controller support in kcms/CMakeLists.txt
  • xdg-desktop-portal-kde requires QtPrintSupport/private/qcups_p.h, so install libcups2-dev before building Qt6