diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-02-03 14:13:25 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-03-16 15:56:17 +0100 |
commit | d1c56073b4cf3346168413e7d931c63355307e9d (patch) | |
tree | 2f7d4abb0f35abf3a4218dc526737a499d1e9376 /cmake | |
parent | c89da212494eded0c4444e573ad7e8c5877350ea (diff) | |
download | qtbase-d1c56073b4cf3346168413e7d931c63355307e9d.tar.gz |
CMake: Don't rely on CMAKE_FIND_ROOT_PATH_MODE_PACKAGE for examples
We shouldn't set CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to BOTH when
cross-building examples without ExternalProjects.
Instead append the $build_tree_prefix to CMAKE_FIND_ROOT_PATH
and $build_tree_prefix/lib/cmake to QT_EXAMPLES_CMAKE_PREFIX_PATH
to circumvent the usual CMake path-rerooting issue.
This ensures that the build-tree Config files are found by the in-tree
find_package calls when cross-building examples.
Pick-to: 6.2 6.3
Task-number: QTBUG-96232
Change-Id: I4e31f0bf3dbfeb4339823fe09addda3ae83f12c3
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index c2225e4ed4..a515fcd43d 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -719,12 +719,6 @@ macro(qt_internal_set_up_build_dir_package_paths) list(APPEND CMAKE_PREFIX_PATH "${QT_BUILD_DIR}") # Make sure the CMake config files do not recreate the already-existing targets set(QT_NO_CREATE_TARGETS TRUE) - - # TODO: Remove reliance on CMAKE_FIND_ROOT_PATH_MODE_PACKAGE and instead pass any required - # prefixes as a combination of CMAKE_PREFIX_PATH and CMAKE_FIND_ROOT_PATH like we do in - # qt_internal_add_tool. - set(BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}) - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH") endmacro() macro(qt_examples_build_begin) @@ -807,9 +801,12 @@ macro(qt_examples_build_begin) # Appending to CMAKE_PREFIX_PATH helps find the initial Qt6Config.cmake. # Appending to QT_EXAMPLES_CMAKE_PREFIX_PATH helps find components of Qt6, because those # find_package calls use NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH is ignored. + # Appending to CMAKE_FIND_ROOT_PATH ensures the components are found while cross-compiling + # without setting CMAKE_FIND_ROOT_PATH_MODE_PACKAGE to BOTH. if(NOT QT_IS_EXTERNAL_EXAMPLES_BUILD OR NOT __qt_all_examples_ported_to_external_projects) qt_internal_set_up_build_dir_package_paths() - list(APPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${QT_BUILD_DIR}") + list(APPEND CMAKE_FIND_ROOT_PATH "${QT_BUILD_DIR}") + list(APPEND QT_EXAMPLES_CMAKE_PREFIX_PATH "${QT_BUILD_DIR}/lib/cmake") endif() # Because CMAKE_INSTALL_RPATH is empty by default in the repo project, examples need to have @@ -862,8 +859,6 @@ macro(qt_examples_build_end) endif() endforeach() - set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ${BACKUP_CMAKE_FIND_ROOT_PATH_MODE_PACKAGE}) - install(CODE " # Restore backed up CMAKE_INSTALL_PREFIX. set(CMAKE_INSTALL_PREFIX \"\${_qt_internal_examples_cmake_install_prefix_backup}\") |