[Cmake-commits] [cmake-commits] king committed cmGlobalXCodeGenerator.cxx 1.202 1.203 cmGlobalXCodeGenerator.h 1.53 1.54
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Oct 9 11:01:50 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv25871/Source
Modified Files:
cmGlobalXCodeGenerator.cxx cmGlobalXCodeGenerator.h
Log Message:
ENH: Put custom target sources in Xcode projects
Source files in custom targets are now placed in the Xcode project for
convenient editing. See issue #5848.
Index: cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.202
retrieving revision 1.203
diff -C 2 -d -r1.202 -r1.203
*** cmGlobalXCodeGenerator.cxx 2 Oct 2008 17:49:32 -0000 1.202
--- cmGlobalXCodeGenerator.cxx 9 Oct 2008 15:01:47 -0000 1.203
***************
*** 282,285 ****
--- 282,291 ----
cmTarget* allbuild = mf->FindTarget("ALL_BUILD");
+ // Refer to the main build configuration file for easy editing.
+ std::string listfile = mf->GetStartDirectory();
+ listfile += "/";
+ listfile += "CMakeLists.txt";
+ allbuild->AddSource(listfile.c_str());
+
// Add XCODE depend helper
std::string dir = mf->GetCurrentOutputDirectory();
***************
*** 334,337 ****
--- 340,349 ----
allbuild->AddUtility(target.GetName());
}
+
+ // Refer to the build configuration file for easy editing.
+ listfile = lg->GetMakefile()->GetStartDirectory();
+ listfile += "/";
+ listfile += "CMakeLists.txt";
+ target.AddSource(listfile.c_str());
}
}
***************
*** 460,484 ****
// fileRef object for any given full path.
//
! std::string fname = sf->GetFullPath();
! cmXCodeObject* fileRef = this->FileRefs[fname];
! if(!fileRef)
! {
! fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
! std::string comment = fname;
! comment += " in ";
! //std::string gname = group->GetObject("name")->GetString();
! //comment += gname.substr(1, gname.size()-2);
! fileRef->SetComment(fname.c_str());
!
! this->FileRefs[fname] = fileRef;
! }
!
! cmStdString key = GetGroupMapKey(cmtarget, sf);
! cmXCodeObject* group = this->GroupMap[key];
! cmXCodeObject* children = group->GetObject("children");
! if (!children->HasObject(fileRef))
! {
! children->AddObject(fileRef);
! }
cmXCodeObject* buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile);
--- 472,476 ----
// fileRef object for any given full path.
//
! cmXCodeObject* fileRef = this->CreateXCodeFileReference(sf, cmtarget);
cmXCodeObject* buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile);
***************
*** 526,529 ****
--- 518,548 ----
buildFile->AddAttribute("settings", settings);
+ return buildFile;
+ }
+
+ //----------------------------------------------------------------------------
+ cmXCodeObject*
+ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf,
+ cmTarget& cmtarget)
+ {
+ std::string fname = sf->GetFullPath();
+ cmXCodeObject* fileRef = this->FileRefs[fname];
+ if(!fileRef)
+ {
+ fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
+ std::string comment = fname;
+ //comment += " in ";
+ //std::string gname = group->GetObject("name")->GetString();
+ //comment += gname.substr(1, gname.size()-2);
+ fileRef->SetComment(fname.c_str());
+ this->FileRefs[fname] = fileRef;
+ }
+ cmStdString key = GetGroupMapKey(cmtarget, sf);
+ cmXCodeObject* group = this->GroupMap[key];
+ cmXCodeObject* children = group->GetObject("children");
+ if (!children->HasObject(fileRef))
+ {
+ children->AddObject(fileRef);
+ }
fileRef->AddAttribute("fileEncoding", this->CreateString("4"));
***************
*** 570,573 ****
--- 589,596 ----
sourcecode += ".c.c";
}
+ else if(ext == "txt")
+ {
+ sourcecode += ".text";
+ }
//else
// {
***************
*** 603,607 ****
}
! return buildFile;
}
--- 626,630 ----
}
! return fileRef;
}
***************
*** 1785,1788 ****
--- 1808,1826 ----
target->AddAttribute("productName",this->CreateString(productName.c_str()));
target->SetTarget(&cmtarget);
+
+ // Add source files without build rules for editing convenience.
+ if(cmtarget.GetType() == cmTarget::UTILITY)
+ {
+ std::vector<cmSourceFile*> const& sources = cmtarget.GetSourceFiles();
+ for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
+ i != sources.end(); ++i)
+ {
+ if(!(*i)->GetPropertyAsBool("GENERATED"))
+ {
+ this->CreateXCodeFileReference(*i, cmtarget);
+ }
+ }
+ }
+
return target;
}
***************
*** 2183,2188 ****
// groups:
//
! if(cmtarget.GetType() == cmTarget::UTILITY ||
! cmtarget.GetType() == cmTarget::GLOBAL_TARGET)
{
continue;
--- 2221,2225 ----
// groups:
//
! if(cmtarget.GetType() == cmTarget::GLOBAL_TARGET)
{
continue;
Index: cmGlobalXCodeGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -C 2 -d -r1.53 -r1.54
*** cmGlobalXCodeGenerator.h 3 Jul 2008 17:28:54 -0000 1.53
--- cmGlobalXCodeGenerator.h 9 Oct 2008 15:01:48 -0000 1.54
***************
*** 153,156 ****
--- 153,157 ----
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
+ cmXCodeObject* CreateXCodeFileReference(cmSourceFile* sf, cmTarget& cmtarget);
cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
cmSourceFile* sf,
More information about the Cmake-commits
mailing list