CMake: Fix configuring a standalone test on Apple platforms

Configuring a test as standalone would fail with the following error:
 Invalid max SDK version: It should be a major version number,
 without minor

This happened because _qt_internal_check_apple_sdk_and_xcode_versions
expects QT_SUPPORTED_MAX_MACOS_SDK_VERSION to be available, but it is
not yet set due to Qt6 package not being found yet.

Avoid the issue by exporting the version requirements into both
Qt6ConfigExtras.cmake and Qt6BuildInternalsConfigExtra.cmake.

Make sure to assign the variables only once.

Amends a29bff3d80219f54d0837b0e6e0577192011dea1
Amends a0bdd2195f24d8a7d880ba506afc16b41337218e

Pick-to: 6.6
Task-number: QTBUG-119490
Change-Id: Ic297eeaabf22c8c42ded1a766906f88fdb91fd3d
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit cec2e42052a04cd2481c20bd4be5de2ba5ccaec2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2024-02-02 12:07:43 +01:00 committed by Qt Cherry-pick Bot
parent 7fa10ab76e
commit cfdffa17a5
2 changed files with 18 additions and 1 deletions

View File

@ -720,6 +720,19 @@ set(QT_COPYRIGHT_YEAR \"${QT_COPYRIGHT_YEAR}\" CACHE STRING \"\")
set(QT_COPYRIGHT \"${QT_COPYRIGHT}\" CACHE STRING \"\") set(QT_COPYRIGHT \"${QT_COPYRIGHT}\" CACHE STRING \"\")
") ")
# Add the apple version requirements to the BuildInternals extra code, so the info is
# available when configuring a standalone test.
# Otherwise when QtSetup is included after a
# find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
# call, Qt6ConfigExtras.cmake is not included yet, the requirements are not available and
# _qt_internal_check_apple_sdk_and_xcode_versions() would fail.
_qt_internal_export_apple_sdk_and_xcode_version_requirements(apple_requirements)
if(apple_requirements)
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "
${apple_requirements}
")
endif()
qt_compute_relative_path_from_cmake_config_dir_to_prefix() qt_compute_relative_path_from_cmake_config_dir_to_prefix()
configure_file( configure_file(
"${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake.in" "${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake.in"

View File

@ -692,7 +692,11 @@ function(_qt_internal_export_apple_sdk_and_xcode_version_requirements out_var)
set(assignments "") set(assignments "")
foreach(var IN LISTS vars_to_assign) foreach(var IN LISTS vars_to_assign)
set(value "${${var}}") set(value "${${var}}")
list(APPEND assignments "set(${var} \"${value}\")") list(APPEND assignments
"
if(NOT ${var})
set(${var} \"${value}\")
endif()")
endforeach() endforeach()
list(JOIN assignments "\n" assignments) list(JOIN assignments "\n" assignments)