Attached Files | 0001-Add-TARGET_INFO-genex.patch [^] (6,613 bytes) 2015-03-16 14:47 [Show Content] [Hide Content]From cd1df6249844d18218cdee3b239f55672ce5693b Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 5 Jan 2014 04:13:35 +0100
Subject: [PATCH] Add TARGET_INFO genex.
---
Source/cmGeneratorExpressionNode.cxx | 167 +++++++++++++++++++++++++++++++++++
1 file changed, 167 insertions(+)
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 673dcb9..2bdbeb4 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -13,6 +13,7 @@
#include "cmGeneratorExpressionNode.h"
#include "cmGlobalGenerator.h"
#include "cmAlgorithms.h"
+#include "cmComputeLinkInformation.h"
//----------------------------------------------------------------------------
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
@@ -1547,6 +1548,172 @@ static const struct InstallPrefixNode : public cmGeneratorExpressionNode
} installPrefixNode;
//----------------------------------------------------------------------------
+static const struct TargetInfoNode : public cmGeneratorExpressionNode
+{
+ TargetInfoNode() {}
+
+ virtual int NumExpectedParameters() const { return OneOrMoreParameters; }
+
+ std::string Evaluate(const std::vector<std::string> ¶meters,
+ cmGeneratorExpressionContext * context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ std::string tgtName = parameters.front();
+ std::string info = parameters[1];
+ std::string iface;
+ if (parameters.size() > 2)
+ {
+ iface = parameters[2]; // BUILD_INTERFACE or INSTALL_INTERFACE
+ }
+ cmGeneratorTarget* gt =
+ context->Makefile->FindGeneratorTargetToUse(tgtName);
+ if (!gt)
+ {
+ std::ostringstream e;
+ e << "Information of target \"" << tgtName
+ << "\" referenced but no such target exists.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return std::string();
+ }
+ else if (info == "OBJECT_SOURCES")
+ {
+ std::vector<cmSourceFile const*> files;
+ gt->GetObjectSources(files, context->Config);
+ return this->Join(files);
+ }
+ else if (info == "HEADER_SOURCES")
+ {
+ std::vector<cmSourceFile const*> files;
+ gt->GetHeaderSources(files, context->Config);
+ return this->Join(files);
+ }
+ else if (info == "EXTRA_SOURCES")
+ {
+ std::vector<cmSourceFile const*> files;
+ gt->GetExtraSources(files, context->Config);
+ return this->Join(files);
+ }
+ else if (info == "EXTERNAL_OBJECTS")
+ {
+ // TODO: Only allow for Makefile/Ninja generators.
+ std::vector<cmSourceFile const*> files;
+ gt->GetExternalObjects(files, context->Config);
+ return this->Join(files);
+ }
+ else if (info == "CUSTOM_COMMAND_SOURCES")
+ {
+ std::vector<cmSourceFile const*> files;
+ gt->GetCustomCommands(files, context->Config);
+ return this->Join(files);
+ }
+ else if (info == "LINKED_LIBRARIES")
+ {
+ // TODO: INSTALL_INTERFACE filenames only.
+ cmComputeLinkInformation* cli =
+ gt->Target->GetLinkInformation(context->Config);
+ assert(cli);
+ return this->Join(cli->GetDepends());
+ }
+ else if (info == "INCLUDE_DIRECTORIES")
+ {
+ // TODO: INSTALL_INTERFACE relative only.
+ // What does that mean for transitivity?
+ // Need a redesign with configurable behaviors for
+ // installInterfaceNode and buildInterfaceNode? Set the context with
+ // a property which knows what it's evaluating?
+ std::string prepro = cmGeneratorExpression::Preprocess(
+ gt->GetProperty("INCLUDE_DIRECTORIES"),
+ cmGeneratorExpression::InstallInterface);
+ }
+ else
+ {
+ std::ostringstream e;
+ e << "Information for \"" << info
+ << "\" Not available.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return std::string();
+ }
+// if (info == "ALL_LIB_DEPENDS")
+// {
+// tgt->GetProperty("LINK_LIBRARIES");
+// }
+// else if (info == "ALL_INTERFACE_LIB_DEPENDS")
+// {
+// tgt->GetProperty("INTERFACE_LINK_LIBRARIES");
+// }
+// else if (info == "ALL_INTERFACE_TARGET_DEPENDS")
+// {
+// tgt->GetProperty("INTERFACE_LINK_LIBRARIES");
+// }
+// else if (info == "ALL_INTERFACE_LOCAL_TARGET_DEPENDS")
+// {
+// tgt->GetProperty("INTERFACE_LINK_LIBRARIES");
+// }
+// else if (info == "ALL_INTERFACE_IMPORTED_TARGET_DEPENDS")
+// {
+// tgt->GetProperty("INTERFACE_LINK_LIBRARIES");
+// }
+// else if (info == "DIRECT_LIB_DEPENDS")
+// {
+// tgt->GetProperty("LINK_LIBRARIES");
+// }
+// else if (info == "DIRECT_TARGET_DEPENDS")
+// {
+// tgt->GetProperty("LINK_LIBRARIES");
+// }
+// else if (info == "DIRECT_LOCAL_TARGET_DEPENDS")
+// {
+// tgt->GetProperty("LINK_LIBRARIES");
+// }
+// else if (info == "DIRECT_IMPORTED_TARGET_DEPENDS")
+// {
+// tgt->GetProperty("LINK_LIBRARIES");
+// }
+// else if (info == "DIRECT_INCLUDE_DIRS")
+// {
+// tgt->GetProperty("INCLUDE_DIRECTORIES");
+// }
+// else if (info == "ALL_INCLUDE_DIRS")
+// {
+// tgt->GetProperty("INCLUDE_DIRECTORIES");
+// }
+// else if (info == "INTERFACE_INCLUDE_DIRS")
+// {
+// tgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES");
+// }
+ // Compile definitions
+ return *parameters.begin() == parameters[1] ? "1" : "0";
+ }
+private:
+ template<typename T>
+ std::string Join(const std::vector<T> &items) const
+ {
+ std::string result;
+ const char *sep = "";
+ for (typename std::vector<T>::const_iterator it = items.begin();
+ it != items.end(); ++it)
+ {
+ result += sep;
+ sep = ";";
+ result += this->GetStringForItem(*it);
+ }
+ return result;
+ }
+
+ std::string GetStringForItem(cmSourceFile const* file) const
+ {
+ return file->GetFullPath();
+ }
+
+ std::string GetStringForItem(std::string const& str) const
+ {
+ return str;
+ }
+
+} targetInfoNode;
+
+//----------------------------------------------------------------------------
class ArtifactNameTag;
class ArtifactLinkerTag;
class ArtifactSonameTag;
--
2.3.0.rc2.2.g0d1c285.dirty
|