[Cmake-commits] CMake branch, next, updated. v3.4.0-rc1-420-gf8024bd

Stephen Kelly steveire at gmail.com
Sat Oct 10 11:06:26 EDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  f8024bd6b69b84e5cd63ddf2e81be016c9f251b7 (commit)
       via  0f404e51f17f29ba1d525d5bcfdeb303608e0ee0 (commit)
      from  cbeae3b62d1db399875314fd307b7e1581793b71 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f8024bd6b69b84e5cd63ddf2e81be016c9f251b7
commit f8024bd6b69b84e5cd63ddf2e81be016c9f251b7
Merge: cbeae3b 0f404e5
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Oct 10 11:06:24 2015 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Sat Oct 10 11:06:24 2015 -0400

    Merge topic 'use-generator-target' into next
    
    0f404e51 Revert commits.


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0f404e51f17f29ba1d525d5bcfdeb303608e0ee0
commit 0f404e51f17f29ba1d525d5bcfdeb303608e0ee0
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Sat Oct 10 17:05:27 2015 +0200
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Sat Oct 10 17:05:44 2015 +0200

    Revert commits.

diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 24d0e61..252e231 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -109,7 +109,7 @@ std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const
 {
   std::string mod_dir;
   const char* target_mod_dir =
-    this->GeneratorTarget->GetProperty("Fortran_MODULE_DIRECTORY");
+    this->Target->GetProperty("Fortran_MODULE_DIRECTORY");
   const char* moddir_flag =
     this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG");
   if(target_mod_dir && moddir_flag)
@@ -214,7 +214,7 @@ cmCommonTargetGenerator
     this->LocalGenerator->GetFortranFormat(srcfmt);
   if(format == cmLocalGenerator::FortranFormatNone)
     {
-    const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT");
+    const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT");
     format = this->LocalGenerator->GetFortranFormat(tgtfmt);
     }
   const char* var = 0;
@@ -383,7 +383,7 @@ std::vector<std::string>
 cmCommonTargetGenerator::GetLinkedTargetDirectories() const
 {
   std::vector<std::string> dirs;
-  std::set<cmGeneratorTarget const*> emitted;
+  std::set<cmTarget const*> emitted;
   if (cmComputeLinkInformation* cli =
       this->GeneratorTarget->GetLinkInformation(this->ConfigName))
     {
@@ -391,7 +391,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const
     for(cmComputeLinkInformation::ItemVector::const_iterator
           i = items.begin(); i != items.end(); ++i)
       {
-      cmGeneratorTarget const* linkee = i->Target;
+      cmTarget const* linkee = i->Target;
       if(linkee && !linkee->IsImported()
                 // We can ignore the INTERFACE_LIBRARY items because
                 // Target->GetLinkInformation already processed their
@@ -399,11 +399,13 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const
                 && linkee->GetType() != cmTarget::INTERFACE_LIBRARY
                 && emitted.insert(linkee).second)
         {
-        cmLocalGenerator* lg = linkee->GetLocalGenerator();
-        cmMakefile* mf = linkee->Target->GetMakefile();
+        cmGeneratorTarget* gt =
+          this->GlobalGenerator->GetGeneratorTarget(linkee);
+        cmLocalGenerator* lg = gt->GetLocalGenerator();
+        cmMakefile* mf = linkee->GetMakefile();
         std::string di = mf->GetCurrentBinaryDirectory();
         di += "/";
-        di += lg->GetTargetDirectory(*linkee->Target);
+        di += lg->GetTargetDirectory(*linkee);
         dirs.push_back(di);
         }
       }
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 22843f1..7d20827 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -320,7 +320,8 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
   int index = lei->second;
   LinkEntry& entry = this->EntryList[index];
   entry.Item = item;
-  entry.Target = item.Target;
+  entry.Target =
+      item.Target ? this->GlobalGenerator->GetGeneratorTarget(item.Target) : 0;
   entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' &&
                   item.substr(0, 10) != "-framework");
 
@@ -442,7 +443,9 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
     // Initialize the item entry.
     LinkEntry& entry = this->EntryList[lei->second];
     entry.Item = dep.Item;
-    entry.Target = dep.Item.Target;
+    entry.Target =
+        dep.Item.Target ?
+          this->GlobalGenerator->GetGeneratorTarget(dep.Item.Target) : 0;
 
     // This item was added specifically because it is a dependent
     // shared library.  It may get special treatment
@@ -631,9 +634,8 @@ cmComputeLinkDepends::AddLinkEntries(
 }
 
 //----------------------------------------------------------------------------
-cmGeneratorTarget const*
-cmComputeLinkDepends::FindTargetToLink(int depender_index,
-                                       const std::string& name)
+cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
+                                                 const std::string& name)
 {
   // Look for a target in the scope of the depender.
   cmGeneratorTarget const* from = this->Target;
@@ -645,7 +647,7 @@ cmComputeLinkDepends::FindTargetToLink(int depender_index,
       from = depender;
       }
     }
-  return from->FindTargetToLink(name);
+  return from->Target->FindTargetToLink(name);
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index 9d960c6..5ad8714 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -14,7 +14,6 @@
 
 #include "cmStandardIncludes.h"
 #include "cmTarget.h"
-#include "cmLinkItem.h"
 
 #include "cmGraphAdjacencyList.h"
 
@@ -53,7 +52,7 @@ public:
   EntryVector const& Compute();
 
   void SetOldLinkDirMode(bool b);
-  std::set<cmGeneratorTarget const*> const& GetOldWrongConfigItems() const
+  std::set<cmTarget const*> const& GetOldWrongConfigItems() const
     { return this->OldWrongConfigItems; }
 
 private:
@@ -75,8 +74,8 @@ private:
   void AddDirectLinkEntries();
   template <typename T>
     void AddLinkEntries(int depender_index, std::vector<T> const& libs);
-  cmGeneratorTarget const* FindTargetToLink(int depender_index,
-                                            const std::string& name);
+  cmTarget const* FindTargetToLink(int depender_index,
+                                   const std::string& name);
 
   // One entry for each unique item.
   std::vector<LinkEntry> EntryList;
@@ -153,7 +152,7 @@ private:
 
   // Record of the original link line.
   std::vector<int> OriginalEntries;
-  std::set<cmGeneratorTarget const*> OldWrongConfigItems;
+  std::set<cmTarget const*> OldWrongConfigItems;
   void CheckWrongConfigItem(cmLinkItem const& item);
 
   int ComponentOrderId;
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index c6225f6..7e34611 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -19,6 +19,7 @@
 #include "cmState.h"
 #include "cmOutputConverter.h"
 #include "cmMakefile.h"
+#include "cmTarget.h"
 #include "cmGeneratorTarget.h"
 #include "cmake.h"
 #include "cmAlgorithms.h"
@@ -470,7 +471,7 @@ std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths()
 }
 
 //----------------------------------------------------------------------------
-const std::set<const cmGeneratorTarget*>&
+std::set<cmTarget const*> const&
 cmComputeLinkInformation::GetSharedLibrariesLinked()
 {
   return this->SharedLibrariesLinked;
@@ -536,16 +537,16 @@ bool cmComputeLinkInformation::Compute()
     // For CMake 2.4 bug-compatibility we need to consider the output
     // directories of targets linked in another configuration as link
     // directories.
-    std::set<cmGeneratorTarget const*> const& wrongItems =
-        cld.GetOldWrongConfigItems();
-    for(std::set<cmGeneratorTarget const*>::const_iterator i =
-        wrongItems.begin(); i != wrongItems.end(); ++i)
+    std::set<cmTarget const*> const& wrongItems = cld.GetOldWrongConfigItems();
+    for(std::set<cmTarget const*>::const_iterator i = wrongItems.begin();
+        i != wrongItems.end(); ++i)
       {
-      cmGeneratorTarget const* tgt = *i;
+      cmTarget const* tgt = *i;
+      cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt);
       bool implib =
         (this->UseImportLibrary &&
          (tgt->GetType() == cmTarget::SHARED_LIBRARY));
-      std::string lib = tgt->GetFullPath(this->Config , implib, true);
+      std::string lib = gtgt->GetFullPath(this->Config , implib, true);
       this->OldLinkDirItems.push_back(lib);
       }
     }
@@ -657,7 +658,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
       std::string exe = tgt->GetFullPath(config, this->UseImportLibrary,
                                          true);
       linkItem += exe;
-      this->Items.push_back(Item(linkItem, true, tgt));
+      this->Items.push_back(Item(linkItem, true, tgt->Target));
       this->Depends.push_back(exe);
       }
     else if(tgt->GetType() == cmTarget::INTERFACE_LIBRARY)
@@ -665,7 +666,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
       // Add the interface library as an item so it can be considered as part
       // of COMPATIBLE_INTERFACE_ enforcement.  The generators will ignore
       // this for the actual link line.
-      this->Items.push_back(Item(std::string(), true, tgt));
+      this->Items.push_back(Item(std::string(), true, tgt->Target));
       }
     else
       {
@@ -682,8 +683,8 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
         this->Depends.push_back(lib);
         }
 
-      this->AddTargetItem(lib, tgt);
-      this->AddLibraryRuntimeInfo(lib, tgt);
+      this->AddTargetItem(lib, tgt->Target);
+      this->AddLibraryRuntimeInfo(lib, tgt->Target);
       }
     }
   else
