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)
{
return ret;

View File

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

View File

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