Adapt build system for building qt6
(cherry picked from commit 8f762b3ff60ccbc5e7a2b0f6e6e13ed324b8bc55)