diff options
Diffstat (limited to 'cmake/qt.toolchain.cmake.in')
-rw-r--r-- | cmake/qt.toolchain.cmake.in | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in index 49553c9bbf..9a8019a3da 100644 --- a/cmake/qt.toolchain.cmake.in +++ b/cmake/qt.toolchain.cmake.in @@ -58,13 +58,58 @@ get_filename_component(QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX # one level higher is what we're looking for. get_filename_component(QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) +# REROOT_PATH_ISSUE_MARKER # There's a subdirectory check in cmake's cmFindCommon::RerootPaths() function, that doesn't handle # the case of CMAKE_PREFIX_PATH == CMAKE_FIND_ROOT_PATH for a particular pair of entries. # Instead of collapsing the search prefix (which is the case when one is a subdir of the other), # it concatenates them creating an invalid path. Workaround it by setting the root path to the # Qt install prefix, and the prefix path to the lib/cmake subdir. -set(CMAKE_PREFIX_PATH "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR};${CMAKE_PREFIX_PATH}") -set(CMAKE_FIND_ROOT_PATH "${QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX};${CMAKE_FIND_ROOT_PATH}") +list(PREPEND CMAKE_PREFIX_PATH "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}") +list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX}") + +# Handle packages located in QT_ADDITIONAL_PACKAGES_PREFIX_PATH when cross-compiling. Needed for +# Conan. +# We prepend to CMAKE_PREFIX_PATH so that a find_package(Qt6Foo) call works, without having to go +# through the Qt6 umbrella package. The paths must end in lib/cmake to esnsure the package is found. +# See REROOT_PATH_ISSUE_MARKER. +# We prepend to CMAKE_FIND_ROOT_PATH, due to the bug mentioned at REROOT_PATH_ISSUE_MARKER. +set(__qt_toolchain_additional_packages_prefixes "") +if(QT_ADDITIONAL_PACKAGES_PREFIX_PATH) + list(APPEND __qt_toolchain_additional_packages_prefixes + ${QT_ADDITIONAL_PACKAGES_PREFIX_PATH}) +endif() +if(DEFINED ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH} + AND NOT "$ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH}" STREQUAL "") + list(APPEND __qt_toolchain_additional_packages_prefixes + $ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH}) +endif() + +if(__qt_toolchain_additional_packages_prefixes) + set(__qt_toolchain_additional_packages_root_paths "") + set(__qt_toolchain_additional_packages_prefix_paths "") + + foreach(__qt_additional_path IN LISTS __qt_toolchain_additional_packages_prefixes) + file(TO_CMAKE_PATH "${__qt_additional_path}" __qt_additional_path) + get_filename_component(__qt_additional_path "${__qt_additional_path}" ABSOLUTE) + set(__qt_additional_path_lib_cmake "${__qt_additional_path}") + if(NOT __qt_additional_path_lib_cmake MATCHES "/lib/cmake$") + string(APPEND __qt_additional_path_lib_cmake "/lib/cmake") + endif() + + list(APPEND __qt_toolchain_additional_packages_root_paths + "${__qt_additional_path}") + list(APPEND __qt_toolchain_additional_packages_prefix_paths + "${__qt_additional_path_lib_cmake}") + endforeach() + list(PREPEND CMAKE_PREFIX_PATH ${__qt_toolchain_additional_packages_prefix_paths}) + list(PREPEND CMAKE_FIND_ROOT_PATH ${__qt_toolchain_additional_packages_root_paths}) + + unset(__qt_additional_path) + unset(__qt_additional_path_lib_cmake) + unset(__qt_toolchain_additional_packages_root_paths) + unset(__qt_toolchain_additional_packages_prefix_paths) +endif() +unset(__qt_toolchain_additional_packages_prefixes) @init_qt_host_path_checks@ |