mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-08 07:10:12 -05:00
cmGeneratorTarget: Compute consumed object libraries on demand.
Remove up-front object library computation from cmGlobalGenerator. Adjust tests for message coming from the generator expression evaluation.
This commit is contained in:
@@ -503,57 +503,6 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
|
||||
this->Target->GetSourceFiles(files);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmGeneratorTarget::LookupObjectLibraries()
|
||||
{
|
||||
std::vector<std::string> const& objLibs =
|
||||
this->Target->GetObjectLibraries();
|
||||
for(std::vector<std::string>::const_iterator oli = objLibs.begin();
|
||||
oli != objLibs.end(); ++oli)
|
||||
{
|
||||
std::string const& objLibName = *oli;
|
||||
if(cmTarget* objLib = this->Makefile->FindTargetToUse(objLibName))
|
||||
{
|
||||
if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
|
||||
{
|
||||
if(this->Target->GetType() != cmTarget::EXECUTABLE &&
|
||||
this->Target->GetType() != cmTarget::STATIC_LIBRARY &&
|
||||
this->Target->GetType() != cmTarget::SHARED_LIBRARY &&
|
||||
this->Target->GetType() != cmTarget::MODULE_LIBRARY)
|
||||
{
|
||||
this->GlobalGenerator->GetCMakeInstance()
|
||||
->IssueMessage(cmake::FATAL_ERROR,
|
||||
"Only executables and non-OBJECT libraries may "
|
||||
"reference target objects.",
|
||||
this->Target->GetBacktrace());
|
||||
return;
|
||||
}
|
||||
this->ObjectLibraries.push_back(objLib);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "Objects of target \"" << objLibName
|
||||
<< "\" referenced but is not an OBJECT library.";
|
||||
this->GlobalGenerator->GetCMakeInstance()
|
||||
->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
||||
this->Target->GetBacktrace());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cmOStringStream e;
|
||||
e << "Objects of target \"" << objLibName
|
||||
<< "\" referenced but no such target exists.";
|
||||
this->GlobalGenerator->GetCMakeInstance()
|
||||
->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
||||
this->Target->GetBacktrace());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmGeneratorTarget::GetModuleDefinitionFile() const
|
||||
{
|
||||
@@ -566,9 +515,26 @@ std::string cmGeneratorTarget::GetModuleDefinitionFile() const
|
||||
void
|
||||
cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const
|
||||
{
|
||||
std::vector<cmSourceFile const*> objectFiles;
|
||||
this->GetExternalObjects(objectFiles);
|
||||
std::vector<cmTarget*> objectLibraries;
|
||||
std::set<cmTarget*> emitted;
|
||||
for(std::vector<cmSourceFile const*>::const_iterator
|
||||
it = objectFiles.begin(); it != objectFiles.end(); ++it)
|
||||
{
|
||||
std::string objLib = (*it)->GetObjectLibrary();
|
||||
if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
|
||||
{
|
||||
if (emitted.insert(tgt).second)
|
||||
{
|
||||
objectLibraries.push_back(tgt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(std::vector<cmTarget*>::const_iterator
|
||||
ti = this->ObjectLibraries.begin();
|
||||
ti != this->ObjectLibraries.end(); ++ti)
|
||||
ti = objectLibraries.begin();
|
||||
ti != objectLibraries.end(); ++ti)
|
||||
{
|
||||
cmTarget* objLib = *ti;
|
||||
cmGeneratorTarget* ogt =
|
||||
|
||||
Reference in New Issue
Block a user