From 1583440509a148d216d6691cdaeede1aa24af95c Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Wed, 16 Sep 2015 04:38:52 +0200
Subject: cmGeneratorExpression: Port interface to cmGeneratorTarget.

---
 Source/cmExportFileGenerator.cxx           |  2 +-
 Source/cmExportTryCompileFileGenerator.cxx |  5 +++--
 Source/cmGeneratorExpression.cxx           |  6 +++---
 Source/cmGeneratorExpression.h             |  7 ++++---
 Source/cmGeneratorExpressionContext.cxx    |  9 +++++----
 Source/cmGeneratorExpressionContext.h      |  5 +++--
 Source/cmGeneratorExpressionNode.cxx       | 11 +++++++----
 Source/cmGeneratorExpressionNode.h         |  3 ++-
 Source/cmGeneratorTarget.cxx               | 30 ++++++++++++++----------------
 Source/cmMakefileTargetGenerator.cxx       |  4 +++-
 10 files changed, 45 insertions(+), 37 deletions(-)

diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 4a7a760..d6440ac 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -457,7 +457,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
   this->ReplaceInstallPrefix(dirs);
   cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
   std::string exportDirs = cge->Evaluate(target->GetLocalGenerator(), "",
-                                         false, target->Target);
+                                         false, target);
 
   if (cge->GetHadContextSensitiveCondition())
     {
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 3d302d0..f8dbe31 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -78,10 +78,11 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
 
   cmGeneratorTarget* gtgt =
       tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt);
