summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Köhne <kai.koehne@qt.io>2021-08-04 17:36:22 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-08-18 16:38:27 +0000
commit89760e011555ae375e687daf9d7c4e1333a33797 (patch)
treef53fb682376ae78193ae9c98092bafbecc064b5f
parent7b47e680893d2c23bfa881a5f6d8499b683b925b (diff)
Pick up *Tools components also from host Qt
Let find_package(Qt6 COMPONENTS LinguistTools) for a cross-compiled Qt fall back to search LinguistTools in the host Qt. Use the same trick as in QtModuleDependencies.cmake: Prepend both CMAKE_PREFIX_PATH and CMAKE_FIND_ROOT_PATH with the QT_HOST_PATH (respective ${QT_HOST_PATH}/lib/cmake). Furthermore adding ${QT_HOST_PATH}/lib/cmake to PATHS argument makes sure that find_package will work even with NO_DEFAULT_PATH. Make sure not to match ShaderTools and Tools packages. ShaderTools is the cross-compiled package, the host package name is ShaderToolsTools. Tools is the cross-compiled module from qttools. Allow an opt out via a QT_NO_FIND_HOST_TOOLS_PATH_MANIPULATION variable in case that we accidentally match more packages ending in Tools that are actually cross-compiled packages. Fixes: QTBUG-95602 Change-Id: Ib0a787716fa529e36f22356da069e705d9eed5fa Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit d2359b2d4e5db6c42158d536d6e2a2af5ea1e59c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--cmake/QtConfig.cmake.in27
1 files changed, 27 insertions, 0 deletions
diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in
index 451d4191a7..7e235bcbfe 100644
--- a/cmake/QtConfig.cmake.in
+++ b/cmake/QtConfig.cmake.in
@@ -70,6 +70,23 @@ if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
endif()
foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
+ if(NOT "${QT_HOST_PATH}" STREQUAL ""
+ AND "${module}" MATCHES "Tools$"
+ AND NOT "${module}" MATCHES "ShaderTools$"
+ AND NOT "${module}" MATCHES "^Tools$"
+ AND NOT QT_NO_FIND_HOST_TOOLS_PATH_MANIPULATION)
+ # Make sure that a Qt*Tools package is also looked up in QT_HOST_PATH.
+ # But don't match QtShaderTools and QtTools which are cross-compiled target package names.
+ # Allow opt out just in case.
+ # TODO: Handle a hypothetical QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH
+ # See QTBUG-94524
+ set(__qt_find_package_host_qt_path "${QT_HOST_PATH}/lib/cmake")
+ set(__qt_backup_cmake_prefix_path "${CMAKE_PREFIX_PATH}")
+ set(__qt_backup_cmake_find_root_path "${CMAKE_FIND_ROOT_PATH}")
+ list(PREPEND CMAKE_PREFIX_PATH "${__qt_find_package_host_qt_path}")
+ list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}")
+ endif()
+
find_package(@INSTALL_CMAKE_NAMESPACE@${module}
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET}
${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_REQUIRED}
@@ -78,8 +95,18 @@ foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS})
${_qt_additional_packages_prefix_path}
${_qt_additional_packages_prefix_path_env}
${QT_EXAMPLES_CMAKE_PREFIX_PATH}
+ ${__qt_find_package_host_qt_path}
${__qt_use_no_default_path_for_qt_packages}
)
+
+ if(NOT "${__qt_find_package_host_qt_path}" STREQUAL "")
+ set(CMAKE_PREFIX_PATH "${__qt_backup_cmake_prefix_path}")
+ set(CMAKE_FIND_ROOT_PATH "${__qt_backup_cmake_find_root_path}")
+ unset(__qt_backup_cmake_prefix_path)
+ unset(__qt_backup_cmake_find_root_path)
+ unset(__qt_find_package_host_qt_path)
+ endif()
+
if (NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
string(CONFIGURE ${_qt5_module_location_template} _expected_module_location @ONLY)