From 3f8aa62bfb339dded326b0bc36016134a3dc845b Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Fri, 23 Oct 2015 00:42:58 +0200
Subject: cmGeneratorTarget: Add API for target-relative commands.

---
 Source/cmGeneratorTarget.cxx                   | 24 +++++++++++++++++++++---
 Source/cmGeneratorTarget.h                     |  4 ++++
 Source/cmGhsMultiTargetGenerator.cxx           |  4 ++--
 Source/cmGlobalXCodeGenerator.cxx              |  6 +++---
 Source/cmLocalUnixMakefileGenerator3.cxx       |  8 ++++----
 Source/cmLocalVisualStudio6Generator.cxx       | 26 +++++++++++++-------------
 Source/cmLocalVisualStudio7Generator.cxx       |  8 ++++----
 Source/cmMakefileExecutableTargetGenerator.cxx |  6 +++---
 Source/cmMakefileLibraryTargetGenerator.cxx    |  8 ++++----
 Source/cmMakefileUtilityTargetGenerator.cxx    |  8 ++++----
 Source/cmNinjaNormalTargetGenerator.cxx        |  6 +++---
 Source/cmNinjaUtilityTargetGenerator.cxx       |  4 ++--
 Source/cmVisualStudio10TargetGenerator.cxx     |  8 ++++----
 13 files changed, 71 insertions(+), 49 deletions(-)

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index fe6b446..b224f09 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -833,6 +833,24 @@ const char* cmGeneratorTarget::GetLocation(const std::string& config) const
   return location.c_str();
 }
 
+std::vector<cmCustomCommand> const&
+cmGeneratorTarget::GetPreBuildCommands() const
+{
+  return this->Target->GetPreBuildCommands();
+}
+
+std::vector<cmCustomCommand> const&
+cmGeneratorTarget::GetPreLinkCommands() const
+{
+  return this->Target->GetPreLinkCommands();
+}
+
+std::vector<cmCustomCommand> const&
+cmGeneratorTarget::GetPostBuildCommands() const
+{
+  return this->Target->GetPostBuildCommands();
+}
+
 bool cmGeneratorTarget::IsImported() const
 {
   return this->Target->IsImported();
@@ -2267,11 +2285,11 @@ cmTargetTraceDependencies
 
   // Queue pre-build, pre-link, and post-build rule dependencies.
   this->CheckCustomCommands(
-        this->GeneratorTarget->Target->GetPreBuildCommands());
+        this->GeneratorTarget->GetPreBuildCommands());
   this->CheckCustomCommands(
-        this->GeneratorTarget->Target->GetPreLinkCommands());
+        this->GeneratorTarget->GetPreLinkCommands());
   this->CheckCustomCommands(
-        this->GeneratorTarget->Target->GetPostBuildCommands());
+        this->GeneratorTarget->GetPostBuildCommands());
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 544cf0e..2b2dc86 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -33,6 +33,10 @@ public:
   bool IsImported() const;
   const char *GetLocation(const std::string& config) const;
 
+  std::vector<cmCustomCommand> const &GetPreBuildCommands() const;
+  std::vector<cmCustomCommand> const &GetPreLinkCommands() const;
+  std::vector<cmCustomCommand> const &GetPostBuildCommands() const;
+
 #define DECLARE_TARGET_POLICY(POLICY) \
   cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
     { return this->PolicyMap.Get(cmPolicies::POLICY); }
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 12115be..18e140e 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -392,10 +392,10 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries()
 void cmGhsMultiTargetGenerator::WriteCustomCommands()
 {
   WriteCustomCommandsHelper(
-        this->GeneratorTarget->Target->GetPreBuildCommands(),
+        this->GeneratorTarget->GetPreBuildCommands(),
         cmTarget::PRE_BUILD);
   WriteCustomCommandsHelper(
-        this->GeneratorTarget->Target->GetPostBuildCommands(),
+        this->GeneratorTarget->GetPostBuildCommands(),
         cmTarget::POST_BUILD);
 }
 
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index eecc82b..e6af94f 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1469,11 +1469,11 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
                                                   cmGeneratorTarget* gtgt)
 {
   std::vector<cmCustomCommand> const & prebuild
-    = gtgt->Target->GetPreBuildCommands();
+    = gtgt->GetPreBuildCommands();
   std::vector<cmCustomCommand> const & prelink
-    = gtgt->Target->GetPreLinkCommands();
+    = gtgt->GetPreLinkCommands();
   std::vector<cmCustomCommand> postbuild
-    = gtgt->Target->GetPostBuildCommands();
+    = gtgt->GetPostBuildCommands();
 
   if(gtgt->GetType() == cmState::SHARED_LIBRARY &&
     !gtgt->IsFrameworkOnApple())
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 34a50a3..541257b 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1787,15 +1787,15 @@ void cmLocalUnixMakefileGenerator3
 
       // Global targets store their rules in pre- and post-build commands.
       this->AppendCustomDepends(depends,
-                                gt->Target->GetPreBuildCommands());
+                                gt->GetPreBuildCommands());
       this->AppendCustomDepends(depends,
-                                gt->Target->GetPostBuildCommands());
+                                gt->GetPostBuildCommands());
       this->AppendCustomCommands(commands,
-                                 gt->Target->GetPreBuildCommands(),
+                                 gt->GetPreBuildCommands(),
                                  gt,
                                  cmLocalGenerator::START_OUTPUT);
       this->AppendCustomCommands(commands,
-                                 gt->Target->GetPostBuildCommands(),
+                                 gt->GetPostBuildCommands(),
                                  gt,
                                  cmLocalGenerator::START_OUTPUT);
       std::string targetName = gt->GetName();
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index d5abf68..3b25eda 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -266,21 +266,21 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
   // depend only on the previous rule.
   if ((target->GetType() == cmState::UTILITY ||
       target->GetType() == cmState::GLOBAL_TARGET) &&
-      (!target->Target->GetPreBuildCommands().empty() ||
-       !target->Target->GetPostBuildCommands().empty()))
+      (!target->GetPreBuildCommands().empty() ||
+       !target->GetPostBuildCommands().empty()))
     {
     // Accumulate the dependencies of all the commands.
     std::vector<std::string> depends;
     for (std::vector<cmCustomCommand>::const_iterator cr =
-           target->Target->GetPreBuildCommands().begin();
-         cr != target->Target->GetPreBuildCommands().end(); ++cr)
+           target->GetPreBuildCommands().begin();
+         cr != target->GetPreBuildCommands().end(); ++cr)
       {
       depends.insert(depends.end(),
                      cr->GetDepends().begin(), cr->GetDepends().end());
       }
     for (std::vector<cmCustomCommand>::const_iterator cr =
-           target->Target->GetPostBuildCommands().begin();
-         cr != target->Target->GetPostBuildCommands().end(); ++cr)
+           target->GetPostBuildCommands().begin();
+         cr != target->GetPostBuildCommands().end(); ++cr)
       {
       depends.insert(depends.end(),
                      cr->GetDepends().begin(), cr->GetDepends().end());
@@ -289,14 +289,14 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
     // Add the pre- and post-build commands in order.
     int count = 1;
     for (std::vector<cmCustomCommand>::const_iterator cr =
-           target->Target->GetPreBuildCommands().begin();
-         cr != target->Target->GetPreBuildCommands().end(); ++cr)
+           target->GetPreBuildCommands().begin();
+         cr != target->GetPreBuildCommands().end(); ++cr)
       {
       this->AddUtilityCommandHack(target, count++, depends, *cr);
       }
     for (std::vector<cmCustomCommand>::const_iterator cr =
-           target->Target->GetPostBuildCommands().begin();
-         cr != target->Target->GetPostBuildCommands().end(); ++cr)
+           target->GetPostBuildCommands().begin();
+         cr != target->GetPostBuildCommands().end(); ++cr)
       {
       this->AddUtilityCommandHack(target, count++, depends, *cr);
       }
@@ -838,8 +838,8 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target,
 
   // Write the pre-build and pre-link together (VS6 does not support both).
   event.Start("PreLink");
-  event.Write(target->Target->GetPreBuildCommands());
-  event.Write(target->Target->GetPreLinkCommands());
+  event.Write(target->GetPreBuildCommands());
+  event.Write(target->GetPreLinkCommands());
   cmsys::auto_ptr<cmCustomCommand> pcc(
     this->MaybeCreateImplibDir(target, configName, false));
   if(pcc.get())
@@ -855,7 +855,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmGeneratorTarget *target,
 
   // Write the post-build rules.
   event.Start("PostBuild");
-  event.Write(target->Target->GetPostBuildCommands());
+  event.Write(target->GetPostBuildCommands());
   event.Finish();
 
   customRuleCode += "# End Special Build Tool\n";
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index ca8d697..95a299d 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -2021,7 +2021,7 @@ void cmLocalVisualStudio7Generator
   const char* tool =
     this->FortranProject? "VFPreBuildEventTool":"VCPreBuildEventTool";
   event.Start(tool);
-  event.Write(target->Target->GetPreBuildCommands());
+  event.Write(target->GetPreBuildCommands());
   event.Finish();
 
   // Add pre-link event.
@@ -2035,7 +2035,7 @@ void cmLocalVisualStudio7Generator
       {
       addedPrelink = true;
       std::vector<cmCustomCommand> commands =
-        target->Target->GetPreLinkCommands();
+        target->GetPreLinkCommands();
       cmGlobalVisualStudioGenerator* gg
         = static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
       gg->AddSymbolExportCommand(
@@ -2045,7 +2045,7 @@ void cmLocalVisualStudio7Generator
     }
   if (!addedPrelink)
     {
-    event.Write(target->Target->GetPreLinkCommands());
+    event.Write(target->GetPreLinkCommands());
     }
   cmsys::auto_ptr<cmCustomCommand> pcc(
     this->MaybeCreateImplibDir(target,
@@ -2059,7 +2059,7 @@ void cmLocalVisualStudio7Generator
   // Add post-build event.
   tool = this->FortranProject? "VFPostBuildEventTool":"VCPostBuildEventTool";
   event.Start(tool);
-  event.Write(target->Target->GetPostBuildCommands());
+  event.Write(target->GetPostBuildCommands());
   event.Finish();
 }
 
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index f56037f..9e35e4c 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -279,11 +279,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
     {
     this->LocalGenerator
       ->AppendCustomCommands(commands,
-                        this->GeneratorTarget->Target->GetPreBuildCommands(),
+                        this->GeneratorTarget->GetPreBuildCommands(),
                         this->GeneratorTarget);
     this->LocalGenerator
       ->AppendCustomCommands(commands,
-                        this->GeneratorTarget->Target->GetPreLinkCommands(),
+                        this->GeneratorTarget->GetPreLinkCommands(),
                         this->GeneratorTarget);
     }
 
@@ -450,7 +450,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
     {
     this->LocalGenerator->
       AppendCustomCommands(commands,
-                       this->GeneratorTarget->Target->GetPostBuildCommands(),
+                       this->GeneratorTarget->GetPostBuildCommands(),
                        this->GeneratorTarget);
     }
 
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 0a65641..1923ea4 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -114,7 +114,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
   // Add post-build rules.
   this->LocalGenerator->
     AppendCustomCommands(commands,
-                         this->GeneratorTarget->Target->GetPostBuildCommands(),
+                         this->GeneratorTarget->GetPostBuildCommands(),
                          this->GeneratorTarget);
 
   // Depend on the object files.
@@ -458,11 +458,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     {
     this->LocalGenerator
       ->AppendCustomCommands(commands,
-                        this->GeneratorTarget->Target->GetPreBuildCommands(),
+                        this->GeneratorTarget->GetPreBuildCommands(),
                         this->GeneratorTarget);
     this->LocalGenerator
       ->AppendCustomCommands(commands,
-                        this->GeneratorTarget->Target->GetPreLinkCommands(),
+                        this->GeneratorTarget->GetPreLinkCommands(),
                         this->GeneratorTarget);
     }
 
@@ -814,7 +814,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     {
     this->LocalGenerator->
       AppendCustomCommands(commands,
-                       this->GeneratorTarget->Target->GetPostBuildCommands(),
+                       this->GeneratorTarget->GetPostBuildCommands(),
                        this->GeneratorTarget);
     }
 
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index d35c3ae..5b62cbf 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -67,20 +67,20 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
 
   // Utility targets store their rules in pre- and post-build commands.
   this->LocalGenerator->AppendCustomDepends
-    (depends, this->GeneratorTarget->Target->GetPreBuildCommands());
+    (depends, this->GeneratorTarget->GetPreBuildCommands());
 
   this->LocalGenerator->AppendCustomDepends
-    (depends, this->GeneratorTarget->Target->GetPostBuildCommands());
+    (depends, this->GeneratorTarget->GetPostBuildCommands());
 
   this->LocalGenerator->AppendCustomCommands
-    (commands, this->GeneratorTarget->Target->GetPreBuildCommands(),
+    (commands, this->GeneratorTarget->GetPreBuildCommands(),
      this->GeneratorTarget);
 
   // Depend on all custom command outputs for sources
   this->DriveCustomCommands(depends);
 
   this->LocalGenerator->AppendCustomCommands
-    (commands, this->GeneratorTarget->Target->GetPostBuildCommands(),
+    (commands, this->GeneratorTarget->GetPostBuildCommands(),
      this->GeneratorTarget);
 
   // Add dependencies on targets that must be built first.
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index b533d37..17561b5 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -598,9 +598,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     }
 
   const std::vector<cmCustomCommand> *cmdLists[3] = {
-    &gt.Target->GetPreBuildCommands(),
-    &gt.Target->GetPreLinkCommands(),
-    &gt.Target->GetPostBuildCommands()
+    &gt.GetPreBuildCommands(),
+    &gt.GetPreLinkCommands(),
+    &gt.GetPostBuildCommands()
   };
 
   std::vector<std::string> preLinkCmdLines, postBuildCmdLines;
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index b2a5334..edc65f0 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -33,8 +33,8 @@ void cmNinjaUtilityTargetGenerator::Generate()
   cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
 
   const std::vector<cmCustomCommand> *cmdLists[2] = {
-    &this->GetGeneratorTarget()->Target->GetPreBuildCommands(),
-    &this->GetGeneratorTarget()->Target->GetPostBuildCommands()
+    &this->GetGeneratorTarget()->GetPreBuildCommands(),
+    &this->GetGeneratorTarget()->GetPostBuildCommands()
   };
 
   bool uses_terminal = false;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 9c9f5ab..541e5f6 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2814,7 +2814,7 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
       {
       addedPrelink = true;
       std::vector<cmCustomCommand> commands =
-        this->GeneratorTarget->Target->GetPreLinkCommands();
+        this->GeneratorTarget->GetPreLinkCommands();
       this->GlobalGenerator->AddSymbolExportCommand(
         this->GeneratorTarget, commands, configName);
       this->WriteEvent("PreLinkEvent", commands, configName);
@@ -2823,12 +2823,12 @@ cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
   if (!addedPrelink)
     {
     this->WriteEvent("PreLinkEvent",
-        this->GeneratorTarget->Target->GetPreLinkCommands(), configName);
+        this->GeneratorTarget->GetPreLinkCommands(), configName);
     }
   this->WriteEvent("PreBuildEvent",
-        this->GeneratorTarget->Target->GetPreBuildCommands(), configName);
+        this->GeneratorTarget->GetPreBuildCommands(), configName);
   this->WriteEvent("PostBuildEvent",
-        this->GeneratorTarget->Target->GetPostBuildCommands(), configName);
+        this->GeneratorTarget->GetPostBuildCommands(), configName);
 }
 
 void cmVisualStudio10TargetGenerator::WriteEvent(
-- 
cgit v0.12


From cf69630e510a5c639a93a99b315fcefea9688935 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Fri, 23 Oct 2015 00:47:31 +0200
Subject: cmGeneratorTarget: Move GetFrameworkVersion from cmTarget

---
 Source/cmGeneratorTarget.cxx      | 23 +++++++++++++++++++++--
 Source/cmGeneratorTarget.h        |  4 ++++
 Source/cmGlobalXCodeGenerator.cxx |  2 +-
 Source/cmOSXBundleGenerator.cxx   |  2 +-
 Source/cmTarget.cxx               | 19 -------------------
 Source/cmTarget.h                 |  4 ----
 6 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index b224f09..95d93bc 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1641,7 +1641,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config,
   if(!rootDir && !this->Makefile->PlatformIsAppleIos())
     {
     fpath += "/Versions/";
-    fpath += this->Target->GetFrameworkVersion();
+    fpath += this->GetFrameworkVersion();
     }
   return fpath;
 }
