summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-04-09 12:10:46 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-04-09 12:10:55 (GMT)
commit0f72aba269e95b1709b7ef91f13a874286ab8f86 (patch)
tree80f39d91bab3c54851accb2021ff255b4ed4aee7 /Source
parent685bfad05287ca7702ad238ba3c9ce62f26fa3f6 (diff)
parent84a1e67380207bafaceefe1c19b47513c0fb63b2 (diff)
downloadCMake-0f72aba269e95b1709b7ef91f13a874286ab8f86.zip
CMake-0f72aba269e95b1709b7ef91f13a874286ab8f86.tar.gz
CMake-0f72aba269e95b1709b7ef91f13a874286ab8f86.tar.bz2
Merge topic 'apple-arch-sysroots' into release-3.17
84a1e67380 Apple: Fix mapping CMAKE_APPLE_ARCH_SYSROOTS to custom OSX_ARCHITECTURES 45fa9b32ca Apple: Improve handling of missing SDKs in CMAKE_APPLE_ARCH_SYSROOTS Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4583
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx39
-rw-r--r--Source/cmLocalGenerator.h1
2 files changed, 29 insertions, 11 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 00ad62e..2c923dd 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -131,6 +131,28 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
this->LinkerSysroot = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
}
+ if (std::string const* appleArchSysroots =
+ this->Makefile->GetDef("CMAKE_APPLE_ARCH_SYSROOTS")) {
+ std::string const& appleArchs =
+ this->Makefile->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES");
+ std::vector<std::string> archs;
+ std::vector<std::string> sysroots;
+ cmExpandList(appleArchs, archs);
+ cmExpandList(*appleArchSysroots, sysroots, true);
+ if (archs.size() == sysroots.size()) {
+ for (size_t i = 0; i < archs.size(); ++i) {
+ this->AppleArchSysroots[archs[i]] = sysroots[i];
+ }
+ } else {
+ std::string const e =
+ cmStrCat("CMAKE_APPLE_ARCH_SYSROOTS:\n ", *appleArchSysroots,
+ "\n"
+ "is not the same length as CMAKE_OSX_ARCHITECTURES:\n ",
+ appleArchs);
+ this->IssueMessage(MessageType::FATAL_ERROR, e);
+ }
+ }
+
for (std::string const& lang : enabledLanguages) {
if (lang == "NONE") {
continue;
@@ -1792,20 +1814,15 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
const char* sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar);
if (sysrootFlag && *sysrootFlag) {
- std::vector<std::string> arch_sysroots;
- if (const char* arch_sysroots_str =
- this->Makefile->GetDefinition("CMAKE_APPLE_ARCH_SYSROOTS")) {
- cmExpandList(std::string(arch_sysroots_str), arch_sysroots, true);
- }
- if (!arch_sysroots.empty()) {
- assert(arch_sysroots.size() == archs.size());
- for (size_t i = 0; i < archs.size(); ++i) {
- if (arch_sysroots[i].empty()) {
+ if (!this->AppleArchSysroots.empty()) {
+ for (std::string const& arch : archs) {
+ std::string const& archSysroot = this->AppleArchSysroots[arch];
+ if (cmIsOff(archSysroot)) {
continue;
}
- flags += " -Xarch_" + archs[i] + " ";
+ flags += " -Xarch_" + arch + " ";
// Combine sysroot flag and path to work with -Xarch
- std::string arch_sysroot = sysrootFlag + arch_sysroots[i];
+ std::string arch_sysroot = sysrootFlag + archSysroot;
flags += this->ConvertToOutputFormat(arch_sysroot, SHELL);
}
} else if (sysroot && *sysroot) {
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 88194b7..5377be9 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -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;