summaryrefslogtreecommitdiffstats
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
parent95e3ff2e88aa8dd984915e6e0373eed2bb96f17f (diff)
downloadCMake-d250b67722abcfe1bcd22511943f3e032ef1ef3d.zip
CMake-d250b67722abcfe1bcd22511943f3e032ef1ef3d.tar.gz
CMake-d250b67722abcfe1bcd22511943f3e032ef1ef3d.tar.bz2
cmGlobalXCodeGenerator: Adopt pbxproj object id generation
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx24
-rw-r--r--Source/cmGlobalXCodeGenerator.h1
-rw-r--r--Source/cmXCode21Object.cxx5
-rw-r--r--Source/cmXCode21Object.h2
-rw-r--r--Source/cmXCodeObject.cxx24
-rw-r--r--Source/cmXCodeObject.h2
6 files changed, 30 insertions, 28 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)
{
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index ab5eeb2..277ee82 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -162,6 +162,7 @@ private:
const std::string& configName);
cmXCodeObject* FindXCodeTarget(const cmGeneratorTarget*);
+ std::string GetObjectId();
std::string GetOrCreateId(const std::string& name, const std::string& id);
// create cmXCodeObject from these functions so that memory can be managed
diff --git a/Source/cmXCode21Object.cxx b/Source/cmXCode21Object.cxx
index 1cf9a95..9b0dc58 100644
--- a/Source/cmXCode21Object.cxx
+++ b/Source/cmXCode21Object.cxx
@@ -4,11 +4,12 @@
#include <ostream>
#include <string>
+#include <utility>
#include "cmSystemTools.h"
-cmXCode21Object::cmXCode21Object(PBXType ptype, Type type)
- : cmXCodeObject(ptype, type)
+cmXCode21Object::cmXCode21Object(PBXType ptype, Type type, std::string id)
+ : cmXCodeObject(ptype, type, std::move(id))
{
this->Version = 21;
}
diff --git a/Source/cmXCode21Object.h b/Source/cmXCode21Object.h
index eb017447..f3fc438 100644
--- a/Source/cmXCode21Object.h
+++ b/Source/cmXCode21Object.h
@@ -13,7 +13,7 @@
class cmXCode21Object : public cmXCodeObject
{
public:
- cmXCode21Object(PBXType ptype, Type type);
+ cmXCode21Object(PBXType ptype, Type type, std::string id);
void PrintComment(std::ostream&) override;
static void PrintList(std::vector<std::unique_ptr<cmXCodeObject>> const&,
std::ostream& out, PBXType t);
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index b301ab1..d5c5275 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -40,7 +40,7 @@ cmXCodeObject::~cmXCodeObject()
this->Version = 15;
}
-cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
+cmXCodeObject::cmXCodeObject(PBXType ptype, Type type, std::string id)
{
this->Version = 15;
this->Target = nullptr;
@@ -48,27 +48,7 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
this->IsA = ptype;
- if (type == OBJECT) {
- // Set the Id of an Xcode object to a unique string for each instance.
- // However the Xcode user file references certain Ids: for those cases,
- // override the generated Id using SetId().
- //
- char cUuid[40] = { 0 };
- CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
- CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, uuid);
- CFStringGetCString(s, cUuid, sizeof(cUuid), kCFStringEncodingUTF8);
- this->Id = cUuid;
- CFRelease(s);
- CFRelease(uuid);
- } else {
- this->Id =
- "Temporary cmake object, should not be referred to in Xcode file";
- }
-
- cmSystemTools::ReplaceString(this->Id, "-", "");
- if (this->Id.size() > 24) {
- this->Id = this->Id.substr(0, 24);
- }
+ this->Id = std::move(id);
this->TypeValue = type;
if (this->TypeValue == OBJECT) {
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index 78d4727..ac5be3f 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -57,7 +57,7 @@ public:
};
static const char* PBXTypeNames[];
virtual ~cmXCodeObject();
- cmXCodeObject(PBXType ptype, Type type);
+ cmXCodeObject(PBXType ptype, Type type, std::string id);
Type GetType() const { return this->TypeValue; }
PBXType GetIsA() const { return this->IsA; }