CMake: Fix dbus duplicate target errors in top-level builds

Fixes the 'add_library cannot create imported target "dbus-1"
because another target with the same name already exists' error
when doing top-level static builds.

It's caused by the loading of Qt6DBus dependency when configuring
qttools.

Task-number: QTBUG-84874
Change-Id: Ia84ed460c4ce25de45fb41cb13edd0e63a276f11
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-06-10 11:37:55 +02:00
parent 56f40cdca6
commit a6eb7c641b

View File

@ -2,7 +2,10 @@
# Work around that:-/
# See https://gitlab.freedesktop.org/dbus/dbus/issues/267 for more information
if(DBus1_FOUND OR WrapDBus1_FOUND)
# When doing top-level static Qt builds, we need to protect against double creation of the dbus
# target.
if(DBus1_FOUND OR WrapDBus1_FOUND OR TARGET dbus-1)
set(WrapDBus1_FOUND 1)
return()
endif()