@@ -3331,7 +3331,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name,
     if(!this->Makefile->PlatformIsAppleIos())
       {
       realName += "Versions/";
-      realName += this->Target->GetFrameworkVersion();
+      realName += this->GetFrameworkVersion();
       realName += "/";
       }
     realName += base;
@@ -4526,6 +4526,25 @@ void cmGeneratorTarget::GetTargetVersion(bool soversion,
 }
 
 //----------------------------------------------------------------------------
+std::string cmGeneratorTarget::GetFrameworkVersion() const
+{
+  assert(this->GetType() != cmState::INTERFACE_LIBRARY);
+
+  if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION"))
+    {
+    return fversion;
+    }
+  else if(const char* tversion = this->GetProperty("VERSION"))
+    {
+    return tversion;
+    }
+  else
+    {
+    return "A";
+    }
+}
+
+//----------------------------------------------------------------------------
 void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
                                     std::string const& prefix,
                                     std::string const& base,
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 2b2dc86..cc7d585 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -165,6 +165,10 @@ public:
   std::string GetFrameworkDirectory(const std::string& config,
                                     bool rootDir) const;
 
+  /** Return the framework version string.  Undefined if
+      IsFrameworkOnApple returns false.  */
+  std::string GetFrameworkVersion() const;
+
   /** @return the Mac CFBundle directory without the base */
   std::string GetCFBundleDirectory(const std::string& config,
                                    bool contentOnly) const;
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index e6af94f..9a5c367 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2141,7 +2141,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
     {
     if(gtgt->GetPropertyAsBool("FRAMEWORK"))
       {
-      std::string fw_version = gtgt->Target->GetFrameworkVersion();
+      std::string fw_version = gtgt->GetFrameworkVersion();
       buildSettings->AddAttribute("FRAMEWORK_VERSION",
                                   this->CreateString(fw_version.c_str()));
 
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index e9dc433..3c4aa00 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -83,7 +83,7 @@ void cmOSXBundleGenerator::CreateFramework(
   std::string newoutpath = outpath + "/" +
     this->GT->GetFrameworkDirectory(this->ConfigName, false);
 
-  std::string frameworkVersion = this->GT->Target->GetFrameworkVersion();
+  std::string frameworkVersion = this->GT->GetFrameworkVersion();
 
   // Configure the Info.plist file into the Resources directory.
   this->MacContentFolders->insert("Resources");
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index e056469..0c0cf8e 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2048,25 +2048,6 @@ void cmTarget::SetPropertyDefault(const std::string& property,
     }
 }
 
-//----------------------------------------------------------------------------
-std::string cmTarget::GetFrameworkVersion() const
-{
-  assert(this->GetType() != cmState::INTERFACE_LIBRARY);
-
-  if(const char* fversion = this->GetProperty("FRAMEWORK_VERSION"))
-    {
-    return fversion;
-    }
-  else if(const char* tversion = this->GetProperty("VERSION"))
-    {
-    return tversion;
-    }
-  else
-    {
-    return "A";
-    }
-}
-
 bool cmTarget::GetMappedConfig(std::string const& desired_config,
                                const char** loc,
                                const char** imp,
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 1cae94f..7e7e34a 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -209,10 +209,6 @@ public:
   /** Return whether this target is an executable Bundle on Apple.  */
   bool IsAppBundleOnApple() const;
 
-  /** Return the framework version string.  Undefined if
-      IsFrameworkOnApple returns false.  */
-  std::string GetFrameworkVersion() const;
-
   /** Get a backtrace from the creation of the target.  */
   cmListFileBacktrace const& GetBacktrace() const;
 
-- 
cgit v0.12


From bde277e811fea2532ed32ade6d7f3d6e910bfda0 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Fri, 23 Oct 2015 00:49:58 +0200
Subject: cmGeneratorTarget: Add GetLinkDirectories API.

---
 Source/cmComputeLinkInformation.cxx      | 6 +++---
 Source/cmGeneratorTarget.cxx             | 5 +++++
 Source/cmGeneratorTarget.h               | 2 ++
 Source/cmLocalVisualStudio6Generator.cxx | 2 +-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index a32bb48..50d8324 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -377,9 +377,9 @@ cmComputeLinkInformation
 
   // Add the search path entries requested by the user to path ordering.
   this->OrderLinkerSearchPath
-    ->AddUserDirectories(this->Target->Target->GetLinkDirectories());
+    ->AddUserDirectories(this->Target->GetLinkDirectories());
   this->OrderRuntimeSearchPath
-    ->AddUserDirectories(this->Target->Target->GetLinkDirectories());
+    ->AddUserDirectories(this->Target->GetLinkDirectories());
 
   // Set up the implicit link directories.
   this->LoadImplicitLinkInfo();
@@ -413,7 +413,7 @@ cmComputeLinkInformation
     // Construct a mask to not bother with this behavior for link
     // directories already specified by the user.
     std::vector<std::string> const& dirs =
-        this->Target->Target->GetLinkDirectories();
+        this->Target->GetLinkDirectories();
     this->OldLinkDirMask.insert(dirs.begin(), dirs.end());
     }
 
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 95d93bc..7516576 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1732,6 +1732,11 @@ cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
   return this->Target->GetBacktrace();
 }
 
+const std::vector<std::string>&cmGeneratorTarget::GetLinkDirectories() const
+{
+  return this->Target->GetLinkDirectories();
+}
+
 //----------------------------------------------------------------------------
 bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
 {
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index cc7d585..38e1826 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -184,6 +184,8 @@ public:
 
   cmListFileBacktrace GetBacktrace() const;
 
+  const std::vector<std::string>& GetLinkDirectories() const;
+
   /** Get the macro to define when building sources in this target.
       If no macro should be defined null is returned.  */
   const char* GetExportMacro() const;
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 3b25eda..fd0af61 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -1052,7 +1052,7 @@ void cmLocalVisualStudio6Generator
     }
   std::vector<std::string>::const_iterator i;
   const std::vector<std::string>& libdirs =
-      target->Target->GetLinkDirectories();
+      target->GetLinkDirectories();
   for(i = libdirs.begin(); i != libdirs.end(); ++i)
     {
     std::string path = *i;
-- 
cgit v0.12


From f210cb131e5814631d6d2974cf2437632446654f Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Fri, 23 Oct 2015 00:59:36 +0200
Subject: cmTarget: Make compatbility API explicit.

---
 Source/cmMakefile.cxx | 21 ++++++++++++++++-----
 Source/cmTarget.cxx   | 17 -----------------
 Source/cmTarget.h     |  8 ++------
 3 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 40e2892..361aa99 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -756,15 +756,26 @@ void cmMakefile::ConfigureFinalPass()
       "with CMake 2.4 or later. For compatibility with older versions please "
       "use any CMake 2.8.x release or lower.");
     }
-  for (cmTargets::iterator l = this->Targets.begin();
-       l != this->Targets.end(); l++)
+#if defined(_WIN32) && !defined(__CYGWIN__)
+  // Do old-style link dependency analysis only for CM_USE_OLD_VS6.
+  if(this->GetGlobalGenerator()->IsForVS6())
     {
-    if (l->second.GetType() == cmState::INTERFACE_LIBRARY)
+    for (cmTargets::iterator l = this->Targets.begin();
+         l != this->Targets.end(); l++)
       {
-      continue;
+      if (l->second.GetType() == cmState::INTERFACE_LIBRARY)
+        {
+        continue;
+        }
+      // Erase any cached link information that might have been comptued
+      // on-demand during the configuration.  This ensures that build
+      // system generation uses up-to-date information even if other cache
+      // invalidation code in this source file is buggy.
+
+      l->second.AnalyzeLibDependenciesForVS6(*this);
       }
-    l->second.FinishConfigure();
     }