@@ -765,7 +766,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
   if(tgt)
     {
     lib = tgt->GetFullPath(this->Config, this->UseImportLibrary);
-    this->AddLibraryRuntimeInfo(lib, tgt);
+    this->AddLibraryRuntimeInfo(lib, tgt->Target);
     }
   else
     {
@@ -1076,7 +1077,7 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
 
 //----------------------------------------------------------------------------
 void cmComputeLinkInformation::AddTargetItem(std::string const& item,
-                                             cmGeneratorTarget const* target)
+                                             cmTarget const* target)
 {
   // This is called to handle a link item that is a full path to a target.
   // If the target is not a static library make sure the link type is
@@ -1095,9 +1096,10 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
     this->SharedLibrariesLinked.insert(target);
     }
 
+  cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(target);
   // Handle case of an imported shared library with no soname.
   if(this->NoSONameUsesPath &&
-     target->IsImportedSharedLibWithoutSOName(this->Config))
+     gtgt->IsImportedSharedLibWithoutSOName(this->Config))
     {
     this->AddSharedLibNoSOName(item);
     return;
@@ -1111,7 +1113,7 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
 
   // For compatibility with CMake 2.4 include the item's directory in
   // the linker search path.
-  if(this->OldLinkDirMode && !target->Target->IsFrameworkOnApple() &&
+  if(this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
      this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
      this->OldLinkDirMask.end())
     {
@@ -1775,14 +1777,15 @@ cmComputeLinkInformation::GetRuntimeSearchPath()
 //----------------------------------------------------------------------------
 void
 cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
-                                              cmGeneratorTarget const* target)
+                                                cmTarget const* target)
 {
+  cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(target);
   // Ignore targets on Apple where install_name is not @rpath.
   // The dependenty library can be found with other means such as
   // @loader_path or full paths.
   if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
     {
-    if(!target->HasMacOSXRpathInstallNameDir(this->Config))
+    if(!gtgt->HasMacOSXRpathInstallNameDir(this->Config))
       {
       return;
       }
@@ -1804,7 +1807,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
 
   // Try to get the soname of the library.  Only files with this name
   // could possibly conflict.
-  std::string soName = target->GetSOName(this->Config);
+  std::string soName = gtgt->GetSOName(this->Config);
   const char* soname = soName.empty()? 0 : soName.c_str();
 
   // Include this library in the runtime path ordering.
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 5eecf7d..b1e7e46 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -19,6 +19,7 @@
 class cmake;
 class cmGlobalGenerator;
 class cmMakefile;
+class cmTarget;
 class cmGeneratorTarget;
 class cmOrderDirectories;
 
@@ -38,11 +39,11 @@ public:
     Item(): Value(), IsPath(true), Target(0) {}
     Item(Item const& item):
       Value(item.Value), IsPath(item.IsPath), Target(item.Target) {}
-    Item(std::string const& v, bool p, cmGeneratorTarget const* target = 0):
+    Item(std::string const& v, bool p, cmTarget const* target = 0):
       Value(v), IsPath(p), Target(target) {}
     std::string Value;
     bool IsPath;
-    cmGeneratorTarget const* Target;
+    cmTarget const* Target;
   };
   typedef std::vector<Item> ItemVector;
   ItemVector const& GetItems();
@@ -56,7 +57,7 @@ public:
   void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install);
   std::string GetRPathString(bool for_install);
   std::string GetChrpathString();
-  std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked();
+  std::set<cmTarget const*> const& GetSharedLibrariesLinked();
 
   std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
   std::string GetRPathLinkString();
@@ -70,7 +71,7 @@ private:
   std::vector<std::string> Depends;
   std::vector<std::string> FrameworkPaths;
   std::vector<std::string> RuntimeSearchPath;
-  std::set<cmGeneratorTarget const*> SharedLibrariesLinked;
+  std::set<cmTarget const*> SharedLibrariesLinked;
 
   // Context information.
   cmGeneratorTarget const* Target;
@@ -128,7 +129,7 @@ private:
   std::string NoCaseExpression(const char* str);
 
   // Handling of link items.
-  void AddTargetItem(std::string const& item, const cmGeneratorTarget* target);
+  void AddTargetItem(std::string const& item, cmTarget const* target);
   void AddFullItem(std::string const& item);
   bool CheckImplicitDirItem(std::string const& item);
   void AddUserItem(std::string const& item, bool pathNotKnown);
@@ -182,7 +183,7 @@ private:
   bool CMP0060Warn;
 
   void AddLibraryRuntimeInfo(std::string const& fullPath,
-                             const cmGeneratorTarget* target);
+                             cmTarget const* target);
   void AddLibraryRuntimeInfo(std::string const& fullPath);
 
 };
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 8f3def2..18aad10 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -272,7 +272,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
 
   // Loop over all utility dependencies.
   {
-  std::set<cmLinkItem> const& tutils = depender->GetUtilityItems();
+  std::set<cmLinkItem> const& tutils = depender->Target->GetUtilityItems();
   std::set<std::string> emitted;
   // A target should not depend on itself.
   emitted.insert(depender->GetName());
@@ -319,20 +319,22 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
                                              std::set<std::string> &emitted)
 {
   cmGeneratorTarget const* depender = this->Targets[depender_index];
-  cmGeneratorTarget const* dependee = dependee_name.Target;
+  cmTarget const* dependee = dependee_name.Target;
   // Skip targets that will not really be linked.  This is probably a
   // name conflict between an external library and an executable
   // within the project.
   if(dependee &&
      dependee->GetType() == cmTarget::EXECUTABLE &&
-     !dependee->Target->IsExecutableWithExports())
+     !dependee->IsExecutableWithExports())
     {
     dependee = 0;
     }
 
   if(dependee)
     {
-    this->AddInterfaceDepends(depender_index, dependee, "", emitted);
+    cmGeneratorTarget* gt =
+        this->GlobalGenerator->GetGeneratorTarget(dependee);
+    this->AddInterfaceDepends(depender_index, gt, "", emitted);
     std::vector<std::string> configs;
     depender->Makefile->GetConfigurations(configs);
     for (std::vector<std::string>::const_iterator it = configs.begin();
@@ -340,7 +342,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
       {
       // A target should not depend on itself.
       emitted.insert(depender->GetName());
-      this->AddInterfaceDepends(depender_index, dependee, *it, emitted);
+      this->AddInterfaceDepends(depender_index, gt, *it, emitted);
       }
     }
 }
@@ -354,7 +356,7 @@ void cmComputeTargetDepends::AddTargetDepend(
   cmGeneratorTarget const* depender = this->Targets[depender_index];
 
   // Check the target's makefile first.
-  cmGeneratorTarget const* dependee = dependee_name.Target;
+  cmTarget const* dependee = dependee_name.Target;
 
   if(!dependee && !linking &&
     (depender->GetType() != cmTarget::GLOBAL_TARGET))
@@ -401,14 +403,16 @@ void cmComputeTargetDepends::AddTargetDepend(
   // within the project.
   if(linking && dependee &&
      dependee->GetType() == cmTarget::EXECUTABLE &&
-     !dependee->Target->IsExecutableWithExports())
+     !dependee->IsExecutableWithExports())
     {
     dependee = 0;
     }
 
   if(dependee)
     {
-    this->AddTargetDepend(depender_index, dependee, linking);
+    cmGeneratorTarget* gt =
+        this->GlobalGenerator->GetGeneratorTarget(dependee);
+    this->AddTargetDepend(depender_index, gt, linking);
     }
 }
 
@@ -422,13 +426,15 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
     {
     // Skip IMPORTED and INTERFACE targets but follow their utility
     // dependencies.
-    std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
+    std::set<cmLinkItem> const& utils = dependee->Target->GetUtilityItems();
     for(std::set<cmLinkItem>::const_iterator i = utils.begin();
         i != utils.end(); ++i)
       {
-      if(cmGeneratorTarget const* transitive_dependee = i->Target)
+      if(cmTarget const* transitive_dependee = i->Target)
         {
-        this->AddTargetDepend(depender_index, transitive_dependee, false);
+        cmGeneratorTarget* gt =
+            this->GlobalGenerator->GetGeneratorTarget(transitive_dependee);
+        this->AddTargetDepend(depender_index, gt, false);
         }
       }
     }
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 400fa17..fed0dbc 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -217,7 +217,7 @@ cmExportBuildFileGenerator
     std::string prop = "IMPORTED_IMPLIB";
     prop += suffix;
     std::string value = target->GetFullPath(config, true);
-    target->GetImplibGNUtoMS(value, value,
+    target->Target->GetImplibGNUtoMS(value, value,
                              "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
     properties[prop] = value;
     }
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 6669919..d6149b3 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -513,9 +513,8 @@ void cmExportFileGenerator::PopulateInterfaceProperty(
 
 
 //----------------------------------------------------------------------------
-void getPropertyContents(cmGeneratorTarget const* tgt,
-                         const std::string& prop,
-                         std::set<std::string> &ifaceProperties)
+void getPropertyContents(cmTarget const* tgt, const std::string& prop,
+         std::set<std::string> &ifaceProperties)
 {
   const char *p = tgt->GetProperty(prop);
   if (!p)
@@ -586,11 +585,11 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
 
   std::set<std::string> ifaceProperties;
 
-  getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties);
-  getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_STRING", ifaceProperties);
-  getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MIN",
+  getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties);
+  getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties);
+  getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
                       ifaceProperties);
