summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorHyper Nova Sun <hypernovasun@icloud.com>2022-04-07 23:39:05 (GMT)
committerHyper Nova Sun <hypernovasun@icloud.com>2022-04-11 22:02:41 (GMT)
commitda4ccb502b02af41b9db6c266df0c9ef999a1087 (patch)
treee0488191d5c0f029c53c7aa59e948e5a23bf22b2 /Source/cmGlobalXCodeGenerator.cxx
parent41ba35a42b177db14358390e50857eb2554a3873 (diff)
downloadCMake-da4ccb502b02af41b9db6c266df0c9ef999a1087.zip
CMake-da4ccb502b02af41b9db6c266df0c9ef999a1087.tar.gz
CMake-da4ccb502b02af41b9db6c266df0c9ef999a1087.tar.bz2
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
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx24
1 files 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 <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;
}