summaryrefslogtreecommitdiffstats
path: root/cmake/QtToolchainHelpers.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/QtToolchainHelpers.cmake')
-rw-r--r--cmake/QtToolchainHelpers.cmake73
1 files changed, 42 insertions, 31 deletions
diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake
index b17aa5c075..3d20a7a3ce 100644
--- a/cmake/QtToolchainHelpers.cmake
+++ b/cmake/QtToolchainHelpers.cmake
@@ -14,15 +14,24 @@ set(__qt_chainload_toolchain_file \"\${__qt_initially_configured_toolchain_file}
")
endif()
- if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
- file(TO_CMAKE_PATH "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
- list(APPEND init_vcpkg
- "set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE \"${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}\")")
- endif()
+ if(QT_USE_VCPKG)
+ set(init_vcpkg "set(__qt_initially_configured_use_vcpkg TRUE)")
+ if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
+ file(TO_CMAKE_PATH "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}"
+ initial_vcpkg_chainload_toolchain_file)
+ get_filename_component(initial_vcpkg_chainload_toolchain_file
+ "${initial_vcpkg_chainload_toolchain_file}" REALPATH)
+ list(APPEND init_vcpkg
+ "set(__qt_initially_configured_vcpkg_chainload_toolchain_file \
+ \"${initial_vcpkg_chainload_toolchain_file}\")")
+ endif()
- if(VCPKG_TARGET_TRIPLET)
- list(APPEND init_vcpkg
- "set(VCPKG_TARGET_TRIPLET \"${VCPKG_TARGET_TRIPLET}\" CACHE STRING \"\")")
+ if(VCPKG_TARGET_TRIPLET)
+ list(APPEND init_vcpkg
+ "set(__qt_initially_configured_vcpkg_target_triplet \"${VCPKG_TARGET_TRIPLET}\")")
+ endif()
+ else()
+ set(init_vcpkg "")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_SYSTEM_VERSION STREQUAL "10")
@@ -129,39 +138,41 @@ set(__qt_chainload_toolchain_file \"\${__qt_initially_configured_toolchain_file}
endif()
if(__qt_embed_toolchain_compilers)
list(APPEND init_platform "
- set(__qt_initial_c_compiler \"${CMAKE_C_COMPILER}\")
- set(__qt_initial_cxx_compiler \"${CMAKE_CXX_COMPILER}\")
- if(NOT DEFINED CMAKE_C_COMPILER AND EXISTS \"\${__qt_initial_c_compiler}\")
- set(CMAKE_C_COMPILER \"\${__qt_initial_c_compiler}\" CACHE STRING \"\")
- endif()
- if(NOT DEFINED CMAKE_CXX_COMPILER AND EXISTS \"\${__qt_initial_cxx_compiler}\")
- set(CMAKE_CXX_COMPILER \"\${__qt_initial_cxx_compiler}\" CACHE STRING \"\")
- endif()")
+set(__qt_initial_c_compiler \"${CMAKE_C_COMPILER}\")
+set(__qt_initial_cxx_compiler \"${CMAKE_CXX_COMPILER}\")
+if(QT_USE_ORIGINAL_COMPILER AND NOT DEFINED CMAKE_C_COMPILER
+ AND EXISTS \"\${__qt_initial_c_compiler}\")
+ set(CMAKE_C_COMPILER \"\${__qt_initial_c_compiler}\" CACHE STRING \"\")
+endif()
+if(QT_USE_ORIGINAL_COMPILER AND NOT DEFINED CMAKE_CXX_COMPILER
+ AND EXISTS \"\${__qt_initial_cxx_compiler}\")
+ set(CMAKE_CXX_COMPILER \"\${__qt_initial_cxx_compiler}\" CACHE STRING \"\")
+endif()")
endif()
unset(init_additional_used_variables)
if(APPLE)
- # For an iOS simulator_and_device build, we should not explicitly set the sysroot, but let
- # CMake do it's universal build magic to use one sysroot / sdk per-arch.
- # For a single arch / sysroot iOS build, try to use the initially configured sysroot
- # path if it exists, otherwise just set the name of the sdk to be used.
- # The latter "name" part is important for user projects so that running 'xcodebuild' from
- # the command line chooses the correct sdk.
+ # For an iOS simulator_and_device build, we should not explicitly set the sysroot,
+ # but let CMake do it's universal build magic to use one sysroot / sdk per-arch.
+ # For a single arch / sysroot build, try to use the initially configured sysroot
+ # by name.
+ #
# Also allow to opt out just in case.
#
# TODO: Figure out if the same should apply to universal macOS builds.
+ # We want to preserve the sysroot as an SDK name, instead of the path
+ # that CMake transforms it into in Darwin-initialize.cmake, so we pick
+ # it out from the cache, where it hasn't been touched by CMake.
+ set(cmake_sysroot_name "$CACHE{CMAKE_OSX_SYSROOT}")
+
list(LENGTH CMAKE_OSX_ARCHITECTURES _qt_osx_architectures_count)
- if(CMAKE_OSX_SYSROOT AND NOT _qt_osx_architectures_count GREATER 1 AND UIKIT)
+ if(cmake_sysroot_name AND NOT _qt_osx_architectures_count GREATER 1 AND UIKIT)
list(APPEND init_platform "
- set(__qt_uikit_sdk \"${QT_UIKIT_SDK}\")
- set(__qt_initial_cmake_osx_sysroot \"${CMAKE_OSX_SYSROOT}\")
- if(NOT DEFINED CMAKE_OSX_SYSROOT AND EXISTS \"\${__qt_initial_cmake_osx_sysroot}\")
- set(CMAKE_OSX_SYSROOT \"\${__qt_initial_cmake_osx_sysroot}\" CACHE PATH \"\")
- elseif(NOT DEFINED CMAKE_OSX_SYSROOT AND NOT QT_NO_SET_OSX_SYSROOT)
- set(CMAKE_OSX_SYSROOT \"\${__qt_uikit_sdk}\" CACHE PATH \"\")
- endif()")
+if(NOT DEFINED CMAKE_OSX_SYSROOT)
+ set(CMAKE_OSX_SYSROOT \"${cmake_sysroot_name}\" CACHE STRING \"\")
+endif()")
endif()
if(CMAKE_OSX_DEPLOYMENT_TARGET)
@@ -216,7 +227,7 @@ set(__qt_chainload_toolchain_file \"\${__qt_initially_configured_toolchain_file}
qt_internal_get_first_osx_arch(osx_first_arch)
list(APPEND init_platform
"if((NOT CMAKE_GENERATOR STREQUAL \"Xcode\" AND NOT __qt_toolchain_building_qt_repo)
- OR (CMAKE_GENERATOR STREQUAL \"Xcode\" AND __qt_uikit_sdk AND NOT QT_NO_SET_OSX_ARCHITECTURES))")
+ OR (CMAKE_GENERATOR STREQUAL \"Xcode\" AND __qt_apple_sdk AND NOT QT_NO_SET_OSX_ARCHITECTURES))")
list(APPEND init_platform
" set(CMAKE_OSX_ARCHITECTURES \"${osx_first_arch}\" CACHE STRING \"\")")
list(APPEND init_platform "endif()")