summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalXCodeGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-01-06 20:29:24 (GMT)
committerBrad King <brad.king@kitware.com>2021-01-06 21:21:53 (GMT)
commitd250b67722abcfe1bcd22511943f3e032ef1ef3d (patch)
treeb23b82a7dc28a2197cf765a92c8985486140a8c4 /Source/cmGlobalXCodeGenerator.cxx
parent95e3ff2e88aa8dd984915e6e0373eed2bb96f17f (diff)
downloadCMake-d250b67722abcfe1bcd22511943f3e032ef1ef3d.zip
CMake-d250b67722abcfe1bcd22511943f3e032ef1ef3d.tar.gz
CMake-d250b67722abcfe1bcd22511943f3e032ef1ef3d.tar.bz2
cmGlobalXCodeGenerator: Adopt pbxproj object id generation
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 7ee94b2..af8b2f0 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -799,7 +799,8 @@ void cmGlobalXCodeGenerator::addObject(std::unique_ptr<cmXCodeObject> obj)
cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(
cmXCodeObject::PBXType ptype)
{
- auto obj = cm::make_unique<cmXCode21Object>(ptype, cmXCodeObject::OBJECT);
+ auto obj = cm::make_unique<cmXCode21Object>(ptype, cmXCodeObject::OBJECT,
+ this->GetObjectId());
auto ptr = obj.get();
this->addObject(std::move(obj));
return ptr;
@@ -807,7 +808,9 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(
cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type)
{
- auto obj = cm::make_unique<cmXCodeObject>(cmXCodeObject::None, type);
+ auto obj = cm::make_unique<cmXCodeObject>(
+ cmXCodeObject::None, type,
+ "Temporary cmake object, should not be referred to in Xcode file");
auto ptr = obj.get();
this->addObject(std::move(obj));
return ptr;
@@ -3138,6 +3141,23 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(
return i->second;
}
+std::string cmGlobalXCodeGenerator::GetObjectId()
+{
+ std::string objectId;
+ char cUuid[40] = { 0 };
+ CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
+ CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, uuid);
+ CFStringGetCString(s, cUuid, sizeof(cUuid), kCFStringEncodingUTF8);
+ objectId = cUuid;
+ CFRelease(s);
+ CFRelease(uuid);
+ cmSystemTools::ReplaceString(objectId, "-", "");
+ if (objectId.size() > 24) {
+ objectId = objectId.substr(0, 24);
+ }
+ return objectId;
+}
+
std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
const std::string& id)
{