ENH: fail if an unknown target is listed

Alex
This commit is contained in:
Alexander Neundorf 2007-06-08 16:19:13 -04:00
parent e37f8e2964
commit 33fe9c027f
1 changed files with 32 additions and 12 deletions

View File

@ -97,13 +97,29 @@ bool cmExportCommand
} }
} }
for(std::vector<std::string>::const_iterator currentTarget = targets.begin();
currentTarget != targets.end();
++currentTarget)
{
cmTarget* target = this->Makefile->GetLocalGenerator()->
GetGlobalGenerator()->FindTarget(0, currentTarget->c_str(), true);
if (target == 0)
{
std::string e = "detected unknown target: " + *currentTarget;
this->SetError(e.c_str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
}
for(std::vector<std::string>::const_iterator currentTarget = targets.begin(); for(std::vector<std::string>::const_iterator currentTarget = targets.begin();
currentTarget != targets.end(); currentTarget != targets.end();
++currentTarget) ++currentTarget)
{ {
// Look for a CMake target with the given name, which is an executable // Look for a CMake target with the given name, which is an executable
// and which can be run // and which can be run
cmTarget* target = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->FindTarget(0, currentTarget->c_str(), true); cmTarget* target = this->Makefile->GetLocalGenerator()->
GetGlobalGenerator()->FindTarget(0, currentTarget->c_str(), true);
if ((target != 0) if ((target != 0)
&& ((target->GetType() == cmTarget::EXECUTABLE) && ((target->GetType() == cmTarget::EXECUTABLE)
|| (target->GetType() == cmTarget::STATIC_LIBRARY) || (target->GetType() == cmTarget::STATIC_LIBRARY)
@ -113,24 +129,30 @@ bool cmExportCommand
switch (target->GetType()) switch (target->GetType())
{ {
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
fout << "ADD_EXECUTABLE(" << prefix.c_str() << currentTarget->c_str() << " IMPORT )\n"; fout << "ADD_EXECUTABLE(" << prefix.c_str() << currentTarget->c_str()
<< " IMPORT )\n";
break; break;
case cmTarget::STATIC_LIBRARY: case cmTarget::STATIC_LIBRARY:
fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str() << " STATIC IMPORT )\n"; fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str()
<< " STATIC IMPORT )\n";
break; break;
case cmTarget::SHARED_LIBRARY: case cmTarget::SHARED_LIBRARY:
fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str() << " SHARED IMPORT )\n"; fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str()
<< " SHARED IMPORT )\n";
break; break;
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str() << " MODULE IMPORT )\n"; fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str()
<< " MODULE IMPORT )\n";
break; break;
default: // should never happen default: // should never happen
break; break;
} }
fout << "SET_TARGET_PROPERTIES(" << prefix.c_str() << currentTarget->c_str() << " PROPERTIES \n"; fout << "SET_TARGET_PROPERTIES(" << prefix.c_str()
fout << " LOCATION " << target->GetLocation(0) << "\n"; << currentTarget->c_str() << " PROPERTIES \n"
for(std::vector<std::string>::const_iterator currentConfig = configurationTypes.begin(); << " LOCATION " << target->GetLocation(0) << "\n";
for(std::vector<std::string>::const_iterator
currentConfig = configurationTypes.begin();
currentConfig != configurationTypes.end(); currentConfig != configurationTypes.end();
++currentConfig) ++currentConfig)
{ {
@ -139,15 +161,13 @@ bool cmExportCommand
const char* loc = target->GetLocation(currentConfig->c_str()); const char* loc = target->GetLocation(currentConfig->c_str());
if (loc && *loc) if (loc && *loc)
{ {
fout << " " << currentConfig->c_str()<< "_LOCATION " << loc << "\n"; fout << " " << currentConfig->c_str()
<< "_LOCATION " << loc << "\n";
} }
} }
} }
fout << " )\n\n"; fout << " )\n\n";
} }
else
{
}
} }
return true; return true;