+  cmGeneratorTarget gDummyHead(&dummyHead, gtgt->GetLocalGenerator());
 
   std::string result = cge->Evaluate(gtgt->GetLocalGenerator(), this->Config,
-                                     false, &dummyHead,
-                                     gtgt->Target, &dagChecker);
+                                     false, &gDummyHead,
+                                     gtgt, &dagChecker);
 
   const std::set<cmTarget const*> &allTargets = cge->GetAllTargetsSeen();
   for(std::set<cmTarget const*>::const_iterator li = allTargets.begin();
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index ef1679f..d9f67f2 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -50,7 +50,7 @@ cmGeneratorExpression::~cmGeneratorExpression()
 //----------------------------------------------------------------------------
 const char *cmCompiledGeneratorExpression::Evaluate(cmLocalGenerator* lg,
   const std::string& config, bool quiet,
-  cmTarget const* headTarget,
+  const cmGeneratorTarget* headTarget,
   cmGeneratorExpressionDAGChecker *dagChecker,
                        std::string const& language) const
 {
@@ -66,8 +66,8 @@ const char *cmCompiledGeneratorExpression::Evaluate(cmLocalGenerator* lg,
 //----------------------------------------------------------------------------
 const char *cmCompiledGeneratorExpression::Evaluate(
   cmLocalGenerator* lg, const std::string& config, bool quiet,
-  cmTarget const* headTarget,
-  cmTarget const* currentTarget,
+  const cmGeneratorTarget* headTarget,
+  const cmGeneratorTarget* currentTarget,
   cmGeneratorExpressionDAGChecker *dagChecker,
   std::string const& language) const
 {
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 8843e0a..d64d6ba 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -20,6 +20,7 @@
 #include <cmsys/auto_ptr.hxx>
 
 class cmTarget;
+class cmGeneratorTarget;
 class cmLocalGenerator;
 class cmListFileBacktrace;
 
@@ -80,13 +81,13 @@ class cmCompiledGeneratorExpression
 public:
   const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
                        bool quiet = false,
-                       cmTarget const* headTarget = 0,
-                       cmTarget const* currentTarget = 0,
+                       cmGeneratorTarget const* headTarget = 0,
+                       cmGeneratorTarget const* currentTarget = 0,
                        cmGeneratorExpressionDAGChecker *dagChecker = 0,
                        std::string const& language = std::string()) const;
   const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
                        bool quiet,
-                       cmTarget const* headTarget,
+                       cmGeneratorTarget const* headTarget,
                        cmGeneratorExpressionDAGChecker *dagChecker,
                        std::string const& language = std::string()) const;
 
diff --git a/Source/cmGeneratorExpressionContext.cxx b/Source/cmGeneratorExpressionContext.cxx
index cd056a0..4daf4e9 100644
--- a/Source/cmGeneratorExpressionContext.cxx
+++ b/Source/cmGeneratorExpressionContext.cxx
@@ -11,11 +11,12 @@
 ============================================================================*/
 
 #include "cmGeneratorExpressionContext.h"
+#include "cmGeneratorTarget.h"
 
 cmGeneratorExpressionContext::cmGeneratorExpressionContext(
       cmLocalGenerator* lg, std::string const& config,
-      bool quiet, cmTarget const* headTarget,
-      cmTarget const* currentTarget,
+      bool quiet, cmGeneratorTarget const* headTarget,
+      const cmGeneratorTarget* currentTarget,
       bool evaluateForBuildsystem,
       cmListFileBacktrace const& backtrace,
       std::string const& language)
@@ -23,8 +24,8 @@ cmGeneratorExpressionContext::cmGeneratorExpressionContext(
     LG(lg),
     Config(config),
     Language(language),
-    HeadTarget(headTarget),
-    CurrentTarget(currentTarget),
+    HeadTarget(headTarget ? headTarget->Target : 0),
+    CurrentTarget(currentTarget ? currentTarget->Target : 0),
     Quiet(quiet),
     HadError(false),
     HadContextSensitiveCondition(false),
diff --git a/Source/cmGeneratorExpressionContext.h b/Source/cmGeneratorExpressionContext.h
index 5b6507d..bbf0fcf 100644
--- a/Source/cmGeneratorExpressionContext.h
+++ b/Source/cmGeneratorExpressionContext.h
@@ -19,14 +19,15 @@
 #include <string>
 
 class cmTarget;
+class cmGeneratorTarget;
 class cmLocalGenerator;
 
 //----------------------------------------------------------------------------
 struct cmGeneratorExpressionContext
 {
   cmGeneratorExpressionContext(cmLocalGenerator* lg, std::string const& config,
-                               bool quiet, cmTarget const* headTarget,
-                               cmTarget const* currentTarget,
+                               bool quiet, const cmGeneratorTarget* headTarget,
+                               cmGeneratorTarget const* currentTarget,
                                bool evaluateForBuildsystem,
                                cmListFileBacktrace const& backtrace,
                                std::string const& language);
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 61852ab..2797d10 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -19,7 +19,8 @@
 std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
     std::string const& prop, cmLocalGenerator *lg,
     cmGeneratorExpressionContext *context,
-    cmTarget const* headTarget, cmTarget const* currentTarget,
+    cmGeneratorTarget const* headTarget,
+    cmGeneratorTarget const* currentTarget,
     cmGeneratorExpressionDAGChecker *dagChecker)
 {
   cmGeneratorExpression ge(context->Backtrace);
@@ -862,8 +863,8 @@ getLinkedTargetsContent(
         cmGeneratorExpressionNode::EvaluateDependentExpression(depString,
                                         target->GetLocalGenerator(),
                                         context,
-                                        headTarget->Target,
-                                        target->Target, dagChecker);
+                                        headTarget,
+                                        target, dagChecker);
     }
   linkedTargetsContent =
     cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent);
@@ -1215,9 +1216,11 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
       }
     if(!interfacePropertyName.empty())
       {
+      cmGeneratorTarget* gHeadTarget =
+          context->LG->GetGlobalGenerator()->GetGeneratorTarget(headTarget);
       std::string result = this->EvaluateDependentExpression(prop,
                                         context->LG, context,
-                                        headTarget, target, &dagChecker);
+                                        gHeadTarget, gtgt, &dagChecker);
       if (!linkedTargetsContent.empty())
         {
         result += (result.empty() ? "" : ";") + linkedTargetsContent;
diff --git a/Source/cmGeneratorExpressionNode.h b/Source/cmGeneratorExpressionNode.h
index 22b6585..db65db1 100644
--- a/Source/cmGeneratorExpressionNode.h
+++ b/Source/cmGeneratorExpressionNode.h
@@ -56,7 +56,8 @@ struct cmGeneratorExpressionNode
   static std::string EvaluateDependentExpression(
     std::string const& prop, cmLocalGenerator *lg,
     cmGeneratorExpressionContext *context,
-    cmTarget const* headTarget, cmTarget const* currentTarget,
+    const cmGeneratorTarget* headTarget,
+    const cmGeneratorTarget* currentTarget,
     cmGeneratorExpressionDAGChecker *dagChecker);
 
   static const cmGeneratorExpressionNode* GetNode(
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 04b0d1f..6033efe 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -524,8 +524,8 @@ static void handleSystemIncludesDep(cmLocalGenerator *lg,
     cmGeneratorExpression ge;
     cmSystemTools::ExpandListArgument(ge.Parse(dirs)
                                       ->Evaluate(lg,
-                                      config, false, headTarget->Target,
-                                      depTgt->Target, dagChecker), result);
+                                      config, false, headTarget,
+                                      depTgt, dagChecker), result);
     }
   if (!depTgt->IsImported() || excludeImported)
     {
@@ -538,8 +538,8 @@ static void handleSystemIncludesDep(cmLocalGenerator *lg,
     cmGeneratorExpression ge;
     cmSystemTools::ExpandListArgument(ge.Parse(dirs)
                                       ->Evaluate(lg,
-                                      config, false, headTarget->Target,
-                                      depTgt->Target, dagChecker), result);
+                                      config, false, headTarget,
+                                      depTgt, dagChecker), result);
     }
 }
 
