mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-27 17:10:43 -06:00
Xcode: Use deterministic object ids for targets
When a CMake-generated Xcode project is included in another Xcode project, the used targets' object ids are kept as `remoteGlobalIDString`. Make the ids deterministic and somewhat independent of the build tree location.
This commit is contained in:
@@ -3115,8 +3115,12 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
|
|||||||
"shellScript", this->CreateString("# shell script goes here\nexit 0"));
|
"shellScript", this->CreateString("# shell script goes here\nexit 0"));
|
||||||
shellBuildPhase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
|
shellBuildPhase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
|
||||||
|
|
||||||
cmXCodeObject* target =
|
std::string targetBinaryPath = cmStrCat(
|
||||||
this->CreateObject(cmXCodeObject::PBXAggregateTarget);
|
gtgt->Makefile->GetCurrentBinaryDirectory(), '/', gtgt->GetName());
|
||||||
|
|
||||||
|
cmXCodeObject* target = this->CreateObject(
|
||||||
|
cmXCodeObject::PBXAggregateTarget,
|
||||||
|
cmStrCat("PBXAggregateTarget:", gtgt->GetName(), ":", targetBinaryPath));
|
||||||
target->SetComment(gtgt->GetName());
|
target->SetComment(gtgt->GetName());
|
||||||
cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
||||||
std::vector<cmXCodeObject*> emptyContentVector;
|
std::vector<cmXCodeObject*> emptyContentVector;
|
||||||
@@ -3340,7 +3344,14 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
|
|||||||
if (!gtgt->IsInBuildSystem()) {
|
if (!gtgt->IsInBuildSystem()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget);
|
|
||||||
|
std::string targetBinaryPath = this->RelativeToRootBinary(cmStrCat(
|
||||||
|
gtgt->Makefile->GetCurrentBinaryDirectory(), '/', gtgt->GetName()));
|
||||||
|
|
||||||
|
cmXCodeObject* target = this->CreateObject(
|
||||||
|
cmXCodeObject::PBXNativeTarget,
|
||||||
|
cmStrCat("PBXNativeTarget:", gtgt->GetName(), ":", targetBinaryPath));
|
||||||
|
|
||||||
target->AddAttribute("buildPhases", buildPhases);
|
target->AddAttribute("buildPhases", buildPhases);
|
||||||
cmXCodeObject* buildRules = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
cmXCodeObject* buildRules = this->CreateObject(cmXCodeObject::OBJECT_LIST);
|
||||||
target->AddAttribute("buildRules", buildRules);
|
target->AddAttribute("buildRules", buildRules);
|
||||||
@@ -5130,6 +5141,17 @@ std::string cmGlobalXCodeGenerator::RelativeToSource(const std::string& p)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string cmGlobalXCodeGenerator::RelativeToRootBinary(const std::string& p)
|
||||||
|
{
|
||||||
|
std::string binaryDirectory =
|
||||||
|
this->CurrentRootGenerator->GetCurrentBinaryDirectory();
|
||||||
|
if (cmSystemTools::IsSubDirectory(p, binaryDirectory)) {
|
||||||
|
binaryDirectory = cmSystemTools::ForceToRelativePath(binaryDirectory, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return binaryDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
std::string cmGlobalXCodeGenerator::RelativeToBinary(const std::string& p)
|
std::string cmGlobalXCodeGenerator::RelativeToBinary(const std::string& p)
|
||||||
{
|
{
|
||||||
return this->CurrentRootGenerator->MaybeRelativeToCurBinDir(p);
|
return this->CurrentRootGenerator->MaybeRelativeToCurBinDir(p);
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ private:
|
|||||||
bool CreateGroups(std::vector<cmLocalGenerator*>& generators);
|
bool CreateGroups(std::vector<cmLocalGenerator*>& generators);
|
||||||
std::string XCodeEscapePath(const std::string& p);
|
std::string XCodeEscapePath(const std::string& p);
|
||||||
std::string RelativeToSource(const std::string& p);
|
std::string RelativeToSource(const std::string& p);
|
||||||
|
std::string RelativeToRootBinary(const std::string& p);
|
||||||
std::string RelativeToBinary(const std::string& p);
|
std::string RelativeToBinary(const std::string& p);
|
||||||
std::string ConvertToRelativeForMake(std::string const& p);
|
std::string ConvertToRelativeForMake(std::string const& p);
|
||||||
void CreateCustomCommands(
|
void CreateCustomCommands(
|
||||||
|
|||||||
Reference in New Issue
Block a user