Fix race condition when building
See https://mail.kde.org/pipermail/release-team/2023-August/013120.html (cherry picked from commit 45b73444)
See https://mail.kde.org/pipermail/release-team/2023-August/013120.html (cherry picked from commit 45b73444)
mentioned in commit d3f20b3d