From da4ccb502b02af41b9db6c266df0c9ef999a1087 Mon Sep 17 00:00:00 2001 From: Hyper Nova Sun Date: Thu, 7 Apr 2022 16:39:05 -0700 Subject: Xcode: Check for multiple `OSX_ARCHITECTURES` on target When determining a given target's object directory, also check for its `OSX_ARCHITECTURES` before resorting to global defaults. This fixes inconsistent object library references when: - `CMAKE_OSX_ARCHITECTURES` is unset or singular - but the object library's `OSX_ARCHITECTURES` property is set to multiple archs --- Source/cmGlobalXCodeGenerator.cxx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 29d7139..d53c3d5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1167,6 +1167,20 @@ std::string GetSourcecodeValueFromFileExtension( return sourcecode; } +template +std::string GetTargetObjectDirArch(T const& target, + const std::string& defaultVal) +{ + auto archs = cmExpandedList(target.GetSafeProperty("OSX_ARCHITECTURES")); + if (archs.size() > 1) { + return "$(CURRENT_ARCH)"; + } else if (archs.size() == 1) { + return archs.front(); + } else { + return defaultVal; + } +} + } // anonymous // Extracts the framework directory, if path matches the framework syntax @@ -4924,9 +4938,11 @@ bool cmGlobalXCodeGenerator::IsMultiConfig() const } bool cmGlobalXCodeGenerator::HasKnownObjectFileLocation( - cmTarget const&, std::string* reason) const + cmTarget const& target, std::string* reason) const { - if (this->ObjectDirArch.find('$') != std::string::npos) { + auto objectDirArch = GetTargetObjectDirArch(target, this->ObjectDirArch); + + if (objectDirArch.find('$') != std::string::npos) { if (reason != nullptr) { *reason = " under Xcode with multiple architectures"; } @@ -4957,10 +4973,12 @@ void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory( cmGeneratorTarget* gt) const { std::string configName = this->GetCMakeCFGIntDir(); + auto objectDirArch = GetTargetObjectDirArch(*gt, this->ObjectDirArch); + std::string dir = cmStrCat(this->GetObjectsDirectory("$(PROJECT_NAME)", configName, gt, "$(OBJECT_FILE_DIR_normal:base)/"), - this->ObjectDirArch, '/'); + objectDirArch, '/'); gt->ObjectDirectory = dir; } -- cgit v0.12