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-NOTFOUND instead of an empty string as a placeholder in CMAKE_APPLE_ARCH_SYSROOTS for architectures whose SDK is not found. This ensures the length of CMAKE_APPLE_ARCH_SYSROOTS matches the length of CMAKE_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_ARCHITECTURES value is not used directly by generators. It is used to initialize a per-target OSX_ARCHITECTURES property, 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 each CMAKE_OSX_ARCHITECTURES entry to the corresponding CMAKE_APPLE_ARCH_SYSROOTS entry by name. Use the mapping to find the sysroot for each entry in OSX_ARCHITECTURES for a given target.

Fixes: #20534 (closed)
Backport: release:HEAD^2

Edited by Brad King

Merge request reports

Loading