@@ -880,7 +880,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
       cmGeneratorExpression ge;
       cmSystemTools::ExpandListArgument(ge.Parse(*it)
                                           ->Evaluate(this->LocalGenerator,
-                                          config, false, this->Target,
+                                          config, false, this,
                                           &dagChecker), result);
       }
 
@@ -889,8 +889,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
     for(std::vector<cmGeneratorTarget const*>::const_iterator
           li = deps.begin(), le = deps.end(); li != le; ++li)
       {
-      handleSystemIncludesDep(this->LocalGenerator, *li,
-                              config, this,
+      handleSystemIncludesDep(this->LocalGenerator, *li, config, this,
                               &dagChecker, result, excludeImported);
       }
 
@@ -966,8 +965,8 @@ static bool processSources(cmGeneratorTarget const* tgt,
                                               tgt->GetLocalGenerator(),
                                               config,
                                               false,
-                                              tgt->Target,
-                                              tgt->Target,
+                                              tgt,
+                                              tgt,
                                               dagChecker),
                                     entrySources);
 
@@ -2059,7 +2058,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string> &result,
                                       ->Evaluate(this->LocalGenerator,
                                                 config,
                                                 false,
-                                                this->Target,
+                                                this,
                                                 &dagChecker),
                                   result);
 }
@@ -2544,7 +2543,7 @@ static void processIncludeDirectories(cmGeneratorTarget const* tgt,
                                         tgt->GetLocalGenerator(),
                                               config,
                                               false,
-                                              tgt->Target,
+                                              tgt,
                                               dagChecker, language),
                                     entryIncludes);
 
@@ -2755,7 +2754,7 @@ static void processCompileOptionsInternal(cmGeneratorTarget const* tgt,
                                         tgt->GetLocalGenerator(),
                                               config,
                                               false,
-                                              tgt->Target,
+                                              tgt,
                                               dagChecker,
                                               language),
                                     entryOptions);
@@ -4455,8 +4454,8 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
                                       this->LocalGenerator,
                                       config,
                                       false,
-                                      headTarget->Target,
-                                      this->Target, &dagChecker), libs);
+                                      headTarget,
+                                      this, &dagChecker), libs);
   this->LookupLinkItems(libs, items);
   hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
 }
@@ -5347,8 +5346,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
     cmsys::auto_ptr<cmCompiledGeneratorExpression> const cge =
       ge.Parse(*le);
     std::string const evaluated =
-      cge->Evaluate(this->LocalGenerator, config, false,
-                    head->Target, &dagChecker);
+      cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
     cmSystemTools::ExpandListArgument(evaluated, llibs);
     if(cge->GetHadHeadSensitiveCondition())
       {
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index b896659..abcda21 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -149,7 +149,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
 
     cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator,
                                                     config,
-                                                  false, this->Target, 0, 0),
+                                                    false,
+                                                    this->GeneratorTarget,
+                                                    0, 0),
                                       this->CleanFiles);
     }
 
-- 
cgit v0.12