Plasma-Mobile fails to build on yocto work/qt6 branch

When trying to build plasma-mobile on the qt6 branch, it leads to this error:

| CMake Error at /${BUILDIR}/tmp/work/${ARCH-linux/plasma-mobile/5.27.80-r0/recipe-sysroot/usr/lib/cmake/KWin/KWinTargets.cmake:70 (set_target_properties):
|   The link interface of target "KWin::kwin" contains:
| 
|     Wayland::Server
| 
|   but the target was not found. Possible reasons include:
| 
|     * There is a typo in the target name.
|     * A find_package call is missing for an IMPORTED target.
|     * An ALIAS target is missing.
| 
| Call Stack (most recent call first):
|    ${REDACTED}/plasma-mobile/5.27.80-r0/recipe-sysroot/usr/lib/cmake/KWin/KWinConfig.cmake:46 (include)
|   CMakeLists.txt:86 (find_package)

I think Wayland::Server is provided by Qt Gui, so adding the dependency ought to work, but it didn’t. I tried reordering some of the find_package but couldn’t make it work.

Running on this sha: e82af2b68198682ce360a54ba693280396f39207 on plasma-mobile

Wayland::Server has nothing to do with Qt, it’s the sever half of the wayland library (https://gitlab.freedesktop.org/wayland/wayland)

The dependency seems present on the KWin side, so I tried adding that:

find_package(Wayland REQUIRED COMPONENTS Server)

That seems to work, but wondering why I had to add that to make it work.