diff options
author | Brad King <brad.king@kitware.com> | 2020-04-08 17:44:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-04-08 17:44:42 (GMT) |
commit | da25220d83c25ceabad09b8386fb004b53400bd4 (patch) | |
tree | fbe1c5b94d8ea3ecc5ea1c2419dc8f5893aeda8a /Source | |
parent | 37fa5122c2c1e2138b9e01191dc3cc1800f6ba40 (diff) | |
parent | 84a1e67380207bafaceefe1c19b47513c0fb63b2 (diff) | |
download | CMake-da25220d83c25ceabad09b8386fb004b53400bd4.zip CMake-da25220d83c25ceabad09b8386fb004b53400bd4.tar.gz CMake-da25220d83c25ceabad09b8386fb004b53400bd4.tar.bz2 |
Merge branch 'backport-3.17-apple-arch-sysroots' into apple-arch-sysroots
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 41 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 1 |
2 files changed, 30 insertions, 12 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a49a7f8..f5ca5f4 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; @@ -1868,21 +1890,16 @@ 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; } - if (filterArch.empty() || filterArch == archs[i]) { - flags += " -Xarch_" + archs[i] + " "; + if (filterArch.empty() || filterArch == arch) { + 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); } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 25ed265..71cc63e 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -514,6 +514,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; |