diff options
author | Brad King <brad.king@kitware.com> | 2012-03-12 18:40:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-03-16 14:12:15 (GMT) |
commit | c403f27a2de2327f5c895972e16a81d80968c40c (patch) | |
tree | 20836fe0e36e6ba3abaef61bf7ba394bfcbb02b8 /Source/cmGeneratorTarget.cxx | |
parent | 3a53005f7dd5e582b855ef1f3c0e6814ce7d024a (diff) | |
download | CMake-c403f27a2de2327f5c895972e16a81d80968c40c.zip CMake-c403f27a2de2327f5c895972e16a81d80968c40c.tar.gz CMake-c403f27a2de2327f5c895972e16a81d80968c40c.tar.bz2 |
Add $<TARGET_OBJECTS:...> expression to use an object library
For now do not allow an OBJECT library to reference other object
libraries. Teach cmTarget::ComputeLinkImplementation to include the
languages of object libraries used by a target.
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 369eb5c..c9911a5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -24,6 +24,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t) this->LocalGenerator = this->Makefile->GetLocalGenerator(); this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator(); this->ClassifySources(); + this->LookupObjectLibraries(); } //---------------------------------------------------------------------------- @@ -93,3 +94,76 @@ void cmGeneratorTarget::ClassifySources() this->Target->GetBacktrace()); } } + +//---------------------------------------------------------------------------- +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.c_str())) + { + 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->Target->AddUtility(objLib->GetName()); + 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; + } + } +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) +{ + for(std::vector<cmTarget*>::const_iterator + ti = this->ObjectLibraries.begin(); + ti != this->ObjectLibraries.end(); ++ti) + { + cmTarget* objLib = *ti; + cmGeneratorTarget* ogt = + this->GlobalGenerator->GetGeneratorTarget(objLib); + for(std::vector<cmSourceFile*>::const_iterator + si = ogt->ObjectSources.begin(); + si != ogt->ObjectSources.end(); ++si) + { + std::string obj = ogt->ObjectDirectory; + obj += ogt->Objects[*si]; + objs.push_back(obj); + } + } +} |