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}\")