CMake: Fix old style find_package(Qt6Foo) to work

Each module package needs to first find the Qt6 package to ensure
that all the necessary info is setup for further depedencies to be
found.

Task-number: QTBUG-81672
Change-Id: I3ee608d24c1efbb63a063261fb36341bf52fb78d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-07-14 11:25:47 +02:00
parent 044ca0b8a8
commit bc29555e6e
2 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,12 @@
# Make sure @INSTALL_CMAKE_NAMESPACE@ is found before anything else.
find_dependency(@INSTALL_CMAKE_NAMESPACE@ @PROJECT_VERSION@
PATHS "${CMAKE_CURRENT_LIST_DIR}/.." ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH
)
if (NOT @INSTALL_CMAKE_NAMESPACE@_FOUND)
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
return()
endif()
# note: _third_party_deps example: "ICU\\;1.0\\;i18n uc data;ZLIB\\;\\;"
set(_third_party_deps "@third_party_deps@")

View File

@ -145,7 +145,7 @@ function(qt_internal_create_module_depends_file target)
"${INSTALL_CMAKE_NAMESPACE}${target}Tools\;${PROJECT_VERSION}")
endif()
# Dirty hack because https://gitlab.kitware.com/cmake/cmake/issues/19200
# Dirty deduplication hack because of https://gitlab.kitware.com/cmake/cmake/issues/19200
foreach(dep ${target_deps})
if(dep)
list(FIND target_deps_seen "${dep}" dep_seen)
@ -157,6 +157,12 @@ function(qt_internal_create_module_depends_file target)
list(GET dep 0 dep_name)
list(GET dep 1 dep_ver)
# Skip over Qt6 dependency, because we will manually handle it in the Dependencies
# file before everything else, to ensure that find_package(Qt6Core)-style works.
if(dep_name STREQUAL INSTALL_CMAKE_NAMESPACE)
continue()
endif()
list(APPEND target_deps_seen "${dep_name}\;${dep_ver}")
endif()
endif()