cmake: Merge Apple platform auto-detect functions
Makes it easier to see the interaction between the different parts, and extract some of them to apply to a wider set of platforms later on. Change-Id: I3dd71dd6ad7a5b2870ab60bfbe4cf31be418bd8a Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
b3e9e80719
commit
5e81a17b22
@ -177,7 +177,11 @@ function(qt_auto_detect_vcpkg)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(qt_auto_detect_ios)
|
||||
function(qt_auto_detect_apple)
|
||||
if(NOT APPLE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if("${QT_QMAKE_TARGET_MKSPEC}" STREQUAL "macx-ios-clang")
|
||||
set(CMAKE_SYSTEM_NAME "iOS" CACHE STRING "")
|
||||
endif()
|
||||
@ -238,6 +242,50 @@ function(qt_auto_detect_ios)
|
||||
# needed though.
|
||||
set(QT_DISABLE_RPATH "OFF" CACHE BOOL "Disable automatic Qt rpath handling." FORCE)
|
||||
endif()
|
||||
|
||||
# If no CMAKE_OSX_DEPLOYMENT_TARGET is provided, default to a value that Qt defines.
|
||||
# This replicates the behavior in mkspecs/common/macx.conf where
|
||||
# QMAKE_MACOSX_DEPLOYMENT_TARGET is set.
|
||||
set(description
|
||||
"Minimum OS X version to target for deployment (at runtime); newer APIs weak linked."
|
||||
" Set to empty string for default value.")
|
||||
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
if(NOT CMAKE_SYSTEM_NAME)
|
||||
# macOS
|
||||
set(version "12.0")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
|
||||
set(version "16.0")
|
||||
endif()
|
||||
if(version)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "${version}" CACHE STRING "${description}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_qt_internal_get_apple_sdk_version(apple_sdk_version)
|
||||
set(QT_MAC_SDK_VERSION "${apple_sdk_version}" CACHE STRING "Darwin SDK version.")
|
||||
|
||||
_qt_internal_get_xcode_version_raw(xcode_version_raw)
|
||||
set(QT_MAC_XCODE_VERSION "${xcode_version_raw}" CACHE STRING "Xcode version.")
|
||||
|
||||
if(NOT CMAKE_SYSTEM_NAME)
|
||||
# macOS
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES arch_count)
|
||||
if(arch_count GREATER 0)
|
||||
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
if(arch STREQUAL "arm64e")
|
||||
message(WARNING "Applications built against an arm64e Qt architecture will "
|
||||
"likely fail to run on Apple Silicon. Consider targeting "
|
||||
"'arm64' instead.")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(is_universal "OFF")
|
||||
if(arch_count GREATER 1)
|
||||
set(is_universal "ON")
|
||||
endif()
|
||||
set(QT_IS_MACOS_UNIVERSAL "${is_universal}" CACHE INTERNAL "Build universal Qt for macOS")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(qt_auto_detect_cmake_config)
|
||||
@ -282,58 +330,6 @@ function(qt_auto_detect_cyclic_toolchain)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(qt_auto_detect_darwin)
|
||||
if(APPLE)
|
||||
# If no CMAKE_OSX_DEPLOYMENT_TARGET is provided, default to a value that Qt defines.
|
||||
# This replicates the behavior in mkspecs/common/macx.conf where
|
||||
# QMAKE_MACOSX_DEPLOYMENT_TARGET is set.
|
||||
set(description
|
||||
"Minimum OS X version to target for deployment (at runtime); newer APIs weak linked."
|
||||
" Set to empty string for default value.")
|
||||
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
if(NOT CMAKE_SYSTEM_NAME)
|
||||
# macOS
|
||||
set(version "12.0")
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
|
||||
set(version "16.0")
|
||||
endif()
|
||||
if(version)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "${version}" CACHE STRING "${description}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_qt_internal_get_apple_sdk_version(apple_sdk_version)
|
||||
set(QT_MAC_SDK_VERSION "${apple_sdk_version}" CACHE STRING "Darwin SDK version.")
|
||||
|
||||
_qt_internal_get_xcode_version_raw(xcode_version_raw)
|
||||
set(QT_MAC_XCODE_VERSION "${xcode_version_raw}" CACHE STRING "Xcode version.")
|
||||
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES arch_count)
|
||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL iOS AND arch_count GREATER 0)
|
||||
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
|
||||
if(arch STREQUAL "arm64e")
|
||||
message(WARNING "Applications built against an arm64e Qt architecture will "
|
||||
"likely fail to run on Apple Silicon. Consider targeting "
|
||||
"'arm64' instead.")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(qt_auto_detect_macos_universal)
|
||||
if(APPLE AND NOT CMAKE_SYSTEM_NAME STREQUAL iOS)
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES arch_count)
|
||||
|
||||
set(is_universal "OFF")
|
||||
if(arch_count GREATER 1)
|
||||
set(is_universal "ON")
|
||||
endif()
|
||||
|
||||
set(QT_IS_MACOS_UNIVERSAL "${is_universal}" CACHE INTERNAL "Build universal Qt for macOS")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(qt_auto_detect_pch)
|
||||
set(default_value "ON")
|
||||
|
||||
@ -476,9 +472,7 @@ macro(qt_internal_setup_autodetect)
|
||||
|
||||
qt_auto_detect_cyclic_toolchain()
|
||||
qt_auto_detect_cmake_config()
|
||||
qt_auto_detect_macos_universal()
|
||||
qt_auto_detect_ios()
|
||||
qt_auto_detect_darwin()
|
||||
qt_auto_detect_apple()
|
||||
qt_auto_detect_android()
|
||||
qt_auto_detect_pch()
|
||||
qt_auto_detect_wasm()
|
||||
|
Loading…
x
Reference in New Issue
Block a user