summaryrefslogtreecommitdiffstats
path: root/Source/cmTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-03-12 18:40:58 (GMT)
committerBrad King <brad.king@kitware.com>2012-03-16 14:12:15 (GMT)
commitc403f27a2de2327f5c895972e16a81d80968c40c (patch)
tree20836fe0e36e6ba3abaef61bf7ba394bfcbb02b8 /Source/cmTarget.cxx
parent3a53005f7dd5e582b855ef1f3c0e6814ce7d024a (diff)
downloadCMake-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/cmTarget.cxx')
-rw-r--r--Source/cmTarget.cxx42
1 files changed, 41 insertions, 1 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 9e86681..708a989 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1724,7 +1724,15 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
for(std::vector<std::string>::const_iterator i = srcs.begin();
i != srcs.end(); ++i)
{
- this->AddSource(i->c_str());
+ const char* src = i->c_str();
+ if(src[0] == '$' && src[1] == '<')
+ {
+ this->ProcessSourceExpression(*i);
+ }
+ else
+ {
+ this->AddSource(src);
+ }
}
}
@@ -1743,6 +1751,24 @@ cmSourceFile* cmTarget::AddSource(const char* s)
}
//----------------------------------------------------------------------------
+void cmTarget::ProcessSourceExpression(std::string const& expr)
+{
+ if(strncmp(expr.c_str(), "$<TARGET_OBJECTS:", 17) == 0 &&
+ expr[expr.size()-1] == '>')
+ {
+ std::string objLibName = expr.substr(17, expr.size()-18);
+ this->ObjectLibraries.push_back(objLibName);
+ }
+ else
+ {
+ cmOStringStream e;
+ e << "Unrecognized generator expression:\n"
+ << " " << expr;
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ }
+}
+
+//----------------------------------------------------------------------------
struct cmTarget::SourceFileFlags
cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf)
{
@@ -4542,7 +4568,21 @@ void cmTarget::ComputeLinkImplementation(const char* config,
// This target needs runtime libraries for its source languages.
std::set<cmStdString> languages;
+ // Get languages used in our source files.
this->GetLanguages(languages);
+ // Get languages used in object library sources.
+ for(std::vector<std::string>::iterator i = this->ObjectLibraries.begin();
+ i != this->ObjectLibraries.end(); ++i)
+ {
+ if(cmTarget* objLib = this->Makefile->FindTargetToUse(i->c_str()))
+ {
+ if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
+ {
+ objLib->GetLanguages(languages);
+ }
+ }
+ }
+ // Copy the set of langauges to the link implementation.
for(std::set<cmStdString>::iterator li = languages.begin();
li != languages.end(); ++li)
{