+#endif
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 0c0cf8e..c887fc8 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -315,23 +315,6 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::FinishConfigure()
-{
-  // Erase any cached link information that might have been comptued
-  // on-demand during the configuration.  This ensures that build
-  // system generation uses up-to-date information even if other cache
-  // invalidation code in this source file is buggy.
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  // Do old-style link dependency analysis only for CM_USE_OLD_VS6.
-  if(this->Makefile->GetGlobalGenerator()->IsForVS6())
-    {
-    this->AnalyzeLibDependenciesForVS6(*this->Makefile);
-    }
-#endif
-}
-
-//----------------------------------------------------------------------------
 cmListFileBacktrace const& cmTarget::GetBacktrace() const
 {
   return this->Backtrace;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 7e7e34a..17a1d4d 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -176,9 +176,6 @@ public:
   std::set<std::string>const& GetUtilities() const { return this->Utilities; }
   cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
 
-  /** Finalize the target at the end of the Configure step.  */
-  void FinishConfigure();
-
   ///! Set/Get a property of this target file
   void SetProperty(const std::string& prop, const char *value);
   void AppendProperty(const std::string&  prop, const char* value,
@@ -250,10 +247,11 @@ public:
   cmStringRange GetLinkImplementationEntries() const;
   cmBacktraceRange GetLinkImplementationBacktraces() const;
 
-
 #if defined(_WIN32) && !defined(__CYGWIN__)
   const LinkLibraryVectorType &GetLinkLibrariesForVS6() const {
   return this->LinkLibrariesForVS6;}
+
+  void AnalyzeLibDependenciesForVS6( const cmMakefile& mf );
 #endif
 
   struct StrictTargetComparison {
@@ -312,8 +310,6 @@ private:
   void GatherDependenciesForVS6( const cmMakefile& mf,
                                  const LibraryID& lib,
                                  DependencyMap& dep_map);
-
-  void AnalyzeLibDependenciesForVS6( const cmMakefile& mf );
 #endif
 
   const char* GetSuffixVariableInternal(bool implib) const;
-- 
cgit v0.12


From 736c2042c6bade0322441aafabababcbd92af52e Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Fri, 23 Oct 2015 01:01:46 +0200
Subject: cmGeneratorTarget: Add GetUtilities API

---
 Source/cmGeneratorTarget.cxx              | 7 ++++++-
 Source/cmGeneratorTarget.h                | 1 +
 Source/cmGlobalNinjaGenerator.cxx         | 2 +-
 Source/cmGlobalVisualStudio6Generator.cxx | 2 +-
 Source/cmGlobalVisualStudio7Generator.cxx | 2 +-
 Source/cmGlobalVisualStudio8Generator.cxx | 4 ++--
 Source/cmLocalUnixMakefileGenerator3.cxx  | 4 ++--
 7 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 7516576..7d5a9d0 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -796,7 +796,7 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
   if(!this->UtilityItemsDone)
     {
     this->UtilityItemsDone = true;
-    std::set<std::string> const& utilities = this->Target->GetUtilities();
+    std::set<std::string> const& utilities = this->GetUtilities();
     for(std::set<std::string>::const_iterator i = utilities.begin();
         i != utilities.end(); ++i)
       {
@@ -1737,6 +1737,11 @@ const std::vector<std::string>&cmGeneratorTarget::GetLinkDirectories() const
   return this->Target->GetLinkDirectories();
 }
 
+const std::set<std::string>& cmGeneratorTarget::GetUtilities() const
+{
+  return this->Target->GetUtilities();
+}
+
 //----------------------------------------------------------------------------
 bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
 {
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 38e1826..ff975c5 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -186,6 +186,7 @@ public:
 
   const std::vector<std::string>& GetLinkDirectories() const;
 
+  std::set<std::string>const& GetUtilities() const;
   /** Get the macro to define when building sources in this target.
       If no macro should be defined null is returned.  */
   const char* GetExportMacro() const;
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 2671f4d..8498e39 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -965,7 +965,7 @@ cmGlobalNinjaGenerator
   if (target->GetType() == cmState::GLOBAL_TARGET) {
     // Global targets only depend on other utilities, which may not appear in
     // the TargetDepends set (e.g. "all").
-    std::set<std::string> const& utils = target->Target->GetUtilities();
+    std::set<std::string> const& utils = target->GetUtilities();
     std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
   } else {
     cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index bb494f1..5866c0e 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -235,7 +235,7 @@ void cmGlobalVisualStudio6Generator
       std::string project = target->GetName();
       std::string location = expath;
       this->WriteExternalProject(fout, project.c_str(),
-          location.c_str(), target->Target->GetUtilities());
+          location.c_str(), target->GetUtilities());
       }
     else
       {
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 5473247..340a0f7 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -459,7 +459,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
                                  project.c_str(),
                                  location.c_str(),
                                  target->GetProperty("VS_PROJECT_TYPE"),
-                                 target->Target->GetUtilities());
+                                 target->GetUtilities());
       written = true;
       }
     else
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index bdb1b25..b771f11 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -464,8 +464,8 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
 {
   // Look for utility dependencies that magically link.
   for(std::set<std::string>::const_iterator ui =
-        target->Target->GetUtilities().begin();
-      ui != target->Target->GetUtilities().end(); ++ui)
+        target->GetUtilities().begin();
+      ui != target->GetUtilities().end(); ++ui)
     {
     if(cmGeneratorTarget* depTarget =
         target->GetLocalGenerator()->FindGeneratorTargetToUse(ui->c_str()))
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 541257b..9bb2765 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1778,8 +1778,8 @@ void cmLocalUnixMakefileGenerator3
         {
         text = "Running external command ...";
         }
-      depends.insert(depends.end(), (*glIt)->Target->GetUtilities().begin(),
-                     (*glIt)->Target->GetUtilities().end());
+      depends.insert(depends.end(), (*glIt)->GetUtilities().begin(),
+                     (*glIt)->GetUtilities().end());
       this->AppendEcho(commands, text,
                        cmLocalUnixMakefileGenerator3::EchoGlobal);
 
-- 
cgit v0.12


From 7a1b83cb3fc79639b9e2c1bf11af2d2274e4224a Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Fri, 23 Oct 2015 01:04:07 +0200
Subject: cmGeneratorTarget: Add GetUtilityBacktrace API

---
 Source/cmComputeTargetDepends.cxx | 2 +-
 Source/cmGeneratorTarget.cxx      | 6 ++++++
 Source/cmGeneratorTarget.h        | 2 ++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 113c989..586b5bf 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -382,7 +382,7 @@ void cmComputeTargetDepends::AddTargetDepend(
         << "\" of target \"" << depender->GetName() << "\" does not exist.";
 
       cmListFileBacktrace const* backtrace =
-        depender->Target->GetUtilityBacktrace(dependee_name);
+        depender->GetUtilityBacktrace(dependee_name);
       if(backtrace)
         {
         cm->IssueMessage(messageType, e.str(), *backtrace);
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 7d5a9d0..eb433f5 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1742,6 +1742,12 @@ const std::set<std::string>& cmGeneratorTarget::GetUtilities() const
   return this->Target->GetUtilities();
 }
 
+const cmListFileBacktrace*
+cmGeneratorTarget::GetUtilityBacktrace(const std::string& u) const
+{
+  return this->Target->GetUtilityBacktrace(u);
+}
+
 //----------------------------------------------------------------------------
 bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
 {
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index ff975c5..588ff33 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -187,6 +187,8 @@ public:
   const std::vector<std::string>& GetLinkDirectories() const;
 
   std::set<std::string>const& GetUtilities() const;
+  cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
+
   /** Get the macro to define when building sources in this target.
       If no macro should be defined null is returned.  */
   const char* GetExportMacro() const;
-- 
cgit v0.12


From 7d409f500e3403f8dbb4a0fee6ecdad94f45c35e Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Fri, 23 Oct 2015 01:13:36 +0200
Subject: cmLocalGenerator: Add GetPolicyStatus API

---
 Source/cmGeneratorExpressionNode.cxx |  4 ++--
 Source/cmLocalGenerator.cxx          | 10 ++++++++--
 Source/cmLocalGenerator.h            |  2 ++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 7a7e4ff..03f8d3f 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -393,7 +393,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
 
     if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0)
       {
-      switch(context->LG->GetMakefile()->GetPolicyStatus(cmPolicies::CMP0044))
+      switch(context->LG->GetPolicyStatus(cmPolicies::CMP0044))
         {
         case cmPolicies::WARN:
           {
@@ -1100,7 +1100,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
                            "COMPILE_DEFINITIONS_"))
       {
       cmPolicies::PolicyStatus polSt =
-          context->LG->GetMakefile()->GetPolicyStatus(cmPolicies::CMP0043);
+          context->LG->GetPolicyStatus(cmPolicies::CMP0043);
       if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD)
         {
         interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index c37417d..5f0242e 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2201,7 +2201,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
 
     if (flags && flags != originalFlags)
       {
-      switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0018))
+      switch (this->GetPolicyStatus(cmPolicies::CMP0018))
         {
         case cmPolicies::WARN:
         {
@@ -2949,7 +2949,7 @@ bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
 {
   // Check the policy to decide whether to pay attention to this
   // variable.
-  switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0001))
+  switch(this->GetPolicyStatus(cmPolicies::CMP0001))
     {
     case cmPolicies::WARN:
       // WARN is just OLD without warning because user code does not
@@ -2976,6 +2976,12 @@ bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
           actual_compat <= CMake_VERSION_ENCODE(2, 4, 255));
 }
 
+cmPolicies::PolicyStatus
+cmLocalGenerator::GetPolicyStatus(cmPolicies::PolicyID id) const
+{
+  return this->Makefile->GetPolicyStatus(id);
+}
+
 //----------------------------------------------------------------------------
 bool cmLocalGenerator::CheckDefinition(std::string const& define) const
 {
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 552020b..6380db6 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -265,6 +265,8 @@ public:
    */
   bool NeedBackwardsCompatibility_2_4();
 
+  cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id) const;
+
   cmake* GetCMakeInstance() const;
 
   const char* GetSourceDirectory() const;
-- 
cgit v0.12


From 4c6374bcc56ea7d7f7e67c518e60de94be267256 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Fri, 23 Oct 2015 01:14:08 +0200
Subject: Genex: use cmGeneratorTarget policy API

---
 Source/cmGeneratorExpressionNode.cxx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 03f8d3f..7e75d93 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -1442,7 +1442,7 @@ cmPolicies::PolicyStatus statusForTarget(cmGeneratorTarget const* tgt,
 #define RETURN_POLICY(POLICY) \
   if (strcmp(policy, #POLICY) == 0) \
   { \
-    return tgt->Target->GetPolicyStatus ## POLICY (); \
+    return tgt->GetPolicyStatus ## POLICY (); \
   } \
 
   CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY)
-- 
cgit v0.12


From 00b8c0a8d4b59dc01276d083ccae4a8138718b12 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Fri, 23 Oct 2015 01:17:32 +0200
Subject: cmLocalGenerator: Add IsRootMakefile API

---
 Source/cmGlobalUnixMakefileGenerator3.cxx | 4 ++--
 Source/cmLocalGenerator.cxx               | 5 +++++
 Source/cmLocalGenerator.h                 | 2 ++
 Source/cmLocalNinjaGenerator.cxx          | 4 ++--
 Source/cmLocalUnixMakefileGenerator3.cxx  | 6 +++---
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index b4a915c..7dd24fb 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -523,7 +523,7 @@ cmGlobalUnixMakefileGenerator3
                        cmLocalUnixMakefileGenerator3* lg)
 {
   // Only subdirectories need these rules.
-  if(lg->GetMakefile()->IsRootMakefile())
+  if(lg->IsRootMakefile())
     {
     return;
     }
@@ -1084,7 +1084,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
       static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]);
     // for the passed in makefile or if this is the top Makefile wripte out
     // the targets
-    if (lg2 == lg || lg->GetMakefile()->IsRootMakefile())
+    if (lg2 == lg || lg->IsRootMakefile())
       {
       // for each target Generate the rule files for each target.
       std::vector<cmGeneratorTarget*> targets = lg2->GetGeneratorTargets();
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 5f0242e..1926772 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -490,6 +490,11 @@ void cmLocalGenerator::ComputeTargetManifest()
     }
 }
 
+bool cmLocalGenerator::IsRootMakefile() const
+{
+  return !this->StateSnapshot.GetBuildsystemDirectoryParent().IsValid();
+}
+
 cmState* cmLocalGenerator::GetState() const
 {
   return this->GlobalGenerator->GetCMakeInstance()->GetState();
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 6380db6..46eb1b3 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -67,6 +67,8 @@ public:
    */
   void ComputeTargetManifest();
 
+  bool IsRootMakefile() const;
+
   ///! Get the makefile for this generator
   cmMakefile *GetMakefile() {
     return this->Makefile; }
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 891c44e..7de48a4 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -56,7 +56,7 @@ void cmLocalNinjaGenerator::Generate()
 #endif
 
   // We do that only once for the top CMakeLists.txt file.
-  if(this->Makefile->IsRootMakefile())
+  if(this->IsRootMakefile())
     {
     this->WriteBuildFileTop();
 
@@ -277,7 +277,7 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
     << "# Write statements declared in CMakeLists.txt:" << std::endl
     << "# "
     << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE") << std::endl;
-  if(this->Makefile->IsRootMakefile())
+  if(this->IsRootMakefile())
     os << "# Which is the root file." << std::endl;
   cmGlobalNinjaGenerator::WriteDivider(os);
   os << std::endl;
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 9bb2765..82e3b01 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -254,7 +254,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
     return;
     }
   // always write the top makefile
-  if (!this->GetMakefile()->IsRootMakefile())
+  if (!this->IsRootMakefile())
     {
     ruleFileStream.SetCopyIfDifferent(true);
     }
@@ -265,7 +265,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
   // only write local targets unless at the top Keep track of targets already
   // listed.
   std::set<std::string> emittedTargets;
-  if (!this->GetMakefile()->IsRootMakefile())
+  if (!this->IsRootMakefile())
     {
     // write our targets, and while doing it collect up the object
     // file rules
@@ -880,7 +880,7 @@ void cmLocalUnixMakefileGenerator3
   std::vector<std::string> no_depends;
   std::vector<std::string> commands;
   commands.push_back(runRule);
-  if(!this->GetMakefile()->IsRootMakefile())
+  if(!this->IsRootMakefile())
     {
     this->CreateCDCommand(commands,
                           this->GetBinaryDirectory(),
-- 
cgit v0.12


From b397eae82e14fdf75eddcbfd022d9f2d5933eb1e Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sat, 24 Oct 2015 09:29:49 +0200
Subject: cmGeneratorTarget: Move LinkLanguagePropagatesToDependents from
 cmTarget

---
 Source/cmGeneratorExpressionNode.cxx | 2 +-
 Source/cmGeneratorTarget.cxx         | 4 ++--
 Source/cmGeneratorTarget.h           | 3 +++
 Source/cmTarget.h                    | 3 ---
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 7e75d93..df6e3fb 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -999,7 +999,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
 
     if (propertyName == "LINKER_LANGUAGE")
       {
-      if (target->Target->LinkLanguagePropagatesToDependents() &&
+      if (target->LinkLanguagePropagatesToDependents() &&
           dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries()
             || dagCheckerParent->EvaluatingSources()))
         {
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index eb433f5..651c89c 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -4770,7 +4770,7 @@ void cmGeneratorTarget::ComputeLinkInterface(const std::string& config,
     iface.WrongConfigLibraries = impl->WrongConfigLibraries;
     }
 
-  if(this->Target->LinkLanguagePropagatesToDependents())
+  if(this->LinkLanguagePropagatesToDependents())
     {
     // Targets using this archive need its language runtime libraries.
     if(cmLinkImplementation const* impl =
@@ -5485,7 +5485,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
   }
 
   // Get the link languages.
-  if(this->Target->LinkLanguagePropagatesToDependents())
+  if(this->LinkLanguagePropagatesToDependents())
     {
     std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
     linkProp += suffix;
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 588ff33..58c3421 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -189,6 +189,9 @@ public:
   std::set<std::string>const& GetUtilities() const;
   cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
 
+  bool LinkLanguagePropagatesToDependents() const
+  { return this->GetType() == cmState::STATIC_LIBRARY; }
+
   /** Get the macro to define when building sources in this target.
       If no macro should be defined null is returned.  */
   const char* GetExportMacro() const;
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 17a1d4d..541e850 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -227,9 +227,6 @@ public:
   std::set<std::string> const & GetSystemIncludeDirectories() const
     { return this->SystemIncludeDirectories; }
 
-  bool LinkLanguagePropagatesToDependents() const
-  { return this->TargetTypeValue == cmState::STATIC_LIBRARY; }
-
   cmStringRange GetIncludeDirectoriesEntries() const;
   cmBacktraceRange GetIncludeDirectoriesBacktraces() const;
 
-- 
cgit v0.12


From 6bd7bd1e06fcf92d40c762f2713626d125cb8f87 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sat, 24 Oct 2015 13:30:06 +0200
Subject: Export: Use existing IsDLLPlatform porcelain

---
 Source/cmExportBuildFileGenerator.cxx | 6 +-----
 Source/cmExportFileGenerator.cxx      | 5 +----
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 23c11d7..9e36539 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -213,12 +213,8 @@ cmExportBuildFileGenerator
   properties[prop] = value;
   }
 
-  // Check whether this is a DLL platform.
-  bool dll_platform =
-    (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
-
   // Add the import library for windows DLLs.
-  if(dll_platform &&
+  if(target->IsDLLPlatform() &&
      (target->GetType() == cmState::SHARED_LIBRARY ||
       target->IsExecutableWithExports()) &&
      mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index d52ce35..e8a2e6a 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -879,10 +879,7 @@ cmExportFileGenerator
   if(target->GetType() == cmState::SHARED_LIBRARY ||
      target->GetType() == cmState::MODULE_LIBRARY)
     {
-    // Check whether this is a DLL platform.
-    bool dll_platform =
-      (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
-    if(!dll_platform)
+    if(!target->IsDLLPlatform())
       {
       std::string prop;
       std::string value;
-- 
cgit v0.12


From 780bff5279c6c2d356e5c7726b656bd9c68532b8 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sat, 24 Oct 2015 14:58:23 +0200
Subject: cmake: Store hardcoded lists of sources and headers

Don't duplicate this in each cmMakefile.
---
 Source/cmAuxSourceDirectoryCommand.cxx |  8 ++++----
 Source/cmExtraCodeBlocksGenerator.cxx  | 14 +++++++++-----
 Source/cmExtraCodeLiteGenerator.cxx    | 13 ++++++++-----
 Source/cmGlobalKdevelopGenerator.cxx   |  6 ++++--
 Source/cmGlobalXCodeGenerator.cxx      |  2 +-
 Source/cmMakefile.cxx                  | 25 -------------------------
 Source/cmMakefile.h                    | 13 -------------
 Source/cmQtAutoGenerators.cxx          |  2 +-
 Source/cmSourceFile.cxx                |  6 ++++--
 Source/cmSourceFileLocation.cxx        | 12 ++++++++----
 Source/cmake.cxx                       | 24 ++++++++++++++++++++++++
 Source/cmake.h                         |  7 +++++++
 12 files changed, 70 insertions(+), 62 deletions(-)

diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 5f5017d..92ac07d 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -60,10 +60,10 @@ bool cmAuxSourceDirectoryCommand::InitialPass
         std::string ext = file.substr(dotpos+1);
         std::string base = file.substr(0, dotpos);
         // Process only source files
-        if(!base.empty()
-            && std::find( this->Makefile->GetSourceExtensions().begin(),
-                          this->Makefile->GetSourceExtensions().end(), ext )
-                 != this->Makefile->GetSourceExtensions().end() )
+        std::vector<std::string> srcExts =
+            this->Makefile->GetCMakeInstance()->GetSourceExtensions();
+        if(!base.empty() &&
+           std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
           {
           std::string fullname = templateDirectory;
           fullname += "/";
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 597c9d8..9348ef2 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -383,6 +383,9 @@ void cmExtraCodeBlocksGenerator
   all_files_map_t allFiles;
   std::vector<std::string> cFiles;
 
+  std::vector<std::string> srcExts =
+      this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
+
   for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
        lg!=lgs.end(); lg++)
     {
@@ -420,9 +423,7 @@ void cmExtraCodeBlocksGenerator
               {
               std::string srcext = (*si)->GetExtension();
               for(std::vector<std::string>::const_iterator
-                  ext = mf->GetSourceExtensions().begin();
-                  ext !=  mf->GetSourceExtensions().end();
-                  ++ext)
+                  ext = srcExts.begin(); ext != srcExts.end(); ++ext)
                 {
                 if (srcext == *ext)
                   {
@@ -449,6 +450,9 @@ void cmExtraCodeBlocksGenerator
       }
     }
 
+  std::vector<std::string> headerExts =
+      this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
+
   // The following loop tries to add header files matching to implementation
   // files to the project. It does that by iterating over all
   // C/C++ source files,
@@ -468,8 +472,8 @@ void cmExtraCodeBlocksGenerator
 
     // check if there's a matching header around
     for(std::vector<std::string>::const_iterator
-        ext = mf->GetHeaderExtensions().begin();
-        ext !=  mf->GetHeaderExtensions().end();
+        ext = headerExts.begin();
+        ext != headerExts.end();
         ++ext)
       {
       std::string hname=headerBasename;
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index f4a6537..67aa157 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -149,6 +149,11 @@ void cmExtraCodeLiteGenerator
   // which may have an acompanying header, one for all other files
   std::string projectType;
 
+  std::vector<std::string> srcExts =
+      this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
+  std::vector<std::string> headerExts =
+      this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
+
   std::map<std::string, cmSourceFile*> cFiles;
   std::set<std::string> otherFiles;
   for (std::vector<cmLocalGenerator*>::const_iterator lg=lgs.begin();
@@ -207,9 +212,7 @@ void cmExtraCodeLiteGenerator
               {
               std::string srcext = (*si)->GetExtension();
               for(std::vector<std::string>::const_iterator
-                  ext = mf->GetSourceExtensions().begin();
-                  ext !=  mf->GetSourceExtensions().end();
-                  ++ext)
+                  ext = srcExts.begin(); ext != srcExts.end(); ++ext)
                 {
                 if (srcext == *ext)
                   {
@@ -253,8 +256,8 @@ void cmExtraCodeLiteGenerator
 
     // check if there's a matching header around
     for(std::vector<std::string>::const_iterator
-        ext = mf->GetHeaderExtensions().begin();
-        ext !=  mf->GetHeaderExtensions().end();
+        ext = headerExts.begin();
+        ext != headerExts.end();
         ++ext)
       {
       std::string hname=headerBasename;
diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx
index 7c6c48c..018ab24 100644
--- a/Source/cmGlobalKdevelopGenerator.cxx
+++ b/Source/cmGlobalKdevelopGenerator.cxx
@@ -105,6 +105,9 @@ bool cmGlobalKdevelopGenerator
   std::set<std::string> files;
   std::string tmp;
 
+  std::vector<std::string> hdrExts =
+      this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
+
   for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
        it!=lgs.end(); it++)
     {
@@ -160,8 +163,7 @@ bool cmGlobalKdevelopGenerator
 
           // check if there's a matching header around
           for(std::vector<std::string>::const_iterator
-                ext = makefile->GetHeaderExtensions().begin();
-              ext !=  makefile->GetHeaderExtensions().end(); ++ext)
+                ext = hdrExts.begin(); ext != hdrExts.end(); ++ext)
             {
             std::string hname=headerBasename;
             hname += ".";
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 9a5c367..5737bee 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1420,7 +1420,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
 bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
 {
   const std::vector<std::string>& hdrExts =
-    this->CurrentMakefile->GetHeaderExtensions();
+    this->CMakeInstance->GetHeaderExtensions();
   return (std::find(hdrExts.begin(), hdrExts.end(), sf->GetExtension()) !=
           hdrExts.end());
 }
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 361aa99..3bf34e2 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -57,31 +57,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
 
   // Setup the default include complaint regular expression (match nothing).
   this->ComplainFileRegularExpression = "^$";
-  // Source and header file extensions that we can handle
-
-  // Set up a list of source and header extensions
-  // these are used to find files when the extension
-  // is not given
-  // The "c" extension MUST precede the "C" extension.
-  this->SourceFileExtensions.push_back( "c" );
-  this->SourceFileExtensions.push_back( "C" );
-
-  this->SourceFileExtensions.push_back( "c++" );
-  this->SourceFileExtensions.push_back( "cc" );
-  this->SourceFileExtensions.push_back( "cpp" );
-  this->SourceFileExtensions.push_back( "cxx" );
-  this->SourceFileExtensions.push_back( "m" );
-  this->SourceFileExtensions.push_back( "M" );
-  this->SourceFileExtensions.push_back( "mm" );
-
-  this->HeaderFileExtensions.push_back( "h" );
-  this->HeaderFileExtensions.push_back( "hh" );
-  this->HeaderFileExtensions.push_back( "h++" );
-  this->HeaderFileExtensions.push_back( "hm" );
-  this->HeaderFileExtensions.push_back( "hpp" );
-  this->HeaderFileExtensions.push_back( "hxx" );
-  this->HeaderFileExtensions.push_back( "in" );
-  this->HeaderFileExtensions.push_back( "txx" );
 
   this->DefineFlags = " ";
 
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 725448b..f3dbb74 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -425,17 +425,6 @@ public:
   cmSourceFile* GetOrCreateSource(const std::string& sourceName,
                                   bool generated = false);
 
-  //@{
-  /**
-   * Return a list of extensions associated with source and header
-   * files
-   */
-  const std::vector<std::string>& GetSourceExtensions() const
-    {return this->SourceFileExtensions;}
-  const std::vector<std::string>& GetHeaderExtensions() const
-    {return this->HeaderFileExtensions;}
-  //@}
-
   /**
    * Given a variable name, return its value (as a string).
    * If the variable is not found in this makefile instance, the
@@ -823,8 +812,6 @@ protected:
   std::vector<cmTestGenerator*> TestGenerators;
 
   std::string ComplainFileRegularExpression;
-  std::vector<std::string> SourceFileExtensions;
-  std::vector<std::string> HeaderFileExtensions;
   std::string DefineFlags;
 
   // Track the value of the computed DEFINITIONS property.
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index fc690f8..b16eccd 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -528,7 +528,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
   cmSystemTools::ExpandListArgument(this->Sources, sourceFiles);
 
   const std::vector<std::string>& headerExtensions =
-                                               makefile->GetHeaderExtensions();
+      makefile->GetCMakeInstance()->GetHeaderExtensions();
 
   std::map<std::string, std::vector<std::string> > includedUis;
   std::map<std::string, std::vector<std::string> > skippedUis;
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 37383be..a9ac549 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -167,8 +167,10 @@ bool cmSourceFile::FindFullPath(std::string* error)
     {
     tryDirs[0] = "";
     }
-  const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
-  const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
+  const std::vector<std::string>& srcExts =
+      mf->GetCMakeInstance()->GetSourceExtensions();
+  std::vector<std::string> hdrExts =
+      mf->GetCMakeInstance()->GetHeaderExtensions();
   for(const char* const* di = tryDirs; *di; ++di)
     {
     std::string tryPath = this->Location.GetDirectory();
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index b8d5c02..00d5d6a 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -121,8 +121,10 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name)
   // The global generator checks extensions of enabled languages.
   cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
   cmMakefile const* mf = this->Makefile;
-  const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
-  const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
+  const std::vector<std::string>& srcExts =
+      mf->GetCMakeInstance()->GetSourceExtensions();
+  const std::vector<std::string>& hdrExts =
+      mf->GetCMakeInstance()->GetHeaderExtensions();
   if(!gg->GetLanguageFromExtension(ext.c_str()).empty() ||
      std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
      std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
@@ -193,12 +195,14 @@ cmSourceFileLocation
   // disk.  One of these must match if loc refers to this source file.
   std::string const& ext = this->Name.substr(loc.Name.size()+1);
   cmMakefile const* mf = this->Makefile;
-  const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
+  const std::vector<std::string>& srcExts =
+      mf->GetCMakeInstance()->GetSourceExtensions();
   if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end())
     {
     return true;
     }
-  const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
+  std::vector<std::string> hdrExts =
+      mf->GetCMakeInstance()->GetHeaderExtensions();
   if(std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
     {
     return true;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 7268241..16417fc 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -165,6 +165,30 @@ cmake::cmake()
 
   // Make sure we can capture the build tool output.
   cmSystemTools::EnableVSConsoleOutput();
+
+  // Set up a list of source and header extensions
+  // these are used to find files when the extension
+  // is not given
+  // The "c" extension MUST precede the "C" extension.
+  this->SourceFileExtensions.push_back( "c" );
+  this->SourceFileExtensions.push_back( "C" );
+
+  this->SourceFileExtensions.push_back( "c++" );
+  this->SourceFileExtensions.push_back( "cc" );
+  this->SourceFileExtensions.push_back( "cpp" );
+  this->SourceFileExtensions.push_back( "cxx" );
+  this->SourceFileExtensions.push_back( "m" );
+  this->SourceFileExtensions.push_back( "M" );
+  this->SourceFileExtensions.push_back( "mm" );
+
+  this->HeaderFileExtensions.push_back( "h" );
+  this->HeaderFileExtensions.push_back( "hh" );
+  this->HeaderFileExtensions.push_back( "h++" );
+  this->HeaderFileExtensions.push_back( "hm" );
+  this->HeaderFileExtensions.push_back( "hpp" );
+  this->HeaderFileExtensions.push_back( "hxx" );
+  this->HeaderFileExtensions.push_back( "in" );
+  this->HeaderFileExtensions.push_back( "txx" );
 }
 
 cmake::~cmake()
diff --git a/Source/cmake.h b/Source/cmake.h
index 9d28cba..6b0e83f 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -182,6 +182,11 @@ class cmake
   ///! get the cmCachemManager used by this invocation of cmake
   cmCacheManager *GetCacheManager() { return this->CacheManager; }
 
+  const std::vector<std::string>& GetSourceExtensions() const
+    {return this->SourceFileExtensions;}
+  const std::vector<std::string>& GetHeaderExtensions() const
+    {return this->HeaderFileExtensions;}
+
   /**
    * Given a variable name, return its value (as a string).
    */
@@ -391,6 +396,8 @@ private:
   std::string CheckStampFile;
   std::string CheckStampList;
   std::string VSSolutionFile;
+  std::vector<std::string> SourceFileExtensions;
+  std::vector<std::string> HeaderFileExtensions;
   bool ClearBuildSystem;
   bool DebugTryCompile;
   cmFileTimeComparison* FileComparison;
-- 
cgit v0.12


From 7b127c62d4d4c94cf96e9d406859dbd24eed7dc9 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sat, 24 Oct 2015 15:42:04 +0200
Subject: VS7: Port remaining interface to cmGeneratorTarget

---
 Source/cmGlobalVisualStudio7Generator.cxx | 17 ++++++++---------
 Source/cmGlobalVisualStudio7Generator.h   |  4 ++--
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 340a0f7..f5848ab 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -401,7 +401,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
   for(OrderedTargetDependSet::const_iterator tt =
         projectTargets.begin(); tt != projectTargets.end(); ++tt)
     {
-    cmTarget const* target = (*tt)->Target;
+    cmGeneratorTarget const* target = *tt;
     if(target->GetType() == cmState::INTERFACE_LIBRARY)
       {
       continue;
@@ -996,7 +996,8 @@ cmGlobalVisualStudio7Generator
 std::set<std::string>
 cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
   std::vector<std::string> const& configs,
-  OrderedTargetDependSet const& projectTargets, cmTarget const* target)
+  OrderedTargetDependSet const& projectTargets,
+  cmGeneratorTarget const* target)
 {
   std::set<std::string> activeConfigs;
   // if it is a utilitiy target then only make it part of the
@@ -1011,13 +1012,13 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
       for(std::vector<std::string>::const_iterator i = configs.begin();
           i != configs.end(); ++i)
         {
-        const char* propertyValue = target->GetMakefile()
+        const char* propertyValue = target->Target->GetMakefile()
           ->GetDefinition("CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD");
         cmGeneratorExpression ge;
         cmsys::auto_ptr<cmCompiledGeneratorExpression>
           cge = ge.Parse(propertyValue);
-        cmGeneratorTarget* gt = this->GetGeneratorTarget(target);
-        if(cmSystemTools::IsOn(cge->Evaluate(gt->GetLocalGenerator(), *i)))
+        if(cmSystemTools::IsOn(cge->Evaluate(target->GetLocalGenerator(),
+                                             *i)))
           {
           activeConfigs.insert(*i);
           }
@@ -1029,13 +1030,12 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
     {
     return activeConfigs;
     }
-  cmGeneratorTarget* gt = this->GetGeneratorTarget(target);
   // inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
   for(std::vector<std::string>::const_iterator i = configs.begin();
       i != configs.end(); ++i)
     {
     const char* propertyValue =
-      gt->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
+      target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
     if(cmSystemTools::IsOff(propertyValue))
       {
       activeConfigs.insert(*i);
@@ -1047,9 +1047,8 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
 bool
 cmGlobalVisualStudio7Generator
 ::IsDependedOn(OrderedTargetDependSet const& projectTargets,
-               cmTarget const* targetIn)
+               cmGeneratorTarget const* gtIn)
 {
-  cmGeneratorTarget* gtIn = this->GetGeneratorTarget(targetIn);
   for (OrderedTargetDependSet::const_iterator l = projectTargets.begin();
        l != projectTargets.end(); ++l)
     {
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 6a0e5e9..fe6db2e 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -163,9 +163,9 @@ protected:
   std::set<std::string>
     IsPartOfDefaultBuild(std::vector<std::string> const& configs,
                          OrderedTargetDependSet const& projectTargets,
-                         cmTarget const* target);
+                         cmGeneratorTarget const* target);
   bool IsDependedOn(OrderedTargetDependSet const& projectTargets,
-                    cmTarget const* target);
+                    cmGeneratorTarget const* target);
   std::map<std::string, std::string> GUIDMap;
 
   virtual void WriteFolders(std::ostream& fout);
-- 
cgit v0.12


From 593f347b5385a510e641eca0448f7ddf64c1c12b Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 00:49:31 +0200
Subject: VS7: Port some implementation details to cmGeneratorTarget

---
 Source/cmLocalVisualStudio7Generator.cxx | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 95a299d..0eac203 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -783,10 +783,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   intermediateDir += "/";
   intermediateDir += configName;
 
-  if (target->Target->GetType() < cmState::UTILITY)
+  if (target->GetType() < cmState::UTILITY)
     {
     std::string const& outDir =
-      target->Target->GetType() == cmState::OBJECT_LIBRARY?
+      target->GetType() == cmState::OBJECT_LIBRARY?
       intermediateDir : target->GetDirectory(configName);
     fout << "\t\t\tOutputDirectory=\""
          << this->ConvertToXMLOutputPathSingle(outDir.c_str()) << "\"\n";
@@ -837,7 +837,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   if(this->FortranProject)
     {
     const char* target_mod_dir =
-      target->Target->GetProperty("Fortran_MODULE_DIRECTORY");
+      target->GetProperty("Fortran_MODULE_DIRECTORY");
     std::string modDir;
     if(target_mod_dir)
       {
@@ -877,7 +877,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   targetOptions.OutputFlagMap(fout, "\t\t\t\t");
   targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
   fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
-  if(target->Target->GetType() <= cmState::OBJECT_LIBRARY)
+  if(target->GetType() <= cmState::OBJECT_LIBRARY)
     {
     // Specify the compiler program database file if configured.
     std::string pdb = target->GetCompilePDBPath(configName);
-- 
cgit v0.12


From 3e3c754b8cc3af463dcea95000daf3a18b359b7a Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 01:19:14 +0200
Subject: cmLocalGenerator: Port internals to cmGeneratorTarget

---
 Source/cmLocalGenerator.cxx | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1926772..b5f5ce9 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2033,7 +2033,7 @@ AddCompilerRequirementFlag(std::string &flags,
 }
 
 static void AddVisibilityCompileOption(std::string &flags,
-                                       cmTarget const* target,
+                                       cmGeneratorTarget const* target,
                                        cmLocalGenerator *lg,
                                        const std::string& lang,
                                        std::string* warnCMP0063)
@@ -2073,7 +2073,7 @@ static void AddVisibilityCompileOption(std::string &flags,
 }
 
 static void AddInlineVisibilityCompileOption(std::string &flags,
-                                       cmTarget const* target,
+                                       cmGeneratorTarget const* target,
                                        cmLocalGenerator *lg,
                                        std::string* warnCMP0063)
 {
@@ -2126,12 +2126,11 @@ void cmLocalGenerator
       }
     }
 
-  AddVisibilityCompileOption(flags, target->Target, this, lang, pWarnCMP0063);
+  AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063);
 
   if(lang == "CXX")
     {
-    AddInlineVisibilityCompileOption(flags, target->Target,
-                                     this, pWarnCMP0063);
+    AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063);
     }
 
   if (!warnCMP0063.empty() &&
-- 
cgit v0.12


From 520ca0ff6c123250c633a3618459d0161cbc4683 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 10:35:36 +0100
Subject: cmGeneratorTarget: Add API for property keys

---
 Source/cmExportTryCompileFileGenerator.cxx | 16 +++++++++-------
 Source/cmGeneratorTarget.cxx               | 29 +++++++++++++++++++++++------
 Source/cmGeneratorTarget.h                 |  1 +
 Source/cmGlobalXCodeGenerator.cxx          | 10 +++++-----
 Source/cmLocalVisualStudio7Generator.cxx   | 11 ++++++-----
 5 files changed, 44 insertions(+), 23 deletions(-)

diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 1daa67e..83127e7 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -105,16 +105,18 @@ cmExportTryCompileFileGenerator::PopulateProperties(
                                  ImportPropertyMap& properties,
                                  std::set<cmGeneratorTarget const*> &emitted)
 {
-  cmPropertyMap props = target->Target->GetProperties();
-  for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
+  std::vector<std::string> props = target->GetPropertyKeys();
+  for(std::vector<std::string>::const_iterator i = props.begin();
+      i != props.end(); ++i)
     {
-    properties[i->first] = i->second.GetValue();
 
-    if(i->first.find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
-        || i->first.find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0
-        || i->first.find("INTERFACE_LINK_LIBRARIES") == 0)
+    properties[*i] = target->GetProperty(*i);
+
+    if(i->find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0
+        || i->find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0
+        || i->find("INTERFACE_LINK_LIBRARIES") == 0)
       {
-      std::string evalResult = this->FindTargets(i->first,
+      std::string evalResult = this->FindTargets(*i,
                                                  target, emitted);
 
       std::vector<std::string> depends;
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 651c89c..3df43ff 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -4251,9 +4251,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
                                           PropertyType *)
 {
   PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
-  const bool explicitlySet = tgt->Target->GetProperties()
-                                  .find(p)
-                                  != tgt->Target->GetProperties().end();
+  std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
+  const bool explicitlySet =
+      std::find(headPropKeys.begin(), headPropKeys.end(),
+                p) != headPropKeys.end();
+
   const bool impliedByUse =
           tgt->IsNullImpliedByLinkLibraries(p);
   assert((impliedByUse ^ explicitlySet)
@@ -4298,9 +4300,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
 
     cmGeneratorTarget const* theTarget = *li;
 
-    const bool ifaceIsSet = theTarget->Target->GetProperties()
-                            .find(interfaceProperty)
-                            != theTarget->Target->GetProperties().end();
+    std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
+
+    const bool ifaceIsSet =
+        std::find(propKeys.begin(), propKeys.end(),
+                  interfaceProperty) != propKeys.end();
     PropertyType ifacePropContent =
                     getTypedProperty<PropertyType>(theTarget,
                               interfaceProperty);
@@ -4577,6 +4581,19 @@ void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
   vName += this->Makefile->IsOn("APPLE") ? suffix : std::string();
 }
 
+std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
+{
+  cmPropertyMap propsObject = this->Target->GetProperties();
+  std::vector<std::string> props;
+  props.reserve(propsObject.size());
+  for (cmPropertyMap::const_iterator it = propsObject.begin();
+       it != propsObject.end(); ++it)
+    {
+    props.push_back(it->first);
+    }
+  return props;
+}
+
 //----------------------------------------------------------------------------
 void
 cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 58c3421..3c6f267 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -57,6 +57,7 @@ public:
   std::string GetName() const;
   std::string GetExportName() const;
 
+  std::vector<std::string> GetPropertyKeys() const;
   const char *GetProperty(const std::string& prop) const;
   bool GetPropertyAsBool(const std::string& prop) const;
   void GetSourceFiles(std::vector<cmSourceFile*>& files,
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 5737bee..42f9758 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2486,13 +2486,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
   // put this last so it can override existing settings
   // Convert "XCODE_ATTRIBUTE_*" properties directly.
   {
-  cmPropertyMap const& props = gtgt->Target->GetProperties();
-  for(cmPropertyMap::const_iterator i = props.begin();
+  std::vector<std::string> const& props = gtgt->GetPropertyKeys();
+  for(std::vector<std::string>::const_iterator i = props.begin();
       i != props.end(); ++i)
     {
-    if(i->first.find("XCODE_ATTRIBUTE_") == 0)
+    if(i->find("XCODE_ATTRIBUTE_") == 0)
       {
-      std::string attribute = i->first.substr(16);
+      std::string attribute = i->substr(16);
       // Handle [variant=<config>] condition explicitly here.
       std::string::size_type beginVariant =
         attribute.find("[variant=");
@@ -2523,7 +2523,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       if (!attribute.empty())
         {
         cmGeneratorExpression ge;
-        std::string processed = ge.Parse(i->second.GetValue())
+        std::string processed = ge.Parse(gtgt->GetProperty(*i))
           ->Evaluate(this->CurrentLocalGenerator, configName);
         buildSettings->AddAttribute(attribute.c_str(),
                                     this->CreateString(processed));
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 0eac203..ae6a24e 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -2219,17 +2219,18 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(
 {
   fout << "\t<Globals>\n";
 
-  cmPropertyMap const& props = target->Target->GetProperties();
-  for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i)
+  std::vector<std::string> const& props = target->GetPropertyKeys();
+  for(std::vector<std::string>::const_iterator i = props.begin();
+      i != props.end(); ++i)
     {
-    if(i->first.find("VS_GLOBAL_") == 0)
+    if(i->find("VS_GLOBAL_") == 0)
       {
-      std::string name = i->first.substr(10);
+      std::string name = i->substr(10);
       if(name != "")
         {
         fout << "\t\t<Global\n"
              << "\t\t\tName=\"" << name << "\"\n"
-             << "\t\t\tValue=\"" << i->second.GetValue() << "\"\n"
+             << "\t\t\tValue=\"" << target->GetProperty(*i) << "\"\n"
              << "\t\t/>\n";
         }
       }
-- 
cgit v0.12


From 7f6beddae372a7ae47789f5460bcdfdac39c64e6 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 11:37:34 +0100
Subject: cmGeneratorTarget: Port cmOptionalLinkImplementation

---
 Source/cmGeneratorTarget.cxx | 4 ++--
 Source/cmGeneratorTarget.h   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 3df43ff..e19d5e5 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -5560,7 +5560,7 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const
     }
 
   std::string CONFIG = cmSystemTools::UpperCase(config);
-  cmOptionalLinkImplementation& impl = this->LinkImplMap[CONFIG][this->Target];
+  cmOptionalLinkImplementation& impl = this->LinkImplMap[CONFIG][this];
   if(!impl.LibrariesDone)
     {
     impl.LibrariesDone = true;
@@ -5840,7 +5840,7 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
     return &hm.begin()->second;
     }
 
-  cmOptionalLinkImplementation& impl = hm[head->Target];
+  cmOptionalLinkImplementation& impl = hm[head];
   if(!impl.LibrariesDone)
     {
     impl.LibrariesDone = true;
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 3c6f267..c2607a7 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -647,7 +647,7 @@ private:
                       const std::string& config) const;
 
   struct HeadToLinkImplementationMap:
-    public std::map<cmTarget const*, cmOptionalLinkImplementation> {};
+    public std::map<cmGeneratorTarget const*, cmOptionalLinkImplementation> {};
   typedef std::map<std::string,
                    HeadToLinkImplementationMap> LinkImplMapType;
   mutable LinkImplMapType LinkImplMap;
-- 
cgit v0.12


From 383bfd95432990365ac5c7fc3ab190bfb05cbec1 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 11:49:03 +0100
Subject: cmTargetCollectLinkLanguages: Remove cmMakefile dependency

---
 Source/cmGeneratorTarget.cxx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index e19d5e5..9376e98 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1793,7 +1793,7 @@ public:
                                UNORDERED_SET<std::string>& languages,
                                cmGeneratorTarget const* head):
     Config(config), Languages(languages), HeadTarget(head),
-    Makefile(target->Target->GetMakefile()), Target(target)
+    Target(target)
   { this->Visited.insert(target); }
 
   void Visit(cmLinkItem const& item)
@@ -1805,7 +1805,8 @@ public:
         bool noMessage = false;
         cmake::MessageType messageType = cmake::FATAL_ERROR;
         std::stringstream e;
-        switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028))
+        switch(this->Target->GetLocalGenerator()
+               ->GetPolicyStatus(cmPolicies::CMP0028))
           {
           case cmPolicies::WARN:
             {
@@ -1859,7 +1860,6 @@ private:
   std::string Config;
   UNORDERED_SET<std::string>& Languages;
   cmGeneratorTarget const* HeadTarget;
-  cmMakefile* Makefile;
   const cmGeneratorTarget* Target;
   std::set<cmGeneratorTarget const*> Visited;
 };
-- 
cgit v0.12


From 0c97d32f7a592a768d614c19b3fd48eab245a2c4 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 12:22:51 +0100
Subject: cmGlobalGenerator: Remove direct storage of targets

Find the target by looping when needed.
---
 Source/cmGlobalGenerator.cxx              | 80 +++++++++++++++++++------------
 Source/cmGlobalGenerator.h                |  7 ++-
 Source/cmGlobalVisualStudio8Generator.cxx | 16 ++++---
 Source/cmGlobalXCodeGenerator.cxx         | 15 ++++--
 Source/cmMakefile.cxx                     |  7 +--
 Source/cmTarget.cxx                       |  4 +-
 Source/cmTarget.h                         |  5 +-
 7 files changed, 80 insertions(+), 54 deletions(-)

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index d26cc34..e33e942 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1637,8 +1637,6 @@ void cmGlobalGenerator::ClearGeneratorMembers()
 
   this->ExportSets.clear();
   this->TargetDependencies.clear();
-  this->TotalTargets.clear();
-  this->ImportedTargets.clear();
   this->ProjectMap.clear();
   this->RuleHashes.clear();
   this->DirectoryContentMap.clear();
@@ -2180,6 +2178,41 @@ bool cmGlobalGenerator::IsAlias(const std::string& name) const
   return this->AliasTargets.find(name) != this->AliasTargets.end();
 }
 
+cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
+{
+  for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
+    {
+    cmTargets& tgts = this->Makefiles[i]->GetTargets();
+    for (cmTargets::iterator it = tgts.begin(); it != tgts.end(); ++it)
+      {
+      if (it->second.GetName() == name)
+        {
+        return &it->second;
+        }
+      }
+    }
+  return 0;
+}
+
+cmTarget*
+cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
+{
+  for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
+    {
+    std::vector<cmTarget*> tgts =
+        this->Makefiles[i]->GetOwnedImportedTargets();
+    for (std::vector<cmTarget*>::iterator it = tgts.begin();
+         it != tgts.end(); ++it)
+      {
+      if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
+        {
+        return *it;
+        }
+      }
+    }
+  return 0;
+}
+
 //----------------------------------------------------------------------------
 cmTarget*
 cmGlobalGenerator::FindTarget(const std::string& name,
@@ -2193,17 +2226,11 @@ cmGlobalGenerator::FindTarget(const std::string& name,
       return ai->second;
       }
     }
-  TargetMap::const_iterator i = this->TotalTargets.find ( name );
-  if ( i != this->TotalTargets.end() )
-    {
-    return i->second;
-    }
-  i = this->ImportedTargets.find(name);
-  if ( i != this->ImportedTargets.end() )
+  if (cmTarget* tgt = this->FindTargetImpl(name))
     {
-    return i->second;
+    return tgt;
     }
-  return 0;
+  return this->FindImportedTargetImpl(name);
 }
 
 //----------------------------------------------------------------------------
@@ -2622,18 +2649,6 @@ cmGlobalGenerator::GetTargetDirectDepends(cmGeneratorTarget const* target)
   return this->TargetDependencies[target];
 }
 
-void cmGlobalGenerator::AddTarget(cmTarget* t)
-{
-  if(t->IsImported())
-    {
-    this->ImportedTargets[t->GetName()] = t;
-    }
-  else
-    {
-    this->TotalTargets[t->GetName()] = t;
-    }
-}
-
 bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
 {
   // The following is a list of targets reserved
@@ -2939,17 +2954,20 @@ void cmGlobalGenerator::WriteSummary()
   fname += "/TargetDirectories.txt";
   cmGeneratedFileStream fout(fname.c_str());
 
-  // Generate summary information files for each target.
-  for(TargetMap::const_iterator ti =
-        this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
     {
-    if ((ti->second)->GetType() == cmState::INTERFACE_LIBRARY)
+    std::vector<cmGeneratorTarget*> tgts =
+        this->LocalGenerators[i]->GetGeneratorTargets();
+    for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
+         it != tgts.end(); ++it)
       {
-      continue;
+      if ((*it)->GetType() == cmState::INTERFACE_LIBRARY)
+        {
+        continue;
+        }
+      this->WriteSummary(*it);
+      fout << (*it)->GetSupportDirectory() << "\n";
       }
-    cmGeneratorTarget* gt = this->GetGeneratorTarget(ti->second);
-    this->WriteSummary(gt);
-    fout << gt->GetSupportDirectory() << "\n";
     }
 }
 
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 18f5329..5d4ce08 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -280,8 +280,6 @@ public:
   std::set<std::string> const& GetDirectoryContent(std::string const& dir,
                                                    bool needDisk = true);
 
-  void AddTarget(cmTarget* t);
-
   static bool IsReservedTarget(std::string const& name);
 
   virtual const char* GetAllTargetName()         const { return "ALL_BUILD"; }
@@ -439,9 +437,10 @@ protected:
 #else
   typedef std::map<std::string,cmTarget *> TargetMap;
 #endif
-  TargetMap TotalTargets;
   TargetMap AliasTargets;
-  TargetMap ImportedTargets;
+
+  cmTarget* FindTargetImpl(std::string const& name) const;
+  cmTarget* FindImportedTargetImpl(std::string const& name) const;
 
   const char* GetPredefinedTargetsFolder();
   virtual bool UseFolderProperty();
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index b771f11..f08ab5a 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -354,14 +354,18 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets()
   cmGlobalVisualStudio7Generator::AddExtraIDETargets();
   if(this->AddCheckTarget())
     {
-    // All targets depend on the build-system check target.
-    for(TargetMap::const_iterator
-          ti = this->TotalTargets.begin();
-        ti != this->TotalTargets.end(); ++ti)
+    for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
       {
-      if(ti->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
+      std::vector<cmGeneratorTarget*> tgts =
+          this->LocalGenerators[i]->GetGeneratorTargets();
+      // All targets depend on the build-system check target.
+      for(std::vector<cmGeneratorTarget*>::iterator ti = tgts.begin();
+          ti != tgts.end(); ++ti)
         {
-        ti->second->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
+        if((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
+          {
+          (*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
+          }
         }
       }
     }
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 42f9758..6d4fc1f 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1362,12 +1362,17 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
 //----------------------------------------------------------------------------
 void cmGlobalXCodeGenerator::ForceLinkerLanguages()
 {
-  // This makes sure all targets link using the proper language.
-  for(TargetMap::const_iterator
-        ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
     {
-    cmGeneratorTarget* gt = this->GetGeneratorTarget(ti->second);
-    this->ForceLinkerLanguage(gt);
+    std::vector<cmGeneratorTarget*> tgts =
+        this->LocalGenerators[i]->GetGeneratorTargets();
+    // All targets depend on the build-system check target.
+    for(std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin();
+        ti != tgts.end(); ++ti)
+      {
+      // This makes sure all targets link using the proper language.
+      this->ForceLinkerLanguage(*ti);
+      }
     }
 }
 
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 3bf34e2..d9d773d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2096,7 +2096,6 @@ cmMakefile::AddNewTarget(cmState::TargetType type, const std::string& name)
   cmTarget& target = it->second;
   target.SetType(type, name);
   target.SetMakefile(this);
-  this->GetGlobalGenerator()->AddTarget(&it->second);
   return &it->second;
 }
 
@@ -4183,15 +4182,11 @@ cmMakefile::AddImportedTarget(const std::string& name,
   // Create the target.
   cmsys::auto_ptr<cmTarget> target(new cmTarget);
   target->SetType(type, name);
-  target->MarkAsImported();
+  target->MarkAsImported(global);
   target->SetMakefile(this);
 
   // Add to the set of available imported targets.
   this->ImportedTargets[name] = target.get();
-  if(global)
-    {
-    this->GetGlobalGenerator()->AddTarget(target.get());
-    }
 
   // Transfer ownership to this cmMakefile object.
   this->ImportedTargetsOwned.push_back(target.get());
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index c887fc8..f0f404c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -63,6 +63,7 @@ cmTarget::cmTarget()
   this->IsAndroid = false;
   this->IsApple = false;
   this->IsImportedTarget = false;
+  this->ImportedGloballyVisible = false;
   this->BuildInterfaceIncludesAppended = false;
 }
 
@@ -1505,9 +1506,10 @@ void cmTarget::CheckProperty(const std::string& prop,
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::MarkAsImported()
+void cmTarget::MarkAsImported(bool global)
 {
   this->IsImportedTarget = true;
+  this->ImportedGloballyVisible = global;
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 541e850..62e10f4 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -75,7 +75,7 @@ public:
    */
   void SetType(cmState::TargetType f, const std::string& name);
 
-  void MarkAsImported();
+  void MarkAsImported(bool global = false);
 
   ///! Set/Get the name of the target
   const std::string& GetName() const {return this->Name;}
@@ -186,6 +186,8 @@ public:
   void CheckProperty(const std::string& prop, cmMakefile* context) const;
 
   bool IsImported() const {return this->IsImportedTarget;}
+  bool IsImportedGloballyVisible() const
+  { return this->ImportedGloballyVisible; }
 
   // Get the properties
   cmPropertyMap &GetProperties() const { return this->Properties; }
@@ -349,6 +351,7 @@ private:
   bool IsAndroid;
   bool IsApple;
   bool IsImportedTarget;
+  bool ImportedGloballyVisible;
   bool BuildInterfaceIncludesAppended;
 #if defined(_WIN32) && !defined(__CYGWIN__)
   bool LinkLibrariesForVS6Analyzed;
-- 
cgit v0.12


From d566f39a640297114bd3ad933bb3279440b2f38f Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 12:33:38 +0100
Subject: cmGlobalGenerator: Remove unneeded GetGeneratorTarget

---
 Source/cmGlobalGenerator.cxx | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index e33e942..215d63f 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2244,8 +2244,7 @@ cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const
 
   if(cmTarget* tgt = this->FindTarget(libname))
     {
-    cmGeneratorTarget* gt = this->GetGeneratorTarget(tgt);
-    if(gt->IsFrameworkOnApple())
+    if(tgt->IsFrameworkOnApple())
        {
        return true;
        }
-- 
cgit v0.12


From a67231ac114235f0af4673235c4c07fa896c8ab6 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 12:43:00 +0100
Subject: cmTarget: Implement ALIAS in terms of name mapping

Remove mapping to cmTarget.
---
 Source/cmAddExecutableCommand.cxx |  2 +-
 Source/cmAddLibraryCommand.cxx    |  2 +-
 Source/cmGlobalGenerator.cxx      | 10 ++++++----
 Source/cmGlobalGenerator.h        | 14 ++------------
 Source/cmMakefile.cxx             | 13 ++++++++-----
 Source/cmMakefile.h               |  4 ++--
 6 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 47f6592..a84bb9d 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -192,7 +192,7 @@ bool cmAddExecutableCommand
       this->SetError(e.str());
       return false;
       }
-    this->Makefile->AddAlias(exename, aliasedTarget);
+    this->Makefile->AddAlias(exename, aliasedName);
     return true;
     }
 
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index e0adee3..5296cbb 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -314,7 +314,7 @@ bool cmAddLibraryCommand
       this->SetError(e.str());
       return false;
       }
-    this->Makefile->AddAlias(libName, aliasedTarget);
+    this->Makefile->AddAlias(libName, aliasedName);
     return true;
     }
 
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 215d63f..47d254e 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2167,9 +2167,10 @@ cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::AddAlias(const std::string& name, cmTarget *tgt)
+void cmGlobalGenerator::AddAlias(const std::string& name,
+                                 std::string const& tgtName)
 {
-  this->AliasTargets[name] = tgt;
+  this->AliasTargets[name] = tgtName;
 }
 
 //----------------------------------------------------------------------------
@@ -2220,10 +2221,11 @@ cmGlobalGenerator::FindTarget(const std::string& name,
 {
   if (!excludeAliases)
     {
-    TargetMap::const_iterator ai = this->AliasTargets.find(name);
+    std::map<std::string, std::string>::const_iterator ai =
+        this->AliasTargets.find(name);
     if (ai != this->AliasTargets.end())
       {
-      return ai->second;
+      return this->FindTargetImpl(ai->second);
       }
     }
   if (cmTarget* tgt = this->FindTargetImpl(name))
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 5d4ce08..419cada 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -254,7 +254,7 @@ public:
   cmTarget* FindTarget(const std::string& name,
                        bool excludeAliases = false) const;
 
-  void AddAlias(const std::string& name, cmTarget *tgt);
+  void AddAlias(const std::string& name, const std::string& tgtName);
   bool IsAlias(const std::string& name) const;
 
   /** Determine if a name resolves to a framework on disk or a built target
@@ -427,17 +427,7 @@ protected:
   std::map<std::string, cmExportBuildFileGenerator*> BuildExportSets;
   std::map<std::string, cmExportBuildFileGenerator*> BuildExportExportSets;
 
-  // All targets in the entire project.
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#ifdef CMake_HAVE_CXX11_UNORDERED_MAP
-  typedef std::unordered_map<std::string, cmTarget*> TargetMap;
-#else
-  typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
-#endif
-#else
-  typedef std::map<std::string,cmTarget *> TargetMap;
-#endif
-  TargetMap AliasTargets;
+  std::map<std::string, std::string> AliasTargets;
 
   cmTarget* FindTargetImpl(std::string const& name) const;
   cmTarget* FindImportedTargetImpl(std::string const& name) const;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index d9d773d..8f72f67 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2036,10 +2036,11 @@ void cmMakefile::AddGlobalLinkInformation(const std::string& name,
 }
 
 
-void cmMakefile::AddAlias(const std::string& lname, cmTarget *tgt)
+void cmMakefile::AddAlias(const std::string& lname,
+                          std::string const& tgtName)
 {
-  this->AliasTargets[lname] = tgt;
-  this->GetGlobalGenerator()->AddAlias(lname, tgt);
+  this->AliasTargets[lname] = tgtName;
+  this->GetGlobalGenerator()->AddAlias(lname, tgtName);
 }
 
 cmTarget* cmMakefile::AddLibrary(const std::string& lname,
@@ -4024,10 +4025,12 @@ cmTarget* cmMakefile::FindTarget(const std::string& name,
 {
   if (!excludeAliases)
     {
-    TargetMap::const_iterator i = this->AliasTargets.find(name);
+    std::map<std::string, std::string>::const_iterator i =
+        this->AliasTargets.find(name);
     if (i != this->AliasTargets.end())
       {
-      return i->second;
+      cmTargets::iterator ai = this->Targets.find(i->second);
+      return &ai->second;
       }
     }
   cmTargets::iterator i = this->Targets.find( name );
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index f3dbb74..35dd3c6 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -283,7 +283,7 @@ public:
   cmTarget* AddLibrary(const std::string& libname, cmState::TargetType type,
                   const std::vector<std::string> &srcs,
                   bool excludeFromAll = false);
-  void AddAlias(const std::string& libname, cmTarget *tgt);
+  void AddAlias(const std::string& libname, const std::string& tgt);
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   /**
@@ -790,7 +790,7 @@ protected:
 #else
   typedef std::map<std::string, cmTarget*> TargetMap;
 #endif
-  TargetMap AliasTargets;
+  std::map<std::string, std::string> AliasTargets;
   std::vector<cmSourceFile*> SourceFiles;
 
   // Tests
-- 
cgit v0.12


From def6da616b81958c9f1058a4e520ac3cbc534757 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 12:52:46 +0100
Subject: cmLocalGenerator: Port FindGeneratorTarget away from
 GetGeneratorTarget

---
 Source/cmLocalGenerator.cxx | 40 ++++++++++++++++++++++++++++++++++++++--
 Source/cmLocalGenerator.h   |  1 +
 Source/cmMakefile.h         |  5 +++++
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index b5f5ce9..9d5335e 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -51,6 +51,8 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
 
   this->Makefile = makefile;
 
+  this->AliasTargets = makefile->GetAliasTargets();
+
   this->EmitUniversalBinaryFlags = true;
   this->BackwardsCompatibility = 0;
   this->BackwardsCompatibilityFinal = false;
@@ -453,11 +455,45 @@ void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt)
   this->GeneratorTargets.push_back(gt);
 }
 
+struct NamedGeneratorTargetFinder
+{
+  NamedGeneratorTargetFinder(std::string const& name)
+    : Name(name)
+  {
+
+  }
+
+  bool operator()(cmGeneratorTarget* tgt)
+  {
+    return tgt->GetName() == this->Name;
+  }
+private:
+  std::string Name;
+};
+
 cmGeneratorTarget* cmLocalGenerator::FindGeneratorTarget(
     const std::string& name) const
 {
-  return this->GetGlobalGenerator()->GetGeneratorTarget(
-        this->Makefile->FindTarget(name));
+  std::map<std::string, std::string>::const_iterator i =
+      this->AliasTargets.find(name);
+  if (i != this->AliasTargets.end())
+    {
+    std::vector<cmGeneratorTarget*>::const_iterator ai =
+        std::find_if(this->GeneratorTargets.begin(),
+                     this->GeneratorTargets.end(),
+                     NamedGeneratorTargetFinder(i->second));
+    return *ai;
+    }
+  std::vector<cmGeneratorTarget*>::const_iterator ti =
+      std::find_if(this->GeneratorTargets.begin(),
+                   this->GeneratorTargets.end(),
+                   NamedGeneratorTargetFinder(name));
+  if ( ti != this->GeneratorTargets.end() )
+    {
+    return *ti;
+    }
+
+  return 0;
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 46eb1b3..91a476f 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -373,6 +373,7 @@ protected:
 
   std::set<cmGeneratorTarget const*> WarnCMP0063;
   std::vector<cmGeneratorTarget*> GeneratorTargets;
+  std::map<std::string, std::string> AliasTargets;
 
   bool EmitUniversalBinaryFlags;
 
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 35dd3c6..01c4524 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -400,6 +400,11 @@ public:
                             bool excludeAliases = false) const;
   bool IsAlias(const std::string& name) const;
 
+  std::map<std::string, std::string> GetAliasTargets() const
+  {
+    return this->AliasTargets;
+  }
+
   /**
    * Mark include directories as system directories.
    */
-- 
cgit v0.12


From 9b244cc0ecff0cde22b71b7097a3d84c018c6044 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 12:56:31 +0100
Subject: cmLocalGenerator: Store imported targets in a separate container.

---
 Source/cmGlobalGenerator.cxx | 1 +
 Source/cmLocalGenerator.cxx  | 5 +++++
 Source/cmLocalGenerator.h    | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 47d254e..6b5cb97 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1606,6 +1606,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
     {
     cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
     this->GeneratorTargets[*j] = gt;
+    lg->AddImportedGeneratorTarget(gt);
     }
 }
 
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 9d5335e..1bc7f81 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -455,6 +455,11 @@ void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt)
   this->GeneratorTargets.push_back(gt);
 }
 
+void cmLocalGenerator::AddImportedGeneratorTarget(cmGeneratorTarget* gt)
+{
+  this->ImportedGeneratorTargets.push_back(gt);
+}
+
 struct NamedGeneratorTargetFinder
 {
   NamedGeneratorTargetFinder(std::string const& name)
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 91a476f..7841d05 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -121,6 +121,7 @@ public:
     }
 
   void AddGeneratorTarget(cmGeneratorTarget* gt);
+  void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
 
   cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
   cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
@@ -373,6 +374,7 @@ protected:
 
   std::set<cmGeneratorTarget const*> WarnCMP0063;
   std::vector<cmGeneratorTarget*> GeneratorTargets;
+  std::vector<cmGeneratorTarget*> ImportedGeneratorTargets;
   std::map<std::string, std::string> AliasTargets;
 
   bool EmitUniversalBinaryFlags;
-- 
cgit v0.12


From 79c11d23405d3894a254a8c03df5ead32464b109 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 12:59:39 +0100
Subject: Xcode: Port away from GetGeneratorTarget

---
 Source/cmLocalXCodeGenerator.cxx | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index 3b430d2..aec2603 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -51,13 +51,11 @@ void cmLocalXCodeGenerator::Generate()
 {
   cmLocalGenerator::Generate();
 
-  cmTargets& targets = this->Makefile->GetTargets();
-  for(cmTargets::iterator iter = targets.begin();
+  std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
+  for(std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
       iter != targets.end(); ++iter)
     {
-    cmTarget* t = &iter->second;
-    cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(t);
-    gt->HasMacOSXRpathInstallNameDir("");
+    (*iter)->HasMacOSXRpathInstallNameDir("");
     }
 }
 
@@ -66,13 +64,11 @@ void cmLocalXCodeGenerator::GenerateInstallRules()
 {
   cmLocalGenerator::GenerateInstallRules();
 
-  cmTargets& targets = this->Makefile->GetTargets();
-  for(cmTargets::iterator iter = targets.begin();
+  std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
+  for(std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
       iter != targets.end(); ++iter)
     {
-    cmTarget* t = &iter->second;
-    cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(t);
-    gt->HasMacOSXRpathInstallNameDir("");
+    (*iter)->HasMacOSXRpathInstallNameDir("");
     }
 }
 
-- 
cgit v0.12


From 278ba2db477fdc8cccd2313eb56e0179234747a0 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 13:06:37 +0100
Subject: cmGeneratorTarget: Add API for globally visible IMPORTED

---
 Source/cmGeneratorTarget.cxx | 5 +++++
 Source/cmGeneratorTarget.h   | 1 +
 2 files changed, 6 insertions(+)

diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 9376e98..1f74eda 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -856,6 +856,11 @@ bool cmGeneratorTarget::IsImported() const
   return this->Target->IsImported();
 }
 
+bool cmGeneratorTarget::IsImportedGloballyVisible() const
+{
+  return this->Target->IsImportedGloballyVisible();
+}
+
 //----------------------------------------------------------------------------
 const char* cmGeneratorTarget::GetLocationForBuild() const
 {
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index c2607a7..da59a98 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -31,6 +31,7 @@ public:
   cmLocalGenerator* GetLocalGenerator() const;
 
   bool IsImported() const;
+  bool IsImportedGloballyVisible() const;
   const char *GetLocation(const std::string& config) const;
 
   std::vector<cmCustomCommand> const &GetPreBuildCommands() const;
-- 
cgit v0.12


From 8caf1f361b2207522d19bf4a28cecaa3a2391918 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 13:06:59 +0100
Subject: cmGlobalGenerator: Add FindGeneratorTarget API

---
 Source/cmGlobalGenerator.cxx | 48 ++++++++++++++++++++++++++++++++++++++++++++
 Source/cmGlobalGenerator.h   |  6 ++++++
 2 files changed, 54 insertions(+)

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6b5cb97..5928fb5 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2196,6 +2196,25 @@ cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
   return 0;
 }
 
+cmGeneratorTarget*
+cmGlobalGenerator::FindGeneratorTargetImpl(std::string const& name) const
+{
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
+    {
+    std::vector<cmGeneratorTarget*> tgts =
+        this->LocalGenerators[i]->GetGeneratorTargets();
+    for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
+         it != tgts.end(); ++it)
+      {
+      if ((*it)->GetName() == name)
+        {
+        return *it;
+        }
+      }
+    }
+  return 0;
+}
+
 cmTarget*
 cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
 {
@@ -2215,6 +2234,25 @@ cmGlobalGenerator::FindImportedTargetImpl(std::string const& name) const
   return 0;
 }
 
+cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl(
+    std::string const& name) const
+{
+  for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
+    {
+    std::vector<cmGeneratorTarget*> tgts =
+        this->LocalGenerators[i]->GetGeneratorTargets();
+    for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
+         it != tgts.end(); ++it)
+      {
+      if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
+        {
+        return *it;
+        }
+      }
+    }
+  return 0;
+}
+
 //----------------------------------------------------------------------------
 cmTarget*
 cmGlobalGenerator::FindTarget(const std::string& name,
@@ -2236,6 +2274,16 @@ cmGlobalGenerator::FindTarget(const std::string& name,
   return this->FindImportedTargetImpl(name);
 }
 
+cmGeneratorTarget*
+cmGlobalGenerator::FindGeneratorTarget(const std::string& name) const
+{
+  if (cmGeneratorTarget* tgt = this->FindGeneratorTargetImpl(name))
+    {
+    return tgt;
+    }
+  return this->FindImportedGeneratorTargetImpl(name);
+}
+
 //----------------------------------------------------------------------------
 bool
 cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 419cada..c52b209 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -254,6 +254,8 @@ public:
   cmTarget* FindTarget(const std::string& name,
                        bool excludeAliases = false) const;
 
+  cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
+
   void AddAlias(const std::string& name, const std::string& tgtName);
   bool IsAlias(const std::string& name) const;
 
@@ -432,6 +434,10 @@ protected:
   cmTarget* FindTargetImpl(std::string const& name) const;
   cmTarget* FindImportedTargetImpl(std::string const& name) const;
 
+  cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
+  cmGeneratorTarget*
+  FindImportedGeneratorTargetImpl(std::string const& name) const;
+
   const char* GetPredefinedTargetsFolder();
   virtual bool UseFolderProperty();
 
-- 
cgit v0.12


From 0fb187cc589b83ded107d9a9a1971830efb6c751 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 13:19:54 +0100
Subject: CMP0026: Port away from GetGeneratorTarget

---
 Source/cmTarget.cxx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index f0f404c..1eebd12 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1602,7 +1602,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
         // CMake time.
         cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
         gg->CreateGenerationObjects();
-        cmGeneratorTarget* gt = gg->GetGeneratorTarget(this);
+        cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
         this->Properties.SetProperty(propLOCATION,
                                      gt->GetLocationForBuild());
         }
@@ -1627,7 +1627,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
         {
         cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
         gg->CreateGenerationObjects();
-        cmGeneratorTarget* gt = gg->GetGeneratorTarget(this);
+        cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
         this->Properties.SetProperty(
                 prop, gt->GetFullPath(configName, false).c_str());
         }
@@ -1651,7 +1651,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
           {
           cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
           gg->CreateGenerationObjects();
-          cmGeneratorTarget* gt = gg->GetGeneratorTarget(this);
+          cmGeneratorTarget* gt = gg->FindGeneratorTarget(this->GetName());
           this->Properties.SetProperty(
                   prop, gt->GetFullPath(configName, false).c_str());
           }
-- 
cgit v0.12


From 7a6caae1a78e8d67422b144ceffdd97595f67683 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Mon, 26 Oct 2015 22:18:20 +0100
Subject: cmMakefile: Add imported target accessor

---
 Source/cmMakefile.cxx | 12 ++++++++++++
 Source/cmMakefile.h   |  1 +
 2 files changed, 13 insertions(+)

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 8f72f67..ffe92af 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1766,6 +1766,18 @@ const char* cmMakefile::GetCurrentBinaryDirectory() const
   return this->StateSnapshot.GetDirectory().GetCurrentBinary();
 }
 
+std::vector<cmTarget*> cmMakefile::GetImportedTargets() const
+{
+  std::vector<cmTarget*> tgts;
+  tgts.reserve(this->ImportedTargets.size());
+  for (TargetMap::const_iterator it = this->ImportedTargets.begin();
+       it != this->ImportedTargets.end(); ++it)
+    {
+    tgts.push_back(it->second);
+    }
+  return tgts;
+}
+
 //----------------------------------------------------------------------------
 void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
                                        bool before)
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 01c4524..f1dd374 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -390,6 +390,7 @@ public:
     {
       return this->ImportedTargetsOwned;
     }
+  std::vector<cmTarget*> GetImportedTargets() const;
 
   cmTarget* FindTarget(const std::string& name,
                        bool excludeAliases = false) const;
-- 
cgit v0.12


From b6278e9ff714d8bdacb54f055eac71fe073b28d8 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 14:17:56 +0100
Subject: cmake: Port find_package mode away from GetGeneratorTarget

---
 Source/cmake.cxx | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 16417fc..d5bc3d2 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -447,8 +447,8 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
     (cmSystemTools::GetCurrentWorkingDirectory());
   // read in the list file to fill the cache
   snapshot.SetDefaultDefinitions();
-  cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
-  cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get()));
+  cmMakefile* mf = new cmMakefile(gg, snapshot);
+  gg->AddMakefile(mf);
 
   mf->SetArgcArgv(args);
 
@@ -481,6 +481,8 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
     std::vector<std::string> includeDirs;
     cmSystemTools::ExpandListArgument(includes, includeDirs);
 
+    gg->CreateGenerationObjects();
+    cmLocalGenerator* lg = gg->LocalGenerators[0];
     std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0, language);
 
     std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
@@ -510,8 +512,9 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
     std::string linkPath;
     std::string flags;
     std::string linkFlags;
-    gg->CreateGeneratorTargets(cmGlobalGenerator::AllTargets, lg.get());
-    cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
+    gg->CreateGenerationObjects();
+    cmGeneratorTarget *gtgt = gg->FindGeneratorTarget(tgt->GetName());
+    cmLocalGenerator* lg = gtgt->GetLocalGenerator();
     lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
                        gtgt, false);
     linkLibs = frameworkPath + linkPath + linkLibs;
-- 
cgit v0.12


From 02533038dae9fb5b4ae1b6f7d55bb5af397400af Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 13:19:38 +0100
Subject: VS6: Port to FindGeneratorTarget

---
 Source/cmLocalVisualStudio6Generator.cxx | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index fd0af61..cdacb9e 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -1112,15 +1112,14 @@ void cmLocalVisualStudio6Generator
       // Compute the proper name to use to link this library.
       std::string lib;
       std::string libDebug;
-      cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str());
+      cmGeneratorTarget* tgt =
+          this->GlobalGenerator->FindGeneratorTarget(j->first.c_str());
       if(tgt)
         {
-        cmGeneratorTarget* gt =
-          this->GlobalGenerator->GetGeneratorTarget(tgt);
         lib = cmSystemTools::GetFilenameWithoutExtension
-          (gt->GetFullName().c_str());
+          (tgt->GetFullName().c_str());
         libDebug = cmSystemTools::GetFilenameWithoutExtension
-          (gt->GetFullName("Debug").c_str());
+          (tgt->GetFullName("Debug").c_str());
         lib += ".lib";
         libDebug += ".lib";
         }
-- 
cgit v0.12


From c389f8bb07e900d805ca3163f47b06e3dbe4303b Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 13:14:44 +0100
Subject: cmLocalGenerator: Port Find method away from GetGeneratorTarget

Mirror the cmMakefile::FindTarget method.
---
 Source/cmGlobalGenerator.cxx | 39 ++++++++++++++++++++++++++++-----------
 Source/cmGlobalGenerator.h   |  4 +++-
 Source/cmLocalGenerator.cxx  | 16 +++++++++++++---
 Source/cmLocalGenerator.h    |  5 +++++
 4 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 5928fb5..d53f0e3 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1583,10 +1583,12 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
-                                               cmLocalGenerator *lg)
+void cmGlobalGenerator::CreateGeneratorTargets(
+    TargetTypes targetTypes,
+    cmMakefile *mf,
+    cmLocalGenerator *lg,
+    std::map<cmTarget*, cmGeneratorTarget*> const& importedMap)
 {
-  cmMakefile* mf = lg->GetMakefile();
   if (targetTypes == AllTargets)
     {
     cmTargets& targets = mf->GetTargets();
@@ -1600,23 +1602,38 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
       }
     }
 
+  std::vector<cmTarget*> itgts = mf->GetImportedTargets();
+
   for(std::vector<cmTarget*>::const_iterator
-        j = mf->GetOwnedImportedTargets().begin();
-      j != mf->GetOwnedImportedTargets().end(); ++j)
+        j = itgts.begin(); j != itgts.end(); ++j)
     {
-    cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
-    this->GeneratorTargets[*j] = gt;
-    lg->AddImportedGeneratorTarget(gt);
+    lg->AddImportedGeneratorTarget(importedMap.find(*j)->second);
     }
 }
 
 //----------------------------------------------------------------------------
 void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
 {
+  std::map<cmTarget*, cmGeneratorTarget*> importedMap;
+  for(unsigned int i=0; i < this->Makefiles.size(); ++i)
+    {
+    cmMakefile* mf = this->Makefiles[i];
+    for(std::vector<cmTarget*>::const_iterator
+          j = mf->GetOwnedImportedTargets().begin();
+        j != mf->GetOwnedImportedTargets().end(); ++j)
+      {
+      cmGeneratorTarget* gt =
+          new cmGeneratorTarget(*j, this->LocalGenerators[i]);
+      this->GeneratorTargets[*j] = gt;
+      importedMap[*j] = gt;
+      }
+    }
+
   // Construct per-target generator information.
   for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
     {
-    this->CreateGeneratorTargets(targetTypes, this->LocalGenerators[i]);
+    this->CreateGeneratorTargets(targetTypes, this->Makefiles[i],
+                                 this->LocalGenerators[i], importedMap);
     }
 }
 
@@ -2240,11 +2257,11 @@ cmGeneratorTarget* cmGlobalGenerator::FindImportedGeneratorTargetImpl(
   for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
     {
     std::vector<cmGeneratorTarget*> tgts =
-        this->LocalGenerators[i]->GetGeneratorTargets();
+        this->LocalGenerators[i]->GetImportedGeneratorTargets();
     for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
          it != tgts.end(); ++it)
       {
-      if ((*it)->GetName() == name && (*it)->IsImportedGloballyVisible())
+      if ((*it)->IsImportedGloballyVisible() && (*it)->GetName() == name)
         {
         return *it;
         }
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index c52b209..0057d61 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -485,7 +485,9 @@ private:
   // Per-target generator information.
   cmGeneratorTargetsType GeneratorTargets;
   friend class cmake;
-  void CreateGeneratorTargets(TargetTypes targetTypes, cmLocalGenerator* lg);
+  void CreateGeneratorTargets(TargetTypes targetTypes, cmMakefile* mf,
+                   cmLocalGenerator* lg,
+                   std::map<cmTarget*, cmGeneratorTarget*> const& importedMap);
   void CreateGeneratorTargets(TargetTypes targetTypes);
 
   void ClearGeneratorMembers();
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1bc7f81..ec7c29f 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1821,11 +1821,21 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
 cmGeneratorTarget*
 cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const
 {
-  if (cmTarget *t = this->Makefile->FindTargetToUse(name))
+  std::vector<cmGeneratorTarget*>::const_iterator
+    imported = std::find_if(this->ImportedGeneratorTargets.begin(),
+                            this->ImportedGeneratorTargets.end(),
+                            NamedGeneratorTargetFinder(name));
+  if(imported != this->ImportedGeneratorTargets.end())
     {
-    return this->GetGlobalGenerator()->GetGeneratorTarget(t);
+    return *imported;
     }
-  return 0;
+
+  if(cmGeneratorTarget* t = this->FindGeneratorTarget(name))
+    {
+    return t;
+    }
+
+  return this->GetGlobalGenerator()->FindGeneratorTarget(name);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 7841d05..67383d7 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -120,6 +120,11 @@ public:
       return this->GeneratorTargets;
     }
 
+  const std::vector<cmGeneratorTarget*> &GetImportedGeneratorTargets() const
+    {
+      return this->ImportedGeneratorTargets;
+    }
+
   void AddGeneratorTarget(cmGeneratorTarget* gt);
   void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
 
-- 
cgit v0.12


From 79c3a2a8f72ea175533da9f323f88c507220486e Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Sun, 25 Oct 2015 13:22:42 +0100
Subject: cmGlobalGenerator: Remove map from cmTarget to cmGeneratorTarget

The configure-time and generate-time types should be completely
independent.

Add ownership of cmGeneratorTarget instances to the cmLocalGenerator.
---
 Source/cmGlobalGenerator.cxx              | 26 +++-----------------------
 Source/cmGlobalGenerator.h                | 14 --------------
 Source/cmGlobalVisualStudio8Generator.cxx |  1 -
 Source/cmGlobalVisualStudioGenerator.cxx  |  1 -
 Source/cmGlobalXCodeGenerator.cxx         |  2 --
 Source/cmLocalGenerator.cxx               |  7 +++++++
 Source/cmLocalGenerator.h                 |  2 ++
 Source/cmQtAutoGeneratorInitializer.cxx   |  1 -
 8 files changed, 12 insertions(+), 42 deletions(-)

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index d53f0e3..3d2db42 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1208,8 +1208,6 @@ void cmGlobalGenerator::Configure()
 void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
 {
   this->CreateLocalGenerators();
-  cmDeleteAll(this->GeneratorTargets);
-  this->GeneratorTargets.clear();
   this->CreateGeneratorTargets(targetTypes);
   this->ComputeBuildFileGenerators();
 }
@@ -1597,7 +1595,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(
       {
       cmTarget* t = &ti->second;
       cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
-      this->GeneratorTargets[t] = gt;
       lg->AddGeneratorTarget(gt);
       }
     }
@@ -1622,9 +1619,9 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
           j = mf->GetOwnedImportedTargets().begin();
         j != mf->GetOwnedImportedTargets().end(); ++j)
       {
-      cmGeneratorTarget* gt =
-          new cmGeneratorTarget(*j, this->LocalGenerators[i]);
-      this->GeneratorTargets[*j] = gt;
+      cmLocalGenerator* lg = this->LocalGenerators[i];
+      cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
+      lg->AddOwnedImportedGeneratorTarget(gt);
       importedMap[*j] = gt;
       }
     }
@@ -1641,9 +1638,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
 //----------------------------------------------------------------------------
 void cmGlobalGenerator::ClearGeneratorMembers()
 {
-  cmDeleteAll(this->GeneratorTargets);
-  this->GeneratorTargets.clear();
-
   cmDeleteAll(this->BuildExportSets);
   this->BuildExportSets.clear();
 
@@ -1662,20 +1656,6 @@ void cmGlobalGenerator::ClearGeneratorMembers()
 }
 
 //----------------------------------------------------------------------------
-cmGeneratorTarget*
-cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const
-{
-  cmGeneratorTargetsType::const_iterator ti = this->GeneratorTargets.find(t);
-  if(ti == this->GeneratorTargets.end())
-    {
-    this->CMakeInstance->IssueMessage(
-      cmake::INTERNAL_ERROR, "Missing cmGeneratorTarget instance!");
-    return 0;
-    }
-  return ti->second;
-}
-
-//----------------------------------------------------------------------------
 void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
 {
 }
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 0057d61..bc6e17d 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -42,10 +42,6 @@ class cmInstallTargetGenerator;
 class cmInstallFilesGenerator;
 class cmExportBuildFileGenerator;
 
-typedef std::map<cmTarget const*,
-                 cmGeneratorTarget*,
-                 cmTarget::StrictTargetComparison> cmGeneratorTargetsType;
-
 /** \class cmGlobalGenerator
  * \brief Responsible for overseeing the generation process for the entire tree
  *
@@ -307,14 +303,6 @@ public:
   TargetDependSet const& GetTargetDirectDepends(
       const cmGeneratorTarget* target);
 
-  /** Get per-target generator information.  */
-  cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const;
-
-  void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt)
-  {
-    this->GeneratorTargets[t] = gt;
-  }
-
   const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap()
                                                const {return this->ProjectMap;}
 
@@ -482,8 +470,6 @@ private:
   typedef std::map<cmGeneratorTarget const*, TargetDependSet> TargetDependMap;
   TargetDependMap TargetDependencies;
 
-  // Per-target generator information.
-  cmGeneratorTargetsType GeneratorTargets;
   friend class cmake;
   void CreateGeneratorTargets(TargetTypes targetTypes, cmMakefile* mf,
                    cmLocalGenerator* lg,
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index f08ab5a..5e239b8 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -257,7 +257,6 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
 
   cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
   lg->AddGeneratorTarget(gt);
-  this->AddGeneratorTarget(tgt, gt);
 
   // Organize in the "predefined targets" folder:
   //
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index b819dad..bb0c974 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -88,7 +88,6 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
 
       cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
       gen[0]->AddGeneratorTarget(gt);
-      this->AddGeneratorTarget(allBuild, gt);
 
 #if 0
       // Can't activate this code because we want ALL_BUILD
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 6d4fc1f..da8c814 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -460,7 +460,6 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
 
   cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
   root->AddGeneratorTarget(allBuildGt);
-  root->GetGlobalGenerator()->AddGeneratorTarget(allbuild, allBuildGt);
 
   // Refer to the main build configuration file for easy editing.
   std::string listfile = root->GetCurrentSourceDirectory();
@@ -496,7 +495,6 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
 
     cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
     root->AddGeneratorTarget(checkGt);
-    root->GetGlobalGenerator()->AddGeneratorTarget(check, checkGt);
     }
 
   // now make the allbuild depend on all the non-utility targets
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index ec7c29f..d92cbea 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -62,6 +62,8 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
 
 cmLocalGenerator::~cmLocalGenerator()
 {
+  cmDeleteAll(this->GeneratorTargets);
+  cmDeleteAll(this->OwnedImportedGeneratorTargets);
 }
 
 void cmLocalGenerator::IssueMessage(cmake::MessageType t,
@@ -460,6 +462,11 @@ void cmLocalGenerator::AddImportedGeneratorTarget(cmGeneratorTarget* gt)
   this->ImportedGeneratorTargets.push_back(gt);
 }
 
+void cmLocalGenerator::AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt)
+{
+  this->OwnedImportedGeneratorTargets.push_back(gt);
+}
+
 struct NamedGeneratorTargetFinder
 {
   NamedGeneratorTargetFinder(std::string const& name)
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 67383d7..e2f5519 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -127,6 +127,7 @@ public:
 
   void AddGeneratorTarget(cmGeneratorTarget* gt);
   void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
+  void AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt);
 
   cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
   cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
@@ -380,6 +381,7 @@ protected:
   std::set<cmGeneratorTarget const*> WarnCMP0063;
   std::vector<cmGeneratorTarget*> GeneratorTargets;
   std::vector<cmGeneratorTarget*> ImportedGeneratorTargets;
+  std::vector<cmGeneratorTarget*> OwnedImportedGeneratorTargets;
   std::map<std::string, std::string> AliasTargets;
 
   bool EmitUniversalBinaryFlags;
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 225c03e..b813c14 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -896,7 +896,6 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
 
     cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
     lg->AddGeneratorTarget(gt);
-    lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt);
 
     // Set target folder
     const char* autogenFolder = makefile->GetState()
-- 
cgit v0.12