ENH: fix for finding the correct target in the current project

This commit is contained in:
Bill Hoffman 2005-03-03 22:35:06 -05:00
parent ed1afcdaee
commit a9a0c91630
3 changed files with 33 additions and 18 deletions

View File

@ -873,11 +873,17 @@ void cmGlobalGenerator::FillProjectMap()
} }
cmTarget* cmGlobalGenerator::FindTarget(const char* name) cmTarget* cmGlobalGenerator::FindTarget(const char* project,
const char* name)
{ {
for(unsigned int i = 0; i < m_LocalGenerators.size(); ++i) std::vector<cmLocalGenerator*>* gens = &m_LocalGenerators;
if(project)
{ {
cmTarget* ret = m_LocalGenerators[i]->GetMakefile()->FindTarget(name); gens = &m_ProjectMap[project];
}
for(unsigned int i = 0; i < gens->size(); ++i)
{
cmTarget* ret = (*gens)[i]->GetMakefile()->FindTarget(name);
if(ret) if(ret)
{ {
return ret; return ret;

View File

@ -160,7 +160,7 @@ protected:
void RecursiveConfigure(cmLocalGenerator *lg, float start, float end); void RecursiveConfigure(cmLocalGenerator *lg, float start, float end);
///! Find a target by name by searching the local generators. ///! Find a target by name by searching the local generators.
cmTarget* FindTarget(const char* name); cmTarget* FindTarget(const char* project, const char* name);
private: private:
// If you add a new map here, make sure it is copied // If you add a new map here, make sure it is copied
// in EnableLanguagesFromGenerator // in EnableLanguagesFromGenerator

View File

@ -722,7 +722,8 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin(); for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin();
d != cc.GetDepends().end(); ++d) d != cc.GetDepends().end(); ++d)
{ {
if(!this->FindTarget(d->c_str())) if(!this->FindTarget(m_CurrentMakefile->GetProjectName(),
d->c_str()))
{ {
makefileStream << "\\\n" << this makefileStream << "\\\n" << this
->ConvertToRelativeForMake(d->c_str()); ->ConvertToRelativeForMake(d->c_str());
@ -963,7 +964,6 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
"# shell script goes here\nexit 0")); "# shell script goes here\nexit 0"));
cmXCodeObject* target = cmXCodeObject* target =
this->CreateObject(cmXCodeObject::PBXAggregateTarget); this->CreateObject(cmXCodeObject::PBXAggregateTarget);
cmXCodeObject* buildPhases = cmXCodeObject* buildPhases =
this->CreateObject(cmXCodeObject::OBJECT_LIST); this->CreateObject(cmXCodeObject::OBJECT_LIST);
this->CreateCustomCommands(buildPhases, 0, 0, 0, cmtarget); this->CreateCustomCommands(buildPhases, 0, 0, 0, cmtarget);
@ -992,7 +992,6 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
{ {
cmXCodeObject* target = cmXCodeObject* target =
this->CreateObject(cmXCodeObject::PBXNativeTarget); this->CreateObject(cmXCodeObject::PBXNativeTarget);
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);
@ -1091,7 +1090,9 @@ void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target,
cmXCodeObject* depends = target->GetObject("dependencies"); cmXCodeObject* depends = target->GetObject("dependencies");
if(!depends) if(!depends)
{ {
std::cerr << "target does not have dependencies attribute error...\n"; cmSystemTools::
Error("target does not have dependencies attribute error..");
} }
else else
{ {
@ -1161,7 +1162,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
cmTarget* cmtarget = target->GetcmTarget(); cmTarget* cmtarget = target->GetcmTarget();
if(!cmtarget) if(!cmtarget)
{ {
std::cerr << "Error no target on xobject\n"; cmSystemTools::Error("Error no target on xobject\n");
return; return;
} }
// compute the correct order for link libraries // compute the correct order for link libraries
@ -1215,7 +1216,8 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
for(std::vector<cmStdString>::iterator lib = linkItems.begin(); for(std::vector<cmStdString>::iterator lib = linkItems.begin();
lib != linkItems.end(); ++lib) lib != linkItems.end(); ++lib)
{ {
cmTarget* t = this->FindTarget(lib->c_str()); cmTarget* t = this->FindTarget(m_CurrentMakefile->GetProjectName(),
lib->c_str());
cmXCodeObject* dptarget = this->FindXCodeTarget(t); cmXCodeObject* dptarget = this->FindXCodeTarget(t);
if(dptarget) if(dptarget)
{ {
@ -1239,7 +1241,8 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
= cmtarget->GetUtilities().begin(); = cmtarget->GetUtilities().begin();
i != cmtarget->GetUtilities().end(); ++i) i != cmtarget->GetUtilities().end(); ++i)
{ {
cmTarget* t = this->FindTarget(i->c_str()); cmTarget* t = this->FindTarget(m_CurrentMakefile->GetProjectName(),
i->c_str());
cmXCodeObject* dptarget = this->FindXCodeTarget(t); cmXCodeObject* dptarget = this->FindXCodeTarget(t);
if(dptarget) if(dptarget)
{ {
@ -1247,12 +1250,19 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
} }
else else
{ {
std::cerr << "Error Utility: " << i->c_str() << "\n"; std::string m = "Error Utility: ";
std::cerr << "cmtarget " << t << "\n"; m += i->c_str();
std::cerr << "Is on the target " << cmtarget->GetName() << "\n"; m += "\n";
std::cerr << "But it has no xcode target created yet??\n"; m += "cmtarget ";
std::cerr << "Current project is " m += t->GetName();
<< m_CurrentMakefile->GetProjectName() << "\n"; m += "\n";
m += "Is on the target ";
m += cmtarget->GetName();
m += "\n";
m += "But it has no xcode target created yet??\n";
m += "Current project is ";
m += m_CurrentMakefile->GetProjectName();
cmSystemTools::Error(m.c_str());
} }
} }
std::vector<cmStdString> fullPathLibs; std::vector<cmStdString> fullPathLibs;
@ -1467,7 +1477,6 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
{ {
return; return;
} }
this->CreateXCodeObjects(root, this->CreateXCodeObjects(root,
generators); generators);
std::string xcodeDir = root->GetMakefile()->GetStartOutputDirectory(); std::string xcodeDir = root->GetMakefile()->GetStartOutputDirectory();