summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-03-18 16:07:56 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-04-02 21:12:56 (GMT)
commitfdcefe3c42fefdfcd27e6cf7b679f39cb99db4b9 (patch)
tree63c32eb63120ec2f6394112caa500ae9e3acad6b
parentc355d10865ba0dbaef06d0eafe678627c875a5f5 (diff)
downloadCMake-fdcefe3c42fefdfcd27e6cf7b679f39cb99db4b9.zip
CMake-fdcefe3c42fefdfcd27e6cf7b679f39cb99db4b9.tar.gz
CMake-fdcefe3c42fefdfcd27e6cf7b679f39cb99db4b9.tar.bz2
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.
-rw-r--r--Source/cmGeneratorTarget.cxx72
-rw-r--r--Source/cmGeneratorTarget.h3
-rw-r--r--Source/cmGlobalGenerator.cxx1
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt4
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt4
5 files changed, 27 insertions, 57 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 66f6bdf..64ca863 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -504,57 +504,6 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
}
//----------------------------------------------------------------------------
-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
{
std::string data;
@@ -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 =
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 53e27c5..cb59783 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -84,8 +84,6 @@ public:
*/
void TraceDependencies();
- void LookupObjectLibraries();
-
/** Get sources that must be built before the given source. */
std::vector<cmSourceFile*> const*
GetSourceDepends(cmSourceFile const* sf) const;
@@ -127,7 +125,6 @@ private:
std::map<cmSourceFile const*, std::string> Objects;
std::set<cmSourceFile const*> ExplicitObjectName;
- std::vector<cmTarget*> ObjectLibraries;
mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
void ConstructSourceFileFlags() const;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 2f3c6c9..6caaee3 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1457,7 +1457,6 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects()
continue;
}
cmGeneratorTarget* gt = ti->second;
- gt->LookupObjectLibraries();
this->ComputeTargetObjects(gt);
}
}
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
index f1fcbe8..7060c61 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
@@ -1,4 +1,8 @@
CMake Error at BadSourceExpression2.cmake:1 \(add_library\):
+ Error evaluating generator expression:
+
+ \$<TARGET_OBJECTS:DoesNotExist>
+
Objects of target "DoesNotExist" referenced but no such target exists.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
index ad14a35..838b3d8 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
@@ -1,4 +1,8 @@
CMake Error at BadSourceExpression3.cmake:2 \(add_library\):
+ Error evaluating generator expression:
+
+ \$<TARGET_OBJECTS:NotObjLib>
+
Objects of target "NotObjLib" referenced but is not an OBJECT library.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)