diff options
Diffstat (limited to 'cmake/qt.toolchain.cmake.in')
-rw-r--r-- | cmake/qt.toolchain.cmake.in | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in index 79a37fd95a..15cf7a432e 100644 --- a/cmake/qt.toolchain.cmake.in +++ b/cmake/qt.toolchain.cmake.in @@ -2,7 +2,9 @@ set(__qt_toolchain_used_variables QT_CHAINLOAD_TOOLCHAIN_FILE QT_TOOLCHAIN_INCLUDE_FILE QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR - QT_TOOLCHAIN_RELOCATABLE_PREFIX) + QT_TOOLCHAIN_RELOCATABLE_PREFIX + QT_ADDITIONAL_PACKAGES_PREFIX_PATH +) @init_additional_used_variables@ # Make cache variables used by this toolchain file available to the @@ -19,8 +21,6 @@ if($ENV{_QT_TOOLCHAIN_VARS_INITIALIZED}) endforeach() endif() -@init_qt_host_path@ -@init_qt_host_path_cmake_dir@ @init_original_toolchain_file@ @init_vcpkg@ @@ -34,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." ) @@ -79,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 @@ -89,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) @@ -120,8 +131,6 @@ if(__qt_toolchain_additional_packages_prefixes) endif() unset(__qt_toolchain_additional_packages_prefixes) -@init_qt_host_path_checks@ - # Allow customization of the toolchain file by placing an additional file next to it. set(__qt_toolchain_extra_file "${CMAKE_CURRENT_LIST_DIR}/qt.toolchain.extra.cmake") if(EXISTS "${__qt_toolchain_extra_file}") @@ -141,10 +150,16 @@ if(QT_TOOLCHAIN_INCLUDE_FILE) endif() 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}) + set(__qt_toolchain_cmake_build_type_before_project_call "${CMAKE_BUILD_TYPE}") +endif() + # Compile tests only see a restricted set of variables. -# All cache variables, this toolchain file uses, must be made available to compile tests, -# because this toolchain file will be included there too. -if(NOT ENV{_QT_TOOLCHAIN_VARS_INITIALIZED}) +# All cache variables, this toolchain file uses, must be made available to project-based +# try_compile tests because this toolchain file will be included there too. +if(NOT "$ENV{_QT_TOOLCHAIN_VARS_INITIALIZED}") set(ENV{_QT_TOOLCHAIN_VARS_INITIALIZED} ON) foreach(var ${__qt_toolchain_used_variables}) set(ENV{_QT_TOOLCHAIN_${var}} "${${var}}") |