From f7cb8fd6478544eddd321dedf5ab8a55794ab39d Mon Sep 17 00:00:00 2001 From: Olivier Le Doeuff Date: Mon, 3 Oct 2022 13:27:38 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Only=20look=20for=20qt=20if=20no?= =?UTF-8?q?t=20`Qt::Core`=20target=20exists?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix issue if upper project use `find_package(Qt5)` and Qt6 is also installed. This require at least Qt5.15 to use versionless `Qt` target namespace --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7929d87..72f127e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,8 +119,10 @@ endif() # ───── DEPENDENCIES ───── -find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) -find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Qml REQUIRED) +if(NOT TARGET Qt::Core) + find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) + find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Qml REQUIRED) +endif() # ───── LIBRARY ─────