diff options
Diffstat (limited to 'cmake/qt.toolchain.cmake.in')
-rw-r--r-- | cmake/qt.toolchain.cmake.in | 82 |
1 files changed, 15 insertions, 67 deletions
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in index 23f322824d..15cf7a432e 100644 --- a/cmake/qt.toolchain.cmake.in +++ b/cmake/qt.toolchain.cmake.in @@ -3,9 +3,7 @@ set(__qt_toolchain_used_variables QT_TOOLCHAIN_INCLUDE_FILE QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR QT_TOOLCHAIN_RELOCATABLE_PREFIX - QT_HOST_PATH - QT_HOST_PATH_CMAKE_DIR - QT_REQUIRE_HOST_PATH_CHECK + QT_ADDITIONAL_PACKAGES_PREFIX_PATH ) @init_additional_used_variables@ @@ -36,7 +34,7 @@ if(__qt_chainload_toolchain_file) "${__qt_chainload_toolchain_file}" REALPATH) if(__qt_chainload_toolchain_file_real_path STREQUAL CMAKE_CURRENT_LIST_FILE) message(FATAL_ERROR - "Woah, the Qt toolchain file tried to include itself recusively! '${__qt_chainload_toolchain_file}' " + "Woah, the Qt toolchain file tried to include itself recursively! '${__qt_chainload_toolchain_file}' " "Make sure to remove qtbase/CMakeCache.txt and reconfigure qtbase with 'cmake' " "rather than 'qt-cmake', and then you can reconfigure your own project." ) @@ -81,9 +79,14 @@ endif() # 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. +# through the Qt6 umbrella package. The paths must end in lib/cmake to ensure 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. +# +# Note that we don't handle QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH here, because we would thwart +# our efforts to not accidentally pick up host packages. For now, we say that +# find_package(Qt6FooTools) is not supported, and people must use find_package(Qt6 COMPONENTS +# FooTools) instead. set(__qt_toolchain_additional_packages_prefixes "") if(QT_ADDITIONAL_PACKAGES_PREFIX_PATH) list(APPEND __qt_toolchain_additional_packages_prefixes @@ -91,8 +94,14 @@ if(QT_ADDITIONAL_PACKAGES_PREFIX_PATH) endif() if(DEFINED ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH} AND NOT "$ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH}" STREQUAL "") + set(__qt_env_additional_packages_prefixes $ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH}) + if(NOT CMAKE_HOST_WIN32) + string(REPLACE ":" ";" __qt_env_additional_packages_prefixes + "${__qt_env_additional_packages_prefixes}") + endif() list(APPEND __qt_toolchain_additional_packages_prefixes - $ENV{QT_ADDITIONAL_PACKAGES_PREFIX_PATH}) + ${__qt_env_additional_packages_prefixes}) + unset(__qt_env_additional_packages_prefixes) endif() if(__qt_toolchain_additional_packages_prefixes) @@ -141,67 +150,6 @@ if(QT_TOOLCHAIN_INCLUDE_FILE) endif() endif() -# Set up QT_HOST_PATH and do sanity checks. -# A host path is required when cross-compiling but optional when doing a native build. -# Requiredness can be overridden via variable. -if(DEFINED QT_REQUIRE_HOST_PATH_CHECK) - set(__qt_toolchain_host_path_required "${QT_REQUIRE_HOST_PATH_CHECK}") -else() - set(__qt_toolchain_host_path_required "@qt_host_path_required@") -endif() -set(__qt_toolchain_initial_qt_host_path - "@qt_host_path_absolute@") -set(__qt_toolchain_initial_qt_host_path_cmake_dir - "@qt_host_path_cmake_dir_absolute@") - -# Prefer initially configured path if none was explicitly set. -if(NOT DEFINED QT_HOST_PATH AND __qt_toolchain_initial_qt_host_path - AND EXISTS "${__qt_toolchain_initial_qt_host_path}") - set(QT_HOST_PATH "${__qt_toolchain_initial_qt_host_path}" CACHE PATH "") -endif() - -if(NOT QT_HOST_PATH STREQUAL "") - get_filename_component(__qt_toolchain_host_path_absolute "${QT_HOST_PATH}" ABSOLUTE) -endif() - -if(__qt_toolchain_host_path_required AND - ("${QT_HOST_PATH}" STREQUAL "" OR NOT EXISTS "${__qt_toolchain_host_path_absolute}")) - message(FATAL_ERROR - "To use a cross-compiled Qt, please set the QT_HOST_PATH cache variable to the location " - "of your host Qt installation.") -endif() - -# QT_HOST_PATH_CMAKE_DIR is needed to work around the rerooting issue when looking for host tools -# See REROOT_PATH_ISSUE_MARKER. -# Prefer initially configured path if none was explicitly set. -if(__qt_toolchain_host_path_required AND NOT DEFINED QT_HOST_PATH_CMAKE_DIR) - if(__qt_toolchain_initial_qt_host_path_cmake_dir - AND EXISTS "${__qt_toolchain_initial_qt_host_path_cmake_dir}") - set(QT_HOST_PATH_CMAKE_DIR "${__qt_toolchain_initial_qt_host_path_cmake_dir}" CACHE PATH "") - else() - # First try to auto-compute the location instead of requiring to set QT_HOST_PATH_CMAKE_DIR - # explicitly. - set(__qt_candidate_host_path_cmake_dir "${QT_HOST_PATH}/lib/cmake") - if(__qt_candidate_host_path_cmake_dir AND EXISTS "${__qt_candidate_host_path_cmake_dir}") - set(QT_HOST_PATH_CMAKE_DIR - "${__qt_candidate_host_path_cmake_dir}" CACHE PATH "") - endif() - endif() -endif() - -if(NOT QT_HOST_PATH_CMAKE_DIR STREQUAL "") - get_filename_component(__qt_toolchain_host_path_cmake_dir_absolute - "${QT_HOST_PATH_CMAKE_DIR}" ABSOLUTE) -endif() - -if(__qt_toolchain_host_path_required AND - ("${QT_HOST_PATH_CMAKE_DIR}" STREQUAL "" - OR NOT EXISTS "${__qt_toolchain_host_path_cmake_dir_absolute}")) - message(FATAL_ERROR - "To use a cross-compiled Qt, please set the QT_HOST_PATH_CMAKE_DIR cache variable to " - "the location of your host Qt installation lib/cmake directory.") -endif() - # Store initial build type (if any is specified) to be read by QtBuildInternals.cmake when building # a Qt repo, standalone tests or a single test. if(DEFINED CACHE{CMAKE_BUILD_TYPE}) |