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
This commit is contained in:
Hyper Nova Sun
2022-04-07 16:39:05 -07:00
parent 41ba35a42b
commit da4ccb502b

View File

@@ -1167,6 +1167,20 @@ std::string GetSourcecodeValueFromFileExtension(
return sourcecode;
}
template <class T>
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;
}