From 17d707254d03696b19ccb56cd2742b442ddb2825 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 22 Jul 2009 11:14:23 -0400 Subject: BUG: Fix issue #8481 - generate Xcode projects such that breakpoints may be used from the Xcode debugger without adjusting any settings within the Xcode GUI first... Thanks to Doug Gregor for the patch. --- Source/cmGlobalXCodeGenerator.cxx | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 353fa6e..8bbc8fe 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -672,6 +672,23 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, cmSystemTools::SplitProgramPath(sf->GetFullPath().c_str(), dir, file); + // Try to make the path relative to the project root. + bool Absolute = true; + if (this->XcodeVersion >= 30) + { + std::string relative = + this->CurrentLocalGenerator->Convert(sf->GetFullPath().c_str(), + cmLocalGenerator::HOME, + cmLocalGenerator::MAKEFILE, + false); + relative = cmSystemTools::ConvertToOutputPath(relative.c_str()); + if (!relative.empty() && relative[0] != '/') + { + Absolute = false; + path = relative; + } + } + fileRef->AddAttribute("name", this->CreateString(file.c_str())); fileRef->AddAttribute("path", this->CreateString(path.c_str())); if(this->XcodeVersion == 15) @@ -682,10 +699,14 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, { fileRef->AddAttribute("sourceTree", this->CreateString("")); } - else + else if (Absolute) { fileRef->AddAttribute("sourceTree", this->CreateString("")); } + else + { + fileRef->AddAttribute("sourceTree", this->CreateString("SOURCE_ROOT")); + } return fileRef; } @@ -2581,8 +2602,18 @@ void cmGlobalXCodeGenerator { std::string proot = root->GetMakefile()->GetCurrentDirectory(); proot = this->ConvertToRelativeForXCode(proot.c_str()); - this->RootObject->AddAttribute("projectRoot", - this->CreateString(proot.c_str())); + if (this->XcodeVersion >= 30) + { + this->RootObject->AddAttribute("projectRoot", + this->CreateString("")); + this->RootObject->AddAttribute("projectDirPath", + this->CreateString(proot.c_str())); + } + else + { + this->RootObject->AddAttribute("projectRoot", + this->CreateString(proot.c_str())); + } } cmXCodeObject* configlist = this->CreateObject(cmXCodeObject::XCConfigurationList); -- cgit v0.12