summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-07-13 19:09:32 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-07-21 09:29:13 +0200
commit78491331a8b6d176b8ed60c8c8dc8f82aa7c73c2 (patch)
tree7e05fe08fb0e22365247198612d32e469ba3badc /cmake
parentc01ba43c9bf45775b57753ecbf3247e719543eb2 (diff)
CMake: Allow setting Qt6_DIR to find packages when not cross-compiling
So far we always recommended that developers set CMAKE_PREFIX_PATH to point to the location of the Qt installation so that Qt packages are found by CMake. In Qt5 one could also set the Qt5_DIR variable to $qt/lib/cmake/Qt5 to allow the following signature to work: find_package(Qt5 COMPONENTS Core) This was not sufficient in Qt6 because the CoreTools dependency would not be found. Fix this by also looking into the parent folder of CMAKE_CURRENT_LIST_DIR as well as _qt_cmake_dir, like we already do for regular non-Tools packages in _qt_internal_find_dependencies. Note that setting Qt6_DIR is not sufficient for cross-compilation if the qt.toolchain.cmake file is not used. Aside from platform specific options that would have to be passed manually to CMake (like -DCMAKE_SYSTEM_NAME=iOS for iOS) and passing a QT_HOST_PATH value, the code would also need to be adapted to do the necessary CMAKE_FIND_ROOT_PATH manipulations to ensure that dependent packages are found. Task-number: QTBUG-97615 Change-Id: I10c419632d43bb929e184bab3b9d3d27a35ea87a Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 0e2b385c5b77549fb8a25651840821076fb6d93c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtPublicDependencyHelpers.cmake2
1 files changed, 2 insertions, 0 deletions
diff --git a/cmake/QtPublicDependencyHelpers.cmake b/cmake/QtPublicDependencyHelpers.cmake
index b04363b1db..234ef7e515 100644
--- a/cmake/QtPublicDependencyHelpers.cmake
+++ b/cmake/QtPublicDependencyHelpers.cmake
@@ -58,6 +58,8 @@ macro(_qt_internal_find_tool_dependencies target target_dep_list)
${__qt_${target}_version}
${__qt_${target}_find_package_args}
PATHS
+ "${CMAKE_CURRENT_LIST_DIR}/.."
+ "${_qt_cmake_dir}"
${_qt_additional_packages_prefix_paths}
)
if (NOT ${__qt_${target}_pkg}_FOUND)