summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-02-26 14:59:18 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-03-31 21:18:44 (GMT)
commitbf98cc252f18e761ed9a57d2f7a9304bfbb621de (patch)
tree11dddd9eb207be750e39a959baae2bb3c115799b /Source
parent8cd113ad1d715cc9ce865956870cd462d3659089 (diff)
downloadCMake-bf98cc252f18e761ed9a57d2f7a9304bfbb621de.zip
CMake-bf98cc252f18e761ed9a57d2f7a9304bfbb621de.tar.gz
CMake-bf98cc252f18e761ed9a57d2f7a9304bfbb621de.tar.bz2
Genex: Evaluate TARGET_OBJECTS as a normal expression.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx64
-rw-r--r--Source/cmSourceFile.cxx12
-rw-r--r--Source/cmSourceFile.h4
3 files changed, 80 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 14b2a1a..669694c 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -15,6 +15,8 @@
#include "cmGeneratorExpressionParser.h"
#include "cmGeneratorExpressionDAGChecker.h"
#include "cmGeneratorExpression.h"
+#include "cmLocalGenerator.h"
+#include "cmSourceFile.h"
#include <cmsys/String.h>
@@ -1240,6 +1242,67 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode
} targetNameNode;
//----------------------------------------------------------------------------
+static const struct TargetObjectsNode : public cmGeneratorExpressionNode
+{
+ TargetObjectsNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ std::string tgtName = parameters.front();
+ cmGeneratorTarget* gt =
+ context->Makefile->FindGeneratorTargetToUse(tgtName.c_str());
+ if (!gt)
+ {
+ cmOStringStream e;
+ e << "Objects of target \"" << tgtName
+ << "\" referenced but no such target exists.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return std::string();
+ }
+ if (gt->GetType() != cmTarget::OBJECT_LIBRARY)
+ {
+ cmOStringStream e;
+ e << "Objects of target \"" << tgtName
+ << "\" referenced but is not an OBJECT library.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return std::string();
+ }
+
+ std::vector<cmSourceFile const*> objectSources;
+ gt->GetObjectSources(objectSources);
+ std::map<cmSourceFile const*, std::string> mapping;
+
+ for(std::vector<cmSourceFile const*>::const_iterator it
+ = objectSources.begin(); it != objectSources.end(); ++it)
+ {
+ mapping[*it];
+ }
+
+ gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
+
+ std::string obj_dir = gt->ObjectDirectory;
+ std::string result;
+ const char* sep = "";
+ for(std::map<cmSourceFile const*, std::string>::const_iterator it
+ = mapping.begin(); it != mapping.end(); ++it)
+ {
+ assert(!it->second.empty());
+ result += sep;
+ std::string objFile = obj_dir + it->second;
+ cmSourceFile* sf = context->Makefile->GetOrCreateSource(objFile, true);
+ sf->SetObjectLibrary(tgtName);
+ sf->SetProperty("EXTERNAL_OBJECT", "1");
+ result += objFile;
+ sep = ";";
+ }
+ return result;
+ }
+} targetObjectsNode;
+
+//----------------------------------------------------------------------------
static const char* targetPolicyWhitelist[] = {
0
#define TARGET_POLICY_STRING(POLICY) \
@@ -1593,6 +1656,7 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
nodeMap["SEMICOLON"] = &semicolonNode;
nodeMap["TARGET_PROPERTY"] = &targetPropertyNode;
nodeMap["TARGET_NAME"] = &targetNameNode;
+ nodeMap["TARGET_OBJECTS"] = &targetObjectsNode;
nodeMap["TARGET_POLICY"] = &targetPolicyNode;
nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode;
nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode;
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index b9b6251..0ab30a2 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -39,6 +39,18 @@ std::string const& cmSourceFile::GetExtension() const
}
//----------------------------------------------------------------------------
+void cmSourceFile::SetObjectLibrary(std::string const& objlib)
+{
+ this->ObjectLibrary = objlib;
+}
+
+//----------------------------------------------------------------------------
+std::string cmSourceFile::GetObjectLibrary() const
+{
+ return this->ObjectLibrary;
+}
+
+//----------------------------------------------------------------------------
std::string cmSourceFile::GetLanguage()
{
// If the language was set explicitly by the user then use it.
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 17c96ac..755a2cf 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -97,6 +97,9 @@ public:
*/
bool Matches(cmSourceFileLocation const&);
+ void SetObjectLibrary(std::string const& objlib);
+ std::string GetObjectLibrary() const;
+
private:
cmSourceFileLocation Location;
cmPropertyMap Properties;
@@ -105,6 +108,7 @@ private:
std::string Language;
std::string FullPath;
bool FindFullPathFailed;
+ std::string ObjectLibrary;
bool FindFullPath(std::string* error);
bool TryFullPath(const std::string& path, const std::string& ext);