-  getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX",
+  getPropertyContents(target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
                       ifaceProperties);
 
   if (target->GetType() != cmTarget::INTERFACE_LIBRARY)
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 21c71b0..11410a7 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -255,9 +255,9 @@ void cmExtraSublimeTextGenerator::
             }
           std::vector<std::string>& flags = sourceFileFlagsIter->second;
           std::string flagsString =
-            this->ComputeFlagsForObject(*iter, lg, gtgt);
+            this->ComputeFlagsForObject(*iter, lg, target, gtgt);
           std::string definesString =
-            this->ComputeDefines(*iter, lg, gtgt);
+            this->ComputeDefines(*iter, lg, target, gtgt);
           flags.clear();
           cmsys::RegularExpression flagRegex;
           // Regular expression to extract compiler flags from a string
@@ -365,6 +365,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
 std::string
 cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
                                                    cmLocalGenerator* lg,
+                                                   cmTarget *target,
                                                    cmGeneratorTarget* gtgt)
 {
   std::string flags;
@@ -389,7 +390,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
   //   }
 
   // Add shared-library flags if needed.
-  lg->AddCMP0018Flags(flags, gtgt->Target, language, config);
+  lg->AddCMP0018Flags(flags, target, language, config);
 
   // Add include directory flags.
   {
@@ -404,7 +405,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
   lg->AppendFlags(flags, makefile->GetDefineFlags());
 
   // Add target-specific flags.
-  lg->AddCompileOptions(flags, gtgt->Target, language, config);
+  lg->AddCompileOptions(flags, target, language, config);
 
   // Add source file specific flags.
   lg->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS"));
@@ -418,8 +419,8 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
 // void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
 std::string
 cmExtraSublimeTextGenerator::
-ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg,
-               cmGeneratorTarget* target)
+ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target,
+               cmGeneratorTarget*)
 
 {
   std::set<std::string> defines;
@@ -428,13 +429,13 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg,
   const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
 
   // Add the export symbol definition for shared library objects.
-  if(const char* exportMacro = target->Target->GetExportMacro())
+  if(const char* exportMacro = target->GetExportMacro())
     {
     lg->AppendDefines(defines, exportMacro);
     }
 
   // Add preprocessor definitions for this target and configuration.
-  lg->AddCompileDefinitions(defines, target->Target, config, language);
+  lg->AddCompileDefinitions(defines, target, config, language);
   lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
   {
   std::string defPropName = "COMPILE_DEFINITIONS_";
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 5dd1140..4173b7d 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -79,10 +79,11 @@ private:
    */
   std::string ComputeFlagsForObject(cmSourceFile *source,
                                     cmLocalGenerator* lg,
+                                    cmTarget *target,
                                     cmGeneratorTarget* gtgt);
 
   std::string ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg,
-                             cmGeneratorTarget* gtgt);
+                             cmTarget *target, cmGeneratorTarget* gtgt);
 };
 
 #endif
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 88d10aa..78a5b6f 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -831,8 +831,8 @@ template <typename T>
 std::string
 getLinkedTargetsContent(
   std::vector<T> const &libraries,
-  cmGeneratorTarget const* target,
-  cmGeneratorTarget const* headTarget,
+  cmTarget const* target,
+  cmTarget const* headTarget,
   cmGeneratorExpressionContext *context,
   cmGeneratorExpressionDAGChecker *dagChecker,
   const std::string &interfacePropertyName)
@@ -858,10 +858,8 @@ getLinkedTargetsContent(
     {
     linkedTargetsContent =
         cmGeneratorExpressionNode::EvaluateDependentExpression(depString,
-                                        target->Target->GetMakefile(),
-                                        context,
-                                        headTarget->Target,
-                                        target->Target, dagChecker);
+                                        target->GetMakefile(), context,
+                                        headTarget, target, dagChecker);
     }
   linkedTargetsContent =
     cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent);
@@ -1118,8 +1116,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
          gtgt->GetLinkInterfaceLibraries(context->Config, gHeadTarget, true))
         {
         linkedTargetsContent =
-          getLinkedTargetsContent(iface->Libraries, gtgt,
-                                  gHeadTarget,
+          getLinkedTargetsContent(iface->Libraries, target,
+                                  headTarget,
                                   context, &dagChecker,
                                   interfacePropertyName);
         }
@@ -1130,8 +1128,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
          gtgt->GetLinkImplementationLibraries(context->Config))
         {
         linkedTargetsContent =
-          getLinkedTargetsContent(impl->Libraries, gtgt,
-                                  gtgt,
+          getLinkedTargetsContent(impl->Libraries, target,
+                                  target,
                                   context, &dagChecker,
                                   interfacePropertyName);
         }
@@ -1660,7 +1658,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag>
       return std::string();
       }
     return target->GetFullPath(context->Config,
-                               target->HasImportLibrary());
+                               target->Target->HasImportLibrary());
   }
 };
 
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index f33a9e1..f39a67d 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -271,8 +271,7 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
   DebugCompileFeaturesDone(false),
   DebugCompileDefinitionsDone(false),
   DebugSourcesDone(false),
-  LinkImplementationLanguageIsContextDependent(true),
-  UtilityItemsDone(false)
+  LinkImplementationLanguageIsContextDependent(true)
 {
   this->Makefile = this->Target->GetMakefile();
   this->LocalGenerator = lg;
@@ -510,8 +509,7 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const
   return 0;
 }
 
-static void handleSystemIncludesDep(cmMakefile *mf,
-                                  cmGeneratorTarget const* depTgt,
+static void handleSystemIncludesDep(cmMakefile *mf, cmTarget const* depTgt,
                                   const std::string& config,
                                   cmGeneratorTarget const* headTarget,
                                   cmGeneratorExpressionDAGChecker *dagChecker,
@@ -525,7 +523,7 @@ static void handleSystemIncludesDep(cmMakefile *mf,
     cmSystemTools::ExpandListArgument(ge.Parse(dirs)
                                       ->Evaluate(mf,
                                       config, false, headTarget->Target,
-                                      depTgt->Target, dagChecker), result);
+                                      depTgt, dagChecker), result);
     }
   if (!depTgt->IsImported() || excludeImported)
     {
@@ -539,7 +537,7 @@ static void handleSystemIncludesDep(cmMakefile *mf,
     cmSystemTools::ExpandListArgument(ge.Parse(dirs)
                                       ->Evaluate(mf,
                                       config, false, headTarget->Target,
-                                      depTgt->Target, dagChecker), result);
+                                      depTgt, dagChecker), result);
     }
 }
 
@@ -762,25 +760,7 @@ cmGeneratorTarget::GetExpectedXamlSources(std::set<std::string>& srcs,
 {
   XamlData data;
   IMPLEMENT_VISIT_IMPL(Xaml, COMMA cmGeneratorTarget::XamlData)
-      srcs = data.ExpectedXamlSources;
-}
-
-std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
-{
-  if(!this->UtilityItemsDone)
-    {
-    this->UtilityItemsDone = true;
-    std::set<std::string> const& utilities = this->Target->GetUtilities();
-    for(std::set<std::string>::const_iterator i = utilities.begin();
-        i != utilities.end(); ++i)
-      {
-      cmTarget* tgt = this->Makefile->FindTargetToUse(*i);
-      cmGeneratorTarget* gt = tgt ? this->GlobalGenerator
-          ->GetGeneratorTarget(tgt) : 0;
-      this->UtilityItems.insert(cmLinkItem(*i, gt));
-      }
-    }
-  return this->UtilityItems;
+  srcs = data.ExpectedXamlSources;
 }
 
 //----------------------------------------------------------------------------
@@ -884,9 +864,9 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
                                           &dagChecker), result);
       }
 
-    std::vector<cmGeneratorTarget const*> const& deps =
+    std::vector<cmTarget const*> const& deps =
       this->GetLinkImplementationClosure(config);
-    for(std::vector<cmGeneratorTarget const*>::const_iterator
+    for(std::vector<cmTarget const*>::const_iterator
           li = deps.begin(), le = deps.end(); li != le; ++li)
       {
       handleSystemIncludesDep(this->Makefile, *li, config, this,
@@ -1731,12 +1711,15 @@ public:
         }
       return;
       }
-    if(!this->Visited.insert(item.Target->Target).second)
+    if(!this->Visited.insert(item.Target).second)
       {
       return;
       }
+    cmGeneratorTarget* gtgt =
+        this->Target->GetLocalGenerator()->GetGlobalGenerator()
+            ->GetGeneratorTarget(item.Target);
     cmLinkInterface const* iface =
-      item.Target->GetLinkInterface(this->Config, this->HeadTarget);
+      gtgt->GetLinkInterface(this->Config, this->HeadTarget);
     if(!iface) { return; }
 
     for(std::vector<std::string>::const_iterator
@@ -2067,14 +2050,15 @@ void processILibs(const std::string& config,
                   cmGeneratorTarget const* headTarget,
                   cmLinkItem const& item,
                   cmGlobalGenerator* gg,
-                  std::vector<cmGeneratorTarget const*>& tgts,
-                  std::set<cmGeneratorTarget const*>& emitted)
+                  std::vector<cmTarget const*>& tgts,
+                  std::set<cmTarget const*>& emitted)
 {
   if (item.Target && emitted.insert(item.Target).second)
     {
     tgts.push_back(item.Target);
+    cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target);
     if(cmLinkInterfaceLibraries const* iface =
-       item.Target->GetLinkInterfaceLibraries(config, headTarget, true))
+       gt->GetLinkInterfaceLibraries(config, headTarget, true))
       {
       for(std::vector<cmLinkItem>::const_iterator
             it = iface->Libraries.begin();
@@ -2087,7 +2071,7 @@ void processILibs(const std::string& config,
 }
 
 //----------------------------------------------------------------------------
-const std::vector<const cmGeneratorTarget*>&
+const std::vector<const cmTarget*>&
 cmGeneratorTarget::GetLinkImplementationClosure(
     const std::string& config) const
 {
@@ -2096,7 +2080,7 @@ cmGeneratorTarget::GetLinkImplementationClosure(
   if(!tgts.Done)
     {
     tgts.Done = true;
-    std::set<cmGeneratorTarget const*> emitted;
+    std::set<cmTarget const*> emitted;
 
     cmLinkImplementationLibraries const* impl
       = this->GetLinkImplementationLibraries(config);
@@ -3631,10 +3615,10 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
     compat.Done = true;
     compat.PropsBool.insert("POSITION_INDEPENDENT_CODE");
     compat.PropsString.insert("AUTOUIC_OPTIONS");
-    std::vector<cmGeneratorTarget const*> const& deps =
+    std::vector<cmTarget const*> const& deps =
       this->GetLinkImplementationClosure(config);
-    for(std::vector<cmGeneratorTarget const*>::const_iterator li =
-        deps.begin(); li != deps.end(); ++li)
+    for(std::vector<cmTarget const*>::const_iterator li = deps.begin();
+        li != deps.end(); ++li)
       {
 #define CM_READ_COMPATIBLE_INTERFACE(X, x) \
       if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \
@@ -3751,7 +3735,7 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
 //----------------------------------------------------------------------------
 template<typename PropertyType>
 void checkPropertyConsistency(cmGeneratorTarget const* depender,
-                              cmGeneratorTarget const* dependee,
+                              cmTarget const* dependee,
                               const std::string& propName,
                               std::set<std::string> &emitted,
                               const std::string& config,
@@ -3767,7 +3751,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
   std::vector<std::string> props;
   cmSystemTools::ExpandListArgument(prop, props);
   std::string pdir =
-    dependee->Target->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT");
+    dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT");
   pdir += "/Help/prop_tgt/";
 
   for(std::vector<std::string>::iterator pi = props.begin();
@@ -3980,20 +3964,18 @@ std::string compatibilityAgree(CompatibleType t, bool dominant)
 
 //----------------------------------------------------------------------------
 template<typename PropertyType>
-PropertyType getTypedProperty(cmGeneratorTarget const* tgt,
-                              const std::string& prop);
+PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop);
 
 //----------------------------------------------------------------------------
 template<>
-bool getTypedProperty<bool>(cmGeneratorTarget const* tgt,
-                            const std::string& prop)
+bool getTypedProperty<bool>(cmTarget const* tgt, const std::string& prop)
 {
   return tgt->GetPropertyAsBool(prop);
 }
 
 //----------------------------------------------------------------------------
 template<>
-const char *getTypedProperty<const char *>(cmGeneratorTarget const* tgt,
+const char *getTypedProperty<const char *>(cmTarget const* tgt,
                                            const std::string& prop)
 {
   return tgt->GetProperty(prop);
@@ -4123,7 +4105,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
                                           CompatibleType t,
                                           PropertyType *)
 {
-  PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
+  PropertyType propContent = getTypedProperty<PropertyType>(tgt->Target, p);
   const bool explicitlySet = tgt->Target->GetProperties()
                                   .find(p)
                                   != tgt->Target->GetProperties().end();
@@ -4132,7 +4114,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
   assert((impliedByUse ^ explicitlySet)
       || (!impliedByUse && !explicitlySet));
 
-  std::vector<cmGeneratorTarget const*> const& deps =
+  std::vector<cmTarget const*> const& deps =
     tgt->GetLinkImplementationClosure(config);
 
   if(deps.empty())
@@ -4159,7 +4141,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
     }
 
   std::string interfaceProperty = "INTERFACE_" + p;
-  for(std::vector<cmGeneratorTarget const*>::const_iterator li =
+  for(std::vector<cmTarget const*>::const_iterator li =
       deps.begin();
       li != deps.end(); ++li)
     {
@@ -4169,11 +4151,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
     // target itself has a POSITION_INDEPENDENT_CODE which disagrees
     // with a dependency.
 
-    cmGeneratorTarget const* theTarget = *li;
+    cmTarget const* theTarget = *li;
 
-    const bool ifaceIsSet = theTarget->Target->GetProperties()
+    const bool ifaceIsSet = theTarget->GetProperties()
                             .find(interfaceProperty)
-                            != theTarget->Target->GetProperties().end();
+                            != theTarget->GetProperties().end();
     PropertyType ifacePropContent =
                     getTypedProperty<PropertyType>(theTarget,
                               interfaceProperty);
@@ -4428,7 +4410,7 @@ void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
       {
       continue;
       }
-    items.push_back(cmLinkItem(name, this->FindTargetToLink(name)));
+    items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name)));
     }
 }
 
@@ -4491,7 +4473,7 @@ cmGeneratorTarget::GetLinkInterface(const std::string& config,
     return &hm.begin()->second;
     }
 
-  cmOptionalLinkInterface& iface = hm[head];
+  cmOptionalLinkInterface& iface = hm[head->Target];
   if(!iface.LibrariesDone)
     {
     iface.LibrariesDone = true;
@@ -4643,7 +4625,7 @@ cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config,
     return &hm.begin()->second;
     }
 
-  cmOptionalLinkInterface& iface = hm[head];
+  cmOptionalLinkInterface& iface = hm[head->Target];
   if(!iface.LibrariesDone)
     {
     iface.LibrariesDone = true;
@@ -5080,7 +5062,7 @@ cmGeneratorTarget::GetImportLinkInterface(const std::string& config,
     return &hm.begin()->second;
     }
 
-  cmOptionalLinkInterface& iface = hm[headTarget];
+  cmOptionalLinkInterface& iface = hm[headTarget->Target];
   if(!iface.AllDone)
     {
     iface.AllDone = true;
@@ -5399,7 +5381,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
 
       // The entry is meant for this configuration.
       impl.Libraries.push_back(
-        cmLinkImplItem(name, this->FindTargetToLink(name),
+        cmLinkImplItem(name, this->Target->FindTargetToLink(name),
                        *btIt, evaluated != *le));
       }
 
@@ -5431,48 +5413,12 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
         }
       // Support OLD behavior for CMP0003.
       impl.WrongConfigLibraries.push_back(
-        cmLinkItem(name, this->FindTargetToLink(name)));
+        cmLinkItem(name, this->Target->FindTargetToLink(name)));
       }
     }
 }
 
 //----------------------------------------------------------------------------
-cmGeneratorTarget*
-cmGeneratorTarget::FindTargetToLink(std::string const& name) const
-{
-  cmTarget const* tgt = this->Makefile->FindTargetToUse(name);
-
-  // Skip targets that will not really be linked.  This is probably a
-  // name conflict between an external library and an executable
-  // within the project.
-  if(tgt && tgt->GetType() == cmTarget::EXECUTABLE &&
-     !tgt->IsExecutableWithExports())
-    {
-    tgt = 0;
-    }
-
-  if(tgt && tgt->GetType() == cmTarget::OBJECT_LIBRARY)
-    {
-    std::ostringstream e;
-    e << "Target \"" << this->GetName() << "\" links to "
-      "OBJECT library \"" << tgt->GetName() << "\" but this is not "
-      "allowed.  "
-      "One may link only to STATIC or SHARED libraries, or to executables "
-      "with the ENABLE_EXPORTS property set.";
-    cmake* cm = this->Makefile->GetCMakeInstance();
-    cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
-                     this->Target->GetBacktrace());
-    tgt = 0;
-    }
-
-  if (!tgt)
-    {
-    return 0;
-    }
-  return this->GlobalGenerator->GetGeneratorTarget(tgt);
-}
-
-//----------------------------------------------------------------------------
 std::string
 cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
 {
@@ -5483,47 +5429,3 @@ cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
     }
   return "";
 }
-
-//----------------------------------------------------------------------------
-bool cmGeneratorTarget::HasImplibGNUtoMS() const
-{
-  return this->HasImportLibrary()
-      && this->GetPropertyAsBool("GNUtoMS");
-}
-
-//----------------------------------------------------------------------------
-bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName,
-                                std::string& out, const char* newExt) const
-{
-  if(this->HasImplibGNUtoMS() &&
-     gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a")
-    {
-    out = gnuName.substr(0, gnuName.size()-6);
-    out += newExt? newExt : ".lib";
-    return true;
-    }
-  return false;
-}
-
-//----------------------------------------------------------------------------
-bool cmGeneratorTarget::HasImportLibrary() const
-{
-  return (this->Target->IsDLLPlatform() &&
-          (this->GetType() == cmTarget::SHARED_LIBRARY ||
-           this->Target->IsExecutableWithExports()));
-}
-
-//----------------------------------------------------------------------------
-std::string cmGeneratorTarget::GetSupportDirectory() const
-{
-  std::string dir = this->Makefile->GetCurrentBinaryDirectory();
-  dir += cmake::GetCMakeFilesDirectory();
-  dir += "/";
-  dir += this->GetName();
-#if defined(__VMS)
-  dir += "_dir";
-#else
-  dir += ".dir";
-#endif
-  return dir;
-}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 258c556..799110c 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -82,8 +82,6 @@ public:
   void GetExpectedXamlSources(std::set<std::string>&,
                               const std::string& config) const;
 
-  std::set<cmLinkItem>const& GetUtilityItems() const;
-
   void ComputeObjectMapping();
 
   const char* GetFeature(const std::string& feature,
@@ -216,8 +214,6 @@ public:
                                           cmOptionalLinkImplementation& impl,
                                           const cmGeneratorTarget* head) const;
 
-  cmGeneratorTarget* FindTargetToLink(std::string const& name) const;
-
   // Compute the set of languages compiled by the target.  This is
   // computed every time it is called because the languages can change
   // when source file properties are changed and we do not have enough
@@ -390,20 +386,6 @@ public:
   ///! Return the preferred linker language for this target
   std::string GetLinkerLanguage(const std::string& config = "") const;
 
-  /** Does this target have a GNU implib to convert to MS format?  */
-  bool HasImplibGNUtoMS() const;
-
-  /** Convert the given GNU import library name (.dll.a) to a name with a new
-      extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}).  */
-  bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
-                        const char* newExt = 0) const;
-
-  /** Return whether or not the target has a DLL import library.  */
-  bool HasImportLibrary() const;
-
-  /** Get a build-tree directory in which to place target support files.  */
-  std::string GetSupportDirectory() const;
-
   struct SourceFileFlags
   GetTargetSourceFileFlags(const cmSourceFile* sf) const;
 
@@ -491,7 +473,7 @@ private:
   cmGeneratorTarget(cmGeneratorTarget const&);
   void operator=(cmGeneratorTarget const&);
 
-  struct LinkImplClosure: public std::vector<cmGeneratorTarget const*>
+  struct LinkImplClosure: public std::vector<cmTarget const*>
   {
     LinkImplClosure(): Done(false) {}
     bool Done;
@@ -555,7 +537,6 @@ private:
   typedef std::pair<std::string, bool> OutputNameKey;
   typedef std::map<OutputNameKey, std::string> OutputNameMapType;
   mutable OutputNameMapType OutputNameMap;
-  mutable std::set<cmLinkItem> UtilityItems;
   mutable bool PolicyWarnedCMP0022;
   mutable bool DebugIncludesDone;
   mutable bool DebugCompileOptionsDone;
@@ -563,14 +544,13 @@ private:
   mutable bool DebugCompileDefinitionsDone;
   mutable bool DebugSourcesDone;
   mutable bool LinkImplementationLanguageIsContextDependent;
-  mutable bool UtilityItemsDone;
 
   bool ComputePDBOutputDir(const std::string& kind, const std::string& config,
                            std::string& out) const;
 
 public:
-  const std::vector<const cmGeneratorTarget*>&
-  GetLinkImplementationClosure(const std::string& config) const;
+  std::vector<cmTarget const*> const&
+    GetLinkImplementationClosure(const std::string& config) const;
 
   mutable std::map<std::string, std::string> MaxLanguageStandards;
   std::map<std::string, std::string> const&
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 8f69acd..eb4dfee 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2895,14 +2895,13 @@ void cmGlobalGenerator::WriteSummary()
       {
       continue;
       }
-    cmGeneratorTarget* gt = this->GetGeneratorTarget(ti->second);
-    this->WriteSummary(gt);
-    fout << gt->GetSupportDirectory() << "\n";
+    this->WriteSummary(ti->second);
+    fout << ti->second->GetSupportDirectory() << "\n";
     }
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
+void cmGlobalGenerator::WriteSummary(cmTarget* target)
 {
   // Place the labels file in a per-target support directory.
   std::string dir = target->GetSupportDirectory();
@@ -2945,15 +2944,17 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
     fout << "# Source files and their labels\n";
     std::vector<cmSourceFile*> sources;
     std::vector<std::string> configs;
-    target->Target->GetMakefile()->GetConfigurations(configs);
+    target->GetMakefile()->GetConfigurations(configs);
     if (configs.empty())
       {
       configs.push_back("");
       }
+    cmGeneratorTarget* gt =
+        this->GetGeneratorTarget(target);
     for(std::vector<std::string>::const_iterator ci = configs.begin();
         ci != configs.end(); ++ci)
       {
-      target->GetSourceFiles(sources, *ci);
+      gt->GetSourceFiles(sources, *ci);
       }
     std::vector<cmSourceFile*>::const_iterator sourcesEnd
         = cmRemoveDuplicates(sources);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 55e3766..b22c695 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -458,7 +458,7 @@ private:
   void WriteRuleHashes(std::string const& pfile);
 
   void WriteSummary();
-  void WriteSummary(cmGeneratorTarget* target);
+  void WriteSummary(cmTarget* target);
   void FinalizeTargetCompileInfo();
 
   virtual void ForceLinkerLanguages();
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index e2112d7..383ee00 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -135,7 +135,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
       filesFrom.push_back(from1);
       filesTo.push_back(to1);
       std::string targetNameImportLib;
-      if(this->Target->GetImplibGNUtoMS(targetNameImport,
+      if(this->Target->Target->GetImplibGNUtoMS(targetNameImport,
                                         targetNameImportLib))
         {
         filesFrom.push_back(fromDirConfig + targetNameImportLib);
@@ -199,7 +199,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
       filesFrom.push_back(from1);
       filesTo.push_back(to1);
       std::string targetNameImportLib;
-      if(this->Target->GetImplibGNUtoMS(targetNameImport,
+      if(this->Target->Target->GetImplibGNUtoMS(targetNameImport,
                                         targetNameImportLib))
         {
         filesFrom.push_back(fromDirConfig + targetNameImportLib);
@@ -387,7 +387,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
     if(nameType == NameImplib)
       {
       // Use the import library name.
-      if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname,
+      if(!target->GetImplibGNUtoMS(targetNameImport, fname,
                                    "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
         {
         fname = targetNameImport;
@@ -416,7 +416,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
     if(nameType == NameImplib)
       {
       // Use the import library name.
-      if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname,
+      if(!target->GetImplibGNUtoMS(targetNameImport, fname,
                                    "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
         {
         fname = targetNameImport;
@@ -563,12 +563,12 @@ cmInstallTargetGenerator
   std::map<std::string, std::string> install_name_remap;
   if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config))
     {
-    std::set<cmGeneratorTarget const*> const& sharedLibs
+    std::set<cmTarget const*> const& sharedLibs
                                             = cli->GetSharedLibrariesLinked();
-    for(std::set<cmGeneratorTarget const*>::const_iterator j
-        = sharedLibs.begin(); j != sharedLibs.end(); ++j)
+    for(std::set<cmTarget const*>::const_iterator j = sharedLibs.begin();
+        j != sharedLibs.end(); ++j)
       {
-      cmGeneratorTarget const* tgt = *j;
+      cmTarget const* tgt = *j;
 
       // The install_name of an imported target does not change.
       if(tgt->IsImported())
@@ -576,17 +576,20 @@ cmInstallTargetGenerator
         continue;
         }
 
+      cmGeneratorTarget *gtgt = tgt->GetMakefile()
+                                          ->GetGlobalGenerator()
+                                          ->GetGeneratorTarget(tgt);
       // If the build tree and install tree use different path
       // components of the install_name field then we need to create a
       // mapping to be applied after installation.
-      std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
-      std::string for_install = tgt->GetInstallNameDirForInstallTree();
+      std::string for_build = gtgt->GetInstallNameDirForBuildTree(config);
+      std::string for_install = gtgt->GetInstallNameDirForInstallTree();
       if(for_build != for_install)
         {
         // The directory portions differ.  Append the filename to
         // create the mapping.
         std::string fname =
-          this->GetInstallFilename(tgt->Target, config, NameSO);
+          this->GetInstallFilename(tgt, config, NameSO);
 
         // Map from the build-tree install_name.
         for_build += fname;
diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h
index b875cc0..10dd465 100644
--- a/Source/cmLinkItem.h
+++ b/Source/cmLinkItem.h
@@ -15,7 +15,7 @@
 
 #include "cmListFileCache.h"
 
-class cmGeneratorTarget;
+class cmTarget;
 
 // Basic information about each link item.
 class cmLinkItem: public std::string
@@ -24,9 +24,9 @@ class cmLinkItem: public std::string
 public:
   cmLinkItem(): std_string(), Target(0) {}
   cmLinkItem(const std_string& n,
-             cmGeneratorTarget const* t): std_string(n), Target(t) {}
+             cmTarget const* t): std_string(n), Target(t) {}
   cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {}
-  cmGeneratorTarget const* Target;
+  cmTarget const* Target;
 };
 
 class cmLinkImplItem: public cmLinkItem
@@ -34,7 +34,7 @@ class cmLinkImplItem: public cmLinkItem
 public:
   cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {}
   cmLinkImplItem(std::string const& n,
-                 cmGeneratorTarget const* t,
+                 cmTarget const* t,
                  cmListFileBacktrace const& bt,
                  bool fromGenex):
     cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {}
@@ -97,7 +97,7 @@ struct cmOptionalLinkInterface: public cmLinkInterface
 };
 
 struct cmHeadToLinkInterfaceMap:
-    public std::map<cmGeneratorTarget const*, cmOptionalLinkInterface>
+    public std::map<cmTarget const*, cmOptionalLinkInterface>
 {
 };
 
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 76ef8cc..f6b907e 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -168,7 +168,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   if(linkLanguage.empty())
     {
     cmSystemTools::Error("Cannot determine link language for target \"",
-                         this->GeneratorTarget->GetName().c_str(), "\".");
+                         this->Target->GetName().c_str(), "\".");
     return;
     }
 
@@ -197,7 +197,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
                            this->ConfigName);
 
 
-  if(this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE"))
+  if(this->Target->GetPropertyAsBool("WIN32_EXECUTABLE"))
     {
     this->LocalGenerator->AppendFlags
       (linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE"));
@@ -226,11 +226,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
 
   // Add target-specific linker flags.
   this->LocalGenerator->AppendFlags
-    (linkFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
+    (linkFlags, this->Target->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
   this->LocalGenerator->AppendFlags
-    (linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+    (linkFlags, this->Target->GetProperty(linkFlagsConfig));
 
   this->AddModuleDefinitionFlag(linkFlags);
 
@@ -259,7 +259,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
                                           cmLocalGenerator::START_OUTPUT,
                                           cmLocalGenerator::UNCHANGED));
     std::string implib;
-    if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib))
+    if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
       {
       exeCleanFiles.push_back(this->Convert(implib,
                                             cmLocalGenerator::START_OUTPUT,
@@ -361,7 +361,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   vars.CMTarget = this->Target;
   vars.Language = linkLanguage.c_str();
   vars.Objects = buildObjs.c_str();
-  std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
+  std::string objectDir = this->Target->GetSupportDirectory();
   objectDir = this->Convert(objectDir,
                             cmLocalGenerator::START_OUTPUT,
                             cmLocalGenerator::SHELL);
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 5e5eeab..3b3f63e 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -26,7 +26,7 @@ cmMakefileLibraryTargetGenerator
   cmMakefileTargetGenerator(target)
 {
   this->CustomCommandDriver = OnDepends;
-  if (this->GeneratorTarget->GetType() != cmTarget::INTERFACE_LIBRARY)
+  if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY)
     {
     this->GeneratorTarget->GetLibraryNames(
       this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
@@ -62,7 +62,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
 
   // write the link rules
   // Write the rule for this target type.
-  switch(this->GeneratorTarget->GetType())
+  switch(this->Target->GetType())
     {
     case cmTarget::STATIC_LIBRARY:
       this->WriteStaticLibraryRules();
@@ -122,11 +122,11 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
 
   // Write the rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      this->GeneratorTarget->GetName(),
+                                      this->Target->GetName(),
                                       depends, commands, true);
 
   // Write the main driver rule to build everything in this target.
-  this->WriteTargetDriverRule(this->GeneratorTarget->GetName(), false);
+  this->WriteTargetDriverRule(this->Target->GetName(), false);
 }
 
 //----------------------------------------------------------------------------
@@ -166,11 +166,11 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
 
   std::string extraFlags;
   this->LocalGenerator->AppendFlags
-    (extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
+    (extraFlags, this->Target->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
   this->LocalGenerator->AppendFlags
-    (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+    (extraFlags, this->Target->GetProperty(linkFlagsConfig));
 
   this->LocalGenerator->AddConfigVariableFlags
     (extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
@@ -190,11 +190,11 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
 
   std::string extraFlags;
   this->LocalGenerator->AppendFlags(extraFlags,
-                           this->GeneratorTarget->GetProperty("LINK_FLAGS"));
+                                    this->Target->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
   this->LocalGenerator->AppendFlags
-    (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+    (extraFlags, this->Target->GetProperty(linkFlagsConfig));
   this->LocalGenerator->AddConfigVariableFlags
     (extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
   this->AddModuleDefinitionFlag(extraFlags);
@@ -213,11 +213,11 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
 
   std::string extraFlags;
   this->LocalGenerator->AppendFlags(extraFlags,
-                             this->GeneratorTarget->GetProperty("LINK_FLAGS"));
+                                    this->Target->GetProperty("LINK_FLAGS"));
   std::string linkFlagsConfig = "LINK_FLAGS_";
   linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
   this->LocalGenerator->AppendFlags
-    (extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+    (extraFlags, this->Target->GetProperty(linkFlagsConfig));
   this->LocalGenerator->AddConfigVariableFlags
     (extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName);
 
@@ -244,7 +244,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   if(linkLanguage.empty())
     {
     cmSystemTools::Error("Cannot determine link language for target \"",
-                         this->GeneratorTarget->GetName().c_str(), "\".");
+                         this->Target->GetName().c_str(), "\".");
     return;
     }
 
@@ -253,8 +253,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   this->LocalGenerator->AppendFlags(linkFlags, extraFlags);
 
   // Add OSX version flags, if any.
-  if(this->GeneratorTarget->GetType() == cmTarget::SHARED_LIBRARY ||
-     this->GeneratorTarget->GetType() == cmTarget::MODULE_LIBRARY)
+  if(this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
+     this->Target->GetType() == cmTarget::MODULE_LIBRARY)
     {
     this->AppendOSXVerFlag(linkFlags, linkLanguage, "COMPATIBILITY", true);
     this->AppendOSXVerFlag(linkFlags, linkLanguage, "CURRENT", false);
@@ -351,7 +351,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     // Add the link message.
     std::string buildEcho = "Linking ";
     buildEcho += linkLanguage;
-    switch(this->GeneratorTarget->GetType())
+    switch(this->Target->GetType())
       {
       case cmTarget::STATIC_LIBRARY:
         buildEcho += " static library ";
@@ -375,7 +375,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
     }
 
   const char* forbiddenFlagVar = 0;
-  switch(this->GeneratorTarget->GetType())
+  switch(this->Target->GetType())
     {
     case cmTarget::SHARED_LIBRARY:
       forbiddenFlagVar = "_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS";
@@ -410,7 +410,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
         cmLocalGenerator::START_OUTPUT,
         cmLocalGenerator::UNCHANGED));
     std::string implib;
-    if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib))
+    if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
       {
       libCleanFiles.push_back(this->Convert(implib,
                                             cmLocalGenerator::START_OUTPUT,
@@ -441,7 +441,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   std::vector<std::string> commands1;
   // Add a command to remove any existing files for this library.
   // for static libs only
-  if(this->GeneratorTarget->GetType() == cmTarget::STATIC_LIBRARY)
+  if(this->Target->GetType() == cmTarget::STATIC_LIBRARY)
     {
     this->LocalGenerator->AppendCleanCommand(commands1, libCleanFiles,
                                              *this->Target, "target");
@@ -497,7 +497,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   std::vector<std::string> archiveAppendCommands;
   std::vector<std::string> archiveFinishCommands;
   std::string::size_type archiveCommandLimit = std::string::npos;
-  if(this->GeneratorTarget->GetType() == cmTarget::STATIC_LIBRARY)
+  if(this->Target->GetType() == cmTarget::STATIC_LIBRARY)
     {
     haveStaticLibraryRule =
       this->Makefile->GetDefinition(linkRuleVar)? true:false;
@@ -552,7 +552,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
 
   // Collect up flags to link in needed libraries.
   std::string linkLibs;
-  if(this->GeneratorTarget->GetType() != cmTarget::STATIC_LIBRARY)
+  if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
     {
     this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
                          useWatcomQuote);
@@ -566,15 +566,15 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
                           useWatcomQuote);
 
   // maybe create .def file from list of objects
-  if (this->GeneratorTarget->GetType() == cmTarget::SHARED_LIBRARY &&
+  if (this->Target->GetType() == cmTarget::SHARED_LIBRARY &&
       this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS"))
     {
-    if(this->GeneratorTarget->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
+    if(this->Target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
       {
       std::string name_of_def_file =
-        this->GeneratorTarget->GetSupportDirectory();
+        this->Target->GetSupportDirectory();
       name_of_def_file += std::string("/") +
-        this->GeneratorTarget->GetName();
+        this->Target->GetName();
       name_of_def_file += ".def";
       std::string cmd = cmSystemTools::GetCMakeCommand();
       cmd = this->Convert(cmd, cmLocalGenerator::NONE,
@@ -643,7 +643,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   vars.CMTarget = this->Target;
   vars.Language = linkLanguage.c_str();
   vars.Objects = buildObjs.c_str();
-  std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
+  std::string objectDir = this->Target->GetSupportDirectory();
   objectDir = this->Convert(objectDir,
                             cmLocalGenerator::START_OUTPUT,
                             cmLocalGenerator::SHELL);
@@ -667,7 +667,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
 
   // Compute the directory portion of the install_name setting.
   std::string install_name_dir;
-  if(this->GeneratorTarget->GetType() == cmTarget::SHARED_LIBRARY)
+  if(this->Target->GetType() == cmTarget::SHARED_LIBRARY)
     {
     // Get the install_name directory for the build tree.
     install_name_dir =
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 8534986..6eafeae 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -245,8 +245,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
     // Write an empty dependency file.
     cmGeneratedFileStream depFileStream(dependFileNameFull.c_str());
     depFileStream
-      << "# Empty dependencies file for "
-      << this->GeneratorTarget->GetName() << ".\n"
+      << "# Empty dependencies file for " << this->Target->GetName() << ".\n"
       << "# This may be replaced when dependencies are built." << std::endl;
     }
 
@@ -558,8 +557,7 @@ cmMakefileTargetGenerator
       this->GeneratorTarget->GetCompilePDBPath(this->ConfigName);
     if(targetFullPathCompilePDB.empty())
       {
-      targetFullPathCompilePDB =
-          this->GeneratorTarget->GetSupportDirectory() + "/";
+      targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/";
       }
     }
 
@@ -596,7 +594,7 @@ cmMakefileTargetGenerator
                   cmLocalGenerator::NONE,
                   cmLocalGenerator::SHELL);
   vars.Object = shellObj.c_str();
-  std::string objectDir = this->GeneratorTarget->GetSupportDirectory();
+  std::string objectDir = this->Target->GetSupportDirectory();
   objectDir = this->Convert(objectDir,
                             cmLocalGenerator::START_OUTPUT,
                             cmLocalGenerator::SHELL);
@@ -1518,7 +1516,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule(
                                               const std::string& linkRuleVar)
 {
   std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
-  if(this->GeneratorTarget->HasImplibGNUtoMS())
+  if(this->Target->HasImplibGNUtoMS())
     {
     std::string ruleVar = "CMAKE_";
     ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index 18594bb..303ca63 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -42,8 +42,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
   this->CreateRuleFile();
 
   *this->BuildFileStream
-    << "# Utility rule file for "
-    << this->GeneratorTarget->GetName() << ".\n\n";
+    << "# Utility rule file for " << this->Target->GetName() << ".\n\n";
 
   if(!this->NoRuleMessages)
     {
@@ -102,11 +101,11 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
 
   // Write the rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
-                                      this->GeneratorTarget->GetName(),
+                                      this->Target->GetName(),
                                       depends, commands, true);
 
   // Write the main driver rule to build everything in this target.
-  this->WriteTargetDriverRule(this->GeneratorTarget->GetName(), false);
+  this->WriteTargetDriverRule(this->Target->GetName(), false);
 
   // Write clean target
   this->WriteTargetCleanRules();
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 0dc53f3..f8743d9 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -492,8 +492,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     {
     if(target.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"))
       {
+      std::string dllname = targetOutput;
       std::string name_of_def_file
-        = gt.GetSupportDirectory();
+        = target.GetSupportDirectory();
       name_of_def_file += "/" + target.GetName();
       name_of_def_file += ".def ";
       vars["LINK_FLAGS"] += " /DEF:";
@@ -558,7 +559,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
                                               cmLocalGenerator::SHELL);
     vars["TARGET_IMPLIB"] = impLibPath;
     EnsureParentDirectoryExists(impLibPath);
-    if(genTarget.HasImportLibrary())
+    if(target.HasImportLibrary())
       {
       byproducts.push_back(targetOutputImplib);
       }
@@ -581,7 +582,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
     vars["TARGET_PDB"] = base + suffix + dbg_suffix;
     }
 
-  const std::string objPath = GetGeneratorTarget()->GetSupportDirectory();
+  const std::string objPath = GetTarget()->GetSupportDirectory();
   vars["OBJECT_DIR"] =
     this->GetLocalGenerator()->ConvertToOutputFormat(
       this->ConvertToNinjaPath(objPath), cmLocalGenerator::SHELL);
@@ -633,7 +634,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
       this->GetLocalGenerator()->ConvertToOutputFormat(
         cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
       std::string name_of_def_file
-        = gt.GetSupportDirectory();
+        = target.GetSupportDirectory();
       name_of_def_file += "/" + target.GetName();
       name_of_def_file += ".def";
       std::string cmd = cmakeCommand;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index fd9a158..c2daa63 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -93,7 +93,7 @@ std::string cmNinjaTargetGenerator::LanguageCompilerRule(
   const std::string& lang) const
 {
   return lang + "_COMPILER__" +
-    cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName());
+    cmGlobalNinjaGenerator::EncodeRuleName(this->Target->GetName());
 }
 
 std::string
@@ -190,8 +190,8 @@ ComputeDefines(cmSourceFile const* source, const std::string& language)
 cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
 {
   // Static libraries never depend on other targets for linking.
-  if (this->GeneratorTarget->GetType() == cmTarget::STATIC_LIBRARY ||
-      this->GeneratorTarget->GetType() == cmTarget::OBJECT_LIBRARY)
+  if (this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
+      this->Target->GetType() == cmTarget::OBJECT_LIBRARY)
     return cmNinjaDeps();
 
   cmComputeLinkInformation* cli =
@@ -219,8 +219,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
     }
 
   // Add user-specified dependencies.
-  if (const char* linkDepends =
-      this->GeneratorTarget->GetProperty("LINK_DEPENDS"))
+  if (const char* linkDepends = this->Target->GetProperty("LINK_DEPENDS"))
     {
     std::vector<std::string> linkDeps;
     cmSystemTools::ExpandListArgument(linkDepends, linkDeps);
@@ -273,7 +272,7 @@ cmNinjaTargetGenerator
 
 std::string cmNinjaTargetGenerator::GetTargetName() const
 {
-  return this->GeneratorTarget->GetName();
+  return this->Target->GetName();
 }
 
 
@@ -285,10 +284,10 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
     {
     std::string pdbPath;
     std::string compilePdbPath;
-    if(this->GeneratorTarget->GetType() == cmTarget::EXECUTABLE ||
-       this->GeneratorTarget->GetType() == cmTarget::STATIC_LIBRARY ||
-       this->GeneratorTarget->GetType() == cmTarget::SHARED_LIBRARY ||
-       this->GeneratorTarget->GetType() == cmTarget::MODULE_LIBRARY)
+    if(this->Target->GetType() == cmTarget::EXECUTABLE ||
+       this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
+       this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
+       this->Target->GetType() == cmTarget::MODULE_LIBRARY)
       {
       pdbPath = this->GeneratorTarget->GetPDBDirectory(this->GetConfigName());
       pdbPath += "/";
@@ -300,7 +299,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
               this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName());
       if(compilePdbPath.empty())
         {
-        compilePdbPath = this->GeneratorTarget->GetSupportDirectory() + "/";
+        compilePdbPath = this->Target->GetSupportDirectory() + "/";
         }
       }
 
@@ -412,7 +411,7 @@ cmNinjaTargetGenerator
   if (!compileCmds.empty() && (lang == "C" || lang == "CXX"))
     {
     std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
-    const char *iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
+    const char *iwyu = this->Target->GetProperty(iwyu_prop);
     if (iwyu && *iwyu)
       {
       std::string run_iwyu =
@@ -429,7 +428,7 @@ cmNinjaTargetGenerator
   if (!compileCmds.empty() && (lang == "C" || lang == "CXX"))
     {
     std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
-    const char *clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
+    const char *clauncher = this->Target->GetProperty(clauncher_prop);
     if (clauncher && *clauncher)
       {
       std::vector<std::string> launcher_cmd;
@@ -569,7 +568,7 @@ cmNinjaTargetGenerator
   std::string const language = source->GetLanguage();
   std::string const sourceFileName =
     language=="RC" ? source->GetFullPath() : this->GetSourceFilePath(source);
-  std::string const objectDir = this->GeneratorTarget->GetSupportDirectory();
+  std::string const objectDir = this->Target->GetSupportDirectory();
   std::string const objectFileName = this->GetObjectFilePath(source);
   std::string const objectFileDir =
     cmSystemTools::GetFilenamePath(objectFileName);
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 6e3f65f..378f132 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -64,7 +64,7 @@ static void SetupSourceFiles(cmGeneratorTarget const* target,
         std::string basename = cmsys::SystemTools::
                                       GetFilenameWithoutLastExtension(absFile);
 
-        std::string rcc_output_dir = target->GetSupportDirectory();
+        std::string rcc_output_dir = target->Target->GetSupportDirectory();
         cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
         std::string rcc_output_file = rcc_output_dir;
         rcc_output_file += "/qrc_" + basename + ".cpp";
@@ -833,7 +833,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
           std::string basename = cmsys::SystemTools::
                                   GetFilenameWithoutLastExtension(absFile);
 
-          std::string rcc_output_dir = target->GetSupportDirectory();
+          std::string rcc_output_dir = target->Target->GetSupportDirectory();
           cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
           std::string rcc_output_file = rcc_output_dir;
           rcc_output_file += "/qrc_" + basename + ".cpp";
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 847a5c1..3de7efe 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -64,6 +64,27 @@ const char* cmTarget::GetTargetTypeName(TargetType targetType)
 class cmTargetInternals
 {
 public:
+  cmTargetInternals()
+    : Backtrace()
+    {
+    this->UtilityItemsDone = false;
+    }
+  cmTargetInternals(cmTargetInternals const&)
+    : Backtrace()
+    {
+    this->UtilityItemsDone = false;
+    }
+  ~cmTargetInternals();
+
+  // The backtrace when the target was created.
+  cmListFileBacktrace Backtrace;
+
+  typedef std::map<std::string, cmTarget::ImportInfo> ImportInfoMapType;
+  ImportInfoMapType ImportInfoMap;
+
+  std::set<cmLinkItem> UtilityItems;
+  bool UtilityItemsDone;
+
   std::vector<std::string> IncludeDirectoriesEntries;
   std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces;
   std::vector<std::string> CompileOptionsEntries;
@@ -79,6 +100,11 @@ public:
 };
 
 //----------------------------------------------------------------------------
+cmTargetInternals::~cmTargetInternals()
+{
+}
+
+//----------------------------------------------------------------------------
 cmTarget::cmTarget()
 {
   this->Makefile = 0;
@@ -234,7 +260,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
     }
 
   // Save the backtrace of target construction.
-  this->Backtrace = this->Makefile->GetBacktrace();
+  this->Internal->Backtrace = this->Makefile->GetBacktrace();
 
   if (!this->IsImported())
     {
@@ -338,6 +364,22 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
 }
 
 //----------------------------------------------------------------------------
+std::set<cmLinkItem> const& cmTarget::GetUtilityItems() const
+{
+  if(!this->Internal->UtilityItemsDone)
+    {
+    this->Internal->UtilityItemsDone = true;
+    for(std::set<std::string>::const_iterator i = this->Utilities.begin();
+        i != this->Utilities.end(); ++i)
+      {
+      this->Internal->UtilityItems.insert(
+        cmLinkItem(*i, this->Makefile->FindTargetToUse(*i)));
+      }
+    }
+  return this->Internal->UtilityItems;
+}
+
+//----------------------------------------------------------------------------
 void cmTarget::FinishConfigure()
 {
   // Erase any cached link information that might have been comptued
@@ -357,7 +399,22 @@ void cmTarget::FinishConfigure()
 //----------------------------------------------------------------------------
 cmListFileBacktrace const& cmTarget::GetBacktrace() const
 {
-  return this->Backtrace;
+  return this->Internal->Backtrace;
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetSupportDirectory() const
+{
+  std::string dir = this->Makefile->GetCurrentBinaryDirectory();
+  dir += cmake::GetCMakeFilesDirectory();
+  dir += "/";
+  dir += this->Name;
+#if defined(__VMS)
+  dir += "_dir";
+#else
+  dir += ".dir";
+#endif
+  return dir;
 }
 
 //----------------------------------------------------------------------------
@@ -1535,7 +1592,7 @@ void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop)
   // Wipe out maps caching information affected by this property.
   if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED"))
     {
-    this->ImportInfoMap.clear();
+    this->Internal->ImportInfoMap.clear();
     }
 }
 
@@ -2163,6 +2220,26 @@ void cmTarget::ComputeVersionedName(std::string& vName,
 }
 
 //----------------------------------------------------------------------------
+bool cmTarget::HasImplibGNUtoMS() const
+{
+  return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS");
+}
+
+//----------------------------------------------------------------------------
+bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName,
+                                std::string& out, const char* newExt) const
+{
+  if(this->HasImplibGNUtoMS() &&
+     gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a")
+    {
+    out = gnuName.substr(0, gnuName.size()-6);
+    out += newExt? newExt : ".lib";
+    return true;
+    }
+  return false;
+}
+
+//----------------------------------------------------------------------------
 void cmTarget::SetPropertyDefault(const std::string& property,
                                   const char* default_value)
 {
@@ -2285,15 +2362,16 @@ cmTarget::GetImportInfo(const std::string& config) const
     {
     config_upper = "NOCONFIG";
     }
+  typedef cmTargetInternals::ImportInfoMapType ImportInfoMapType;
 
   ImportInfoMapType::const_iterator i =
-    this->ImportInfoMap.find(config_upper);
-  if(i == this->ImportInfoMap.end())
+    this->Internal->ImportInfoMap.find(config_upper);
+  if(i == this->Internal->ImportInfoMap.end())
     {
     ImportInfo info;
     this->ComputeImportInfo(config_upper, info);
     ImportInfoMapType::value_type entry(config_upper, info);
-    i = this->ImportInfoMap.insert(entry).first;
+    i = this->Internal->ImportInfoMap.insert(entry).first;
     }
 
   if(this->GetType() == INTERFACE_LIBRARY)
@@ -2613,6 +2691,37 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
 }
 
 //----------------------------------------------------------------------------
+cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const
+{
+  cmTarget const* tgt = this->Makefile->FindTargetToUse(name);
+
+  // Skip targets that will not really be linked.  This is probably a
+  // name conflict between an external library and an executable
+  // within the project.
+  if(tgt && tgt->GetType() == cmTarget::EXECUTABLE &&
+     !tgt->IsExecutableWithExports())
+    {
+    tgt = 0;
+    }
+
+  if(tgt && tgt->GetType() == cmTarget::OBJECT_LIBRARY)
+    {
+    std::ostringstream e;
+    e << "Target \"" << this->GetName() << "\" links to "
+      "OBJECT library \"" << tgt->GetName() << "\" but this is not "
+      "allowed.  "
+      "One may link only to STATIC or SHARED libraries, or to executables "
+      "with the ENABLE_EXPORTS property set.";
+    cmake* cm = this->Makefile->GetCMakeInstance();
+    cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+    tgt = 0;
+    }
+
+  // Return the target found, if any.
+  return tgt;
+}
+
+//----------------------------------------------------------------------------
 std::string cmTarget::CheckCMP0004(std::string const& item) const
 {
   // Strip whitespace off the library names because we used to do this
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 97515a7..16d0121 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -16,6 +16,7 @@
 #include "cmPropertyMap.h"
 #include "cmPolicies.h"
 #include "cmListFileCache.h"
+#include "cmLinkItem.h"
 
 #include <cmsys/auto_ptr.hxx>
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -205,6 +206,7 @@ public:
   void AddUtility(const std::string& u, cmMakefile *makefile = 0);
   ///! Get the utilities used by this target
   std::set<std::string>const& GetUtilities() const { return this->Utilities; }
+  std::set<cmLinkItem>const& GetUtilityItems() const;
   cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
 
   /** Finalize the target at the end of the Configure step.  */
@@ -223,6 +225,8 @@ public:
 
   void GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const;
 
+  cmTarget const* FindTargetToLink(std::string const& name) const;
+
   /** Strip off leading and trailing whitespace from an item named in
       the link dependencies of this target.  */
   std::string CheckCMP0004(std::string const& item) const;
@@ -240,6 +244,14 @@ public:
   void
   GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
 
+  /** Does this target have a GNU implib to convert to MS format?  */
+  bool HasImplibGNUtoMS() const;
+
+  /** Convert the given GNU import library name (.dll.a) to a name with a new
+      extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}).  */
+  bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
+                        const char* newExt = 0) const;
+
   // Get the properties
   cmPropertyMap &GetProperties() const { return this->Properties; }
 
@@ -262,6 +274,9 @@ public:
   /** Return whether or not the target is for a DLL platform.  */
   bool IsDLLPlatform() const { return this->DLLPlatform; }
 
+  /** Return whether or not the target has a DLL import library.  */
+  bool HasImportLibrary() const;
+
   /** Return whether this target is a shared library Framework on
       Apple.  */
   bool IsFrameworkOnApple() const;
@@ -282,6 +297,9 @@ public:
   /** Get a backtrace from the creation of the target.  */
   cmListFileBacktrace const& GetBacktrace() const;
 
+  /** Get a build-tree directory in which to place target support files.  */
+  std::string GetSupportDirectory() const;
+
   /** @return whether this target have a well defined output file name. */
   bool HaveWellDefinedOutputFiles() const;
 
@@ -449,9 +467,6 @@ private:
     std::string SharedDeps;
   };
 
-  typedef std::map<std::string, ImportInfo> ImportInfoMapType;
-  mutable ImportInfoMapType ImportInfoMap;
-
   ImportInfo const* GetImportInfo(const std::string& config) const;
   void ComputeImportInfo(std::string const& desired_config,
                          ImportInfo& info) const;
@@ -460,9 +475,6 @@ private:
 
   void MaybeInvalidatePropertyCache(const std::string& prop);
 
-  /** Return whether or not the target has a DLL import library.  */
-  bool HasImportLibrary() const;
-
   // Internal representation details.
   friend class cmTargetInternals;
   friend class cmGeneratorTarget;
@@ -474,8 +486,6 @@ private:
                             std::string const& suffix,
                             std::string const& name,
                             const char* version) const;
-
-  cmListFileBacktrace Backtrace;
 };
 
 #ifdef CMAKE_BUILD_WITH_CMAKE

-----------------------------------------------------------------------

Summary of changes:
 Source/cmCommonTargetGenerator.cxx             |   16 ++-
 Source/cmComputeLinkDepends.cxx                |   14 +-
 Source/cmComputeLinkDepends.h                  |    9 +-
 Source/cmComputeLinkInformation.cxx            |   39 +++---
 Source/cmComputeLinkInformation.h              |   13 +-
 Source/cmComputeTargetDepends.cxx              |   28 ++--
 Source/cmExportBuildFileGenerator.cxx          |    2 +-
 Source/cmExportFileGenerator.cxx               |   13 +-
 Source/cmExtraSublimeTextGenerator.cxx         |   17 +--
 Source/cmExtraSublimeTextGenerator.h           |    3 +-
 Source/cmGeneratorExpressionNode.cxx           |   20 ++-
 Source/cmGeneratorTarget.cxx                   |  174 ++++++------------------
 Source/cmGeneratorTarget.h                     |   26 +---
 Source/cmGlobalGenerator.cxx                   |   13 +-
 Source/cmGlobalGenerator.h                     |    2 +-
 Source/cmInstallTargetGenerator.cxx            |   25 ++--
 Source/cmLinkItem.h                            |   10 +-
 Source/cmMakefileExecutableTargetGenerator.cxx |   12 +-
 Source/cmMakefileLibraryTargetGenerator.cxx    |   50 +++----
 Source/cmMakefileTargetGenerator.cxx           |   10 +-
 Source/cmMakefileUtilityTargetGenerator.cxx    |    7 +-
 Source/cmNinjaNormalTargetGenerator.cxx        |    9 +-
 Source/cmNinjaTargetGenerator.cxx              |   27 ++--
 Source/cmQtAutoGeneratorInitializer.cxx        |    4 +-
 Source/cmTarget.cxx                            |  121 +++++++++++++++-
 Source/cmTarget.h                              |   26 ++--
 26 files changed, 352 insertions(+), 338 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list