CMake: Fix find_package puzzle piece of top-level cross-builds

The subdirectories, the top-level CMakeLists.txt adds, contain
find_package(Qt6 COMPONENTS ...) calls. When cross-compiling to Android,
the toolchain file sets CMAKE_FIND_ROOT_PATH and
CMAKE_FIND_ROOT_PATH_MODE to ONLY. That means, the packages that are
created in qtbase can never be found by other Qt repositories, e.g.
qtdeclarative.

Append the qtbase build dir to CMAKE_FIND_ROOT_PATH to find the Qt
packages of the build dir when cross-compiling. Because of some CMake
idiosyncracy, we need to append "${QtBase_BINARY_DIR}/lib/cmake" to
CMAKE_PREFIX_PATH and not just "${QtBase_BINARY_DIR}". See
qtbase/ec90f9013b4c6b63d7e03a964f66f97329be7885 for details.

Task-number: QTBUG-85080
Change-Id: I799f851316538c310d73f5ab59c809229e16e8a8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann
2020-10-08 12:31:03 +02:00
parent 643172a8df
commit 70dc8438fc

View File

@@ -82,7 +82,8 @@ list(REMOVE_ITEM git_module_list qtbase)
add_subdirectory(qtbase)
if (NOT QT_BUILD_STANDALONE_TESTS)
list(APPEND CMAKE_PREFIX_PATH "${QtBase_BINARY_DIR}")
list(APPEND CMAKE_PREFIX_PATH "${QtBase_BINARY_DIR}/lib/cmake")
list(APPEND CMAKE_FIND_ROOT_PATH "${QtBase_BINARY_DIR}")
endif()
foreach(module IN LISTS git_module_list)