summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/QtFindWrapHelper.cmake21
-rw-r--r--tests/auto/cmake/RunCMake/CMakeLists.txt15
-rw-r--r--tests/auto/cmake/RunCMake/Qt6DirConfiguration/CMakeLists.txt3
-rw-r--r--tests/auto/cmake/RunCMake/Qt6DirConfiguration/RunCMakeTest.cmake19
-rw-r--r--tests/auto/cmake/RunCMake/Qt6DirConfiguration/project.cmake19
5 files changed, 76 insertions, 1 deletions
diff --git a/cmake/QtFindWrapHelper.cmake b/cmake/QtFindWrapHelper.cmake
index 506bfc7fadb..c43824b8234 100644
--- a/cmake/QtFindWrapHelper.cmake
+++ b/cmake/QtFindWrapHelper.cmake
@@ -66,7 +66,26 @@ macro(qt_find_package_system_or_bundled _unique_prefix)
endif()
if(NOT TARGET "${${_unique_prefix}_qt_package_target_to_use}")
- find_package("${${_unique_prefix}_qt_package_name_to_use}")
+ if(QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET})
+ set(${_unique_prefix}_qt_use_no_default_path_for_qt_packages "NO_DEFAULT_PATH")
+ if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
+ set(${_unique_prefix}_qt_use_no_default_path_for_qt_packages "")
+ endif()
+
+ # For bundled targets, we want to limit search paths to the relevant Qt search paths.
+ find_package("${${_unique_prefix}_qt_package_name_to_use}"
+ PATHS
+ ${QT_BUILD_CMAKE_PREFIX_PATH}
+ "${CMAKE_CURRENT_LIST_DIR}/.."
+ ${_qt_cmake_dir}
+ ${_qt_additional_packages_prefix_paths}
+ ${${_unique_prefix}_qt_use_no_default_path_for_qt_packages}
+ )
+ else()
+ # For the non-bundled case we will look for FindWrapSystemFoo.cmake module files,
+ # which means we should not specify any PATHS.
+ find_package("${${_unique_prefix}_qt_package_name_to_use}")
+ endif()
endif()
if(TARGET "${${_unique_prefix}_qt_package_target_to_use}")
diff --git a/tests/auto/cmake/RunCMake/CMakeLists.txt b/tests/auto/cmake/RunCMake/CMakeLists.txt
index 2ed86266d89..313bf464214 100644
--- a/tests/auto/cmake/RunCMake/CMakeLists.txt
+++ b/tests/auto/cmake/RunCMake/CMakeLists.txt
@@ -1,3 +1,18 @@
# Add RunCMake tests using `add_RunCMake_test()`
add_RunCMake_test(QtFlagHandlingHelpers "-DQt6_DIR=${Qt6_DIR}")
+
+set(extra_run_cmake_args "-DQt6_DIR=${Qt6_DIR}")
+if(TARGET Qt::Gui)
+ list(APPEND extra_run_cmake_args "-DHAS_GUI=TRUE")
+endif()
+if(TARGET Qt::DBus)
+ list(APPEND extra_run_cmake_args "-DHAS_DBUS=TRUE")
+endif()
+if(TARGET Qt::Widgets)
+ list(APPEND extra_run_cmake_args "-DHAS_WIDGETS=TRUE")
+endif()
+if(TARGET Qt::OpenGL)
+ list(APPEND extra_run_cmake_args "-DHAS_OPENGL=TRUE")
+endif()
+add_RunCMake_test(Qt6DirConfiguration ${extra_run_cmake_args})
diff --git a/tests/auto/cmake/RunCMake/Qt6DirConfiguration/CMakeLists.txt b/tests/auto/cmake/RunCMake/Qt6DirConfiguration/CMakeLists.txt
new file mode 100644
index 00000000000..d0ef37d817f
--- /dev/null
+++ b/tests/auto/cmake/RunCMake/Qt6DirConfiguration/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.16)
+project(${RunCMake_TEST} LANGUAGES CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/tests/auto/cmake/RunCMake/Qt6DirConfiguration/RunCMakeTest.cmake b/tests/auto/cmake/RunCMake/Qt6DirConfiguration/RunCMakeTest.cmake
new file mode 100644
index 00000000000..0e108cef73e
--- /dev/null
+++ b/tests/auto/cmake/RunCMake/Qt6DirConfiguration/RunCMakeTest.cmake
@@ -0,0 +1,19 @@
+include(RunCMake)
+
+set(cmake_opts "-DQt6_DIR=${Qt6_DIR}")
+
+# Depending on which module features were used when building Qt, look up each of the respective
+# packages.
+if(HAS_GUI)
+ list(APPEND cmake_opts "-DHAS_GUI=TRUE")
+endif()
+if(HAS_DBUS)
+ list(APPEND cmake_opts "-DHAS_DBUS=TRUE")
+endif()
+if(HAS_WIDGETS)
+ list(APPEND cmake_opts "-DHAS_WIDGETS=TRUE")
+endif()
+if(HAS_OPENGL)
+ list(APPEND cmake_opts "-DHAS_OPENGL=TRUE")
+endif()
+run_cmake_with_options(project ${cmake_opts})
diff --git a/tests/auto/cmake/RunCMake/Qt6DirConfiguration/project.cmake b/tests/auto/cmake/RunCMake/Qt6DirConfiguration/project.cmake
new file mode 100644
index 00000000000..b90465e0967
--- /dev/null
+++ b/tests/auto/cmake/RunCMake/Qt6DirConfiguration/project.cmake
@@ -0,0 +1,19 @@
+# This should successfully find the Qt6::BundledZLIB package in a -qt-zlib
+# configuration.
+find_package(Qt6 COMPONENTS Core)
+
+# Depending on which module features were used when building Qt, look up each of the respective
+# packages, those might also look for bundled libraries.
+if(HAS_GUI)
+ find_package(Qt6 COMPONENTS Gui)
+endif()
+if(HAS_DBUS)
+ find_package(Qt6 COMPONENTS DBus)
+endif()
+if(HAS_WIDGETS)
+ find_package(Qt6 COMPONENTS Widgets)
+endif()
+if(HAS_OPENGL)
+ find_package(Qt6 COMPONENTS OpenGL)
+endif()
+