Apple: Improve handling of CMAKE_APPLE_ARCH_SYSROOTS
If CMAKE_APPLE_ARCH_SYSROOTS does not have the same length as
CMAKE_OSX_ARCHITECTURES, error out early rather than risking a crash
or assertion failure.
Also:
-
Improve handling of missing SDKs in CMAKE_APPLE_ARCH_SYSROOTS
Use
<arch>-SDK-NOTFOUNDinstead of an empty string as a placeholder inCMAKE_APPLE_ARCH_SYSROOTSfor architectures whose SDK is not found. This ensures the length ofCMAKE_APPLE_ARCH_SYSROOTSmatches the length ofCMAKE_OSX_ARCHITECTURES. It also makes the missing SDKs more visible in the value. -
Fix mapping CMAKE_APPLE_ARCH_SYSROOTS to custom OSX_ARCHITECTURES
The
CMAKE_OSX_ARCHITECTURESvalue is not used directly by generators. It is used to initialize a per-targetOSX_ARCHITECTURESproperty, but that property can also be set explicitly by project code to a subset of the full list of architectures. In order to handle this case, construct a mapping from eachCMAKE_OSX_ARCHITECTURESentry to the correspondingCMAKE_APPLE_ARCH_SYSROOTSentry by name. Use the mapping to find the sysroot for each entry inOSX_ARCHITECTURESfor a given target.
Fixes: #20534 (closed)
Backport: release:HEAD^2