Apple: 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.

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.

Fixes: #20534
This commit is contained in:
Brad King
2020-04-08 11:35:32 -04:00
parent 45fa9b32ca
commit 84a1e67380
2 changed files with 29 additions and 11 deletions
+1
View File
@@ -513,6 +513,7 @@ protected:
std::map<std::string, std::string> VariableMappings;
std::string CompilerSysroot;
std::string LinkerSysroot;
std::unordered_map<std::string, std::string> AppleArchSysroots;
bool EmitUniversalBinaryFlags;