summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-08-18 18:41:18 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-19 16:58:42 +0000
commit77b655c5cfa9e4423b36f51f152967dc169fbc2d (patch)
tree55d587259beabeb3f1ebc86eebf9f77d76ad5348 /cmake
parent48954c9d0bf2ff7288a3d06f0200706813171c68 (diff)
CMake: Pass Qt6_FIND_VERSION in Qt6Config when looking for components
Pass Qt6_FIND_VERSION to components when the find_package(Qt6 ${ver} COMPONENTS Foo) signature is used. Create a ConfigVersion file for BuildInternals, so that BuildInternals passes the version check. Fix qt_configure_file to look in the _qt_6_config_cmake_dir folder for the template file rather than Qt6_DIR, because Qt6_DIR might be accidentally unset after a failed find_package(Qt6) call and the error is not helpful then. We already pass versions everywhere else when looking for dependencies, like in ModuleDependencies.cmake.in, PluginDependencies.cmake.in, ModuleToolsDependencies.cmake.in. Fixes: QTBUG-91737 Change-Id: Ief1da0c6f239c935385e7ce662951e85ccfdf130 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 654431286931a70645fc3be39570f9109c95fe9e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBaseGlobalTargets.cmake7
-rw-r--r--cmake/QtCMakeHelpers.cmake4
-rw-r--r--cmake/QtConfig.cmake.in1
3 files changed, 10 insertions, 2 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index fd41566c23..8218312493 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -34,8 +34,15 @@ configure_file(
@ONLY
)
+write_basic_package_version_file(
+ "${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
qt_install(FILES
"${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfig.cmake"
+ "${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfigVersion.cmake"
"${__build_internals_build_dir}/QtBuildInternalsExtra.cmake"
DESTINATION "${__build_internals_install_dir}"
COMPONENT Devel
diff --git a/cmake/QtCMakeHelpers.cmake b/cmake/QtCMakeHelpers.cmake
index 356c8ce357..e47d9878e1 100644
--- a/cmake/QtCMakeHelpers.cmake
+++ b/cmake/QtCMakeHelpers.cmake
@@ -15,12 +15,12 @@ function(qt_configure_file)
if(arg_CONTENT)
set(template_name "QtFileConfigure.txt.in")
# When building qtbase, use the source template file.
- # Otherwise use the installed file.
+ # Otherwise use the installed file (basically wherever Qt6 package is found).
# This should work for non-prefix and superbuilds as well.
if(QtBase_SOURCE_DIR)
set(input_file "${QtBase_SOURCE_DIR}/cmake/${template_name}")
else()
- set(input_file "${Qt6_DIR}/${template_name}")
+ set(input_file "${_qt_6_config_cmake_dir}/${template_name}")
endif()
set(__qt_file_configure_content "${arg_CONTENT}")
elseif(arg_INPUT)
diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in
index 2c4058f0da..ce83233b91 100644
--- a/cmake/QtConfig.cmake.in
+++ b/cmake/QtConfig.cmake.in
@@ -118,6 +118,7 @@ foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
endif()
find_package(@INSTALL_CMAKE_NAMESPACE@${module}
+ ${@INSTALL_CMAKE_NAMESPACE@_FIND_VERSION}
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET}
PATHS
${_qt_cmake_dir}