Selaa lähdekoodia

Constify handling of target dependencies.

Stephen Kelly 12 vuotta sitten
vanhempi
sitoutus
ef25ba8d06

+ 22 - 20
Source/cmComputeTargetDepends.cxx

@@ -143,12 +143,13 @@ bool cmComputeTargetDepends::Compute()
 
 //----------------------------------------------------------------------------
 void
-cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t,
+cmComputeTargetDepends::GetTargetDirectDepends(cmTarget const* t,
                                                cmTargetDependSet& deps)
 {
   // Lookup the index for this target.  All targets should be known by
   // this point.
-  std::map<cmTarget*, int>::const_iterator tii = this->TargetIndex.find(t);
+  std::map<cmTarget const*, int>::const_iterator tii
+                                                  = this->TargetIndex.find(t);
   assert(tii != this->TargetIndex.end());
   int i = tii->second;
 
@@ -156,7 +157,7 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t,
   EdgeList const& nl = this->FinalGraph[i];
   for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
     {
-    cmTarget* dep = this->Targets[*ni];
+    cmTarget const* dep = this->Targets[*ni];
     cmTargetDependSet::iterator di = deps.insert(dep).first;
     di->SetType(ni->IsStrong());
     }
@@ -170,10 +171,11 @@ void cmComputeTargetDepends::CollectTargets()
     this->GlobalGenerator->GetLocalGenerators();
   for(unsigned int i = 0; i < lgens.size(); ++i)
     {
-    cmTargets& targets = lgens[i]->GetMakefile()->GetTargets();
-    for(cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti)
+    const cmTargets& targets = lgens[i]->GetMakefile()->GetTargets();
+    for(cmTargets::const_iterator ti = targets.begin();
+        ti != targets.end(); ++ti)
       {
-      cmTarget* target = &ti->second;
+      cmTarget const* target = &ti->second;
       int index = static_cast<int>(this->Targets.size());
       this->TargetIndex[target] = index;
       this->Targets.push_back(target);
@@ -198,7 +200,7 @@ void cmComputeTargetDepends::CollectDepends()
 void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
 {
   // Get the depender.
-  cmTarget* depender = this->Targets[depender_index];
+  cmTarget const* depender = this->Targets[depender_index];
   if (depender->GetType() == cmTarget::INTERFACE_LIBRARY)
     {
     return;
@@ -271,11 +273,11 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
 
 //----------------------------------------------------------------------------
 void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
-                                                 cmTarget* dependee,
+                                                 cmTarget const* dependee,
                                                  const char *config,
                                                std::set<cmStdString> &emitted)
 {
-  cmTarget* depender = this->Targets[depender_index];
+  cmTarget const* depender = this->Targets[depender_index];
   if(cmTarget::LinkInterface const* iface =
                                 dependee->GetLinkInterface(config, depender))
     {
@@ -300,8 +302,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
                                              bool linking,
                                              std::set<cmStdString> &emitted)
 {
-  cmTarget* depender = this->Targets[depender_index];
-  cmTarget* dependee =
+  cmTarget const* depender = this->Targets[depender_index];
+  cmTarget const* dependee =
     depender->GetMakefile()->FindTargetToUse(dependee_name);
   // Skip targets that will not really be linked.  This is probably a
   // name conflict between an external library and an executable
@@ -335,10 +337,10 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
                                              bool linking)
 {
   // Get the depender.
-  cmTarget* depender = this->Targets[depender_index];
+  cmTarget const* depender = this->Targets[depender_index];
 
   // Check the target's makefile first.
-  cmTarget* dependee =
+  cmTarget const* dependee =
     depender->GetMakefile()->FindTargetToUse(dependee_name);
 
   // Skip targets that will not really be linked.  This is probably a
@@ -359,7 +361,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
 
 //----------------------------------------------------------------------------
 void cmComputeTargetDepends::AddTargetDepend(int depender_index,
-                                             cmTarget* dependee,
+                                             cmTarget const* dependee,
                                              bool linking)
 {
   if(dependee->IsImported())
@@ -369,7 +371,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
     for(std::set<cmStdString>::const_iterator i = utils.begin();
         i != utils.end(); ++i)
       {
-      if(cmTarget* transitive_dependee =
+      if(cmTarget const* transitive_dependee =
          dependee->GetMakefile()->FindTargetToUse(i->c_str()))
         {
         this->AddTargetDepend(depender_index, transitive_dependee, false);
@@ -380,7 +382,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
     {
     // Lookup the index for this target.  All targets should be known by
     // this point.
-    std::map<cmTarget*, int>::const_iterator tii =
+    std::map<cmTarget const*, int>::const_iterator tii =
       this->TargetIndex.find(dependee);
     assert(tii != this->TargetIndex.end());
     int dependee_index = tii->second;
@@ -400,13 +402,13 @@ cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name)
   for(int depender_index = 0; depender_index < n; ++depender_index)
     {
     EdgeList const& nl = graph[depender_index];
-    cmTarget* depender = this->Targets[depender_index];
+    cmTarget const* depender = this->Targets[depender_index];
     fprintf(stderr, "target %d is [%s]\n",
             depender_index, depender->GetName());
     for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
       {
       int dependee_index = *ni;
-      cmTarget* dependee = this->Targets[dependee_index];
+      cmTarget const* dependee = this->Targets[dependee_index];
       fprintf(stderr, "  depends on target %d [%s] (%s)\n", dependee_index,
               dependee->GetName(), ni->IsStrong()? "strong" : "weak");
       }
@@ -493,7 +495,7 @@ cmComputeTargetDepends
     {
     // Get the depender.
     int i = *ci;
-    cmTarget* depender = this->Targets[i];
+    cmTarget const* depender = this->Targets[i];
 
     // Describe the depender.
     e << "  \"" << depender->GetName() << "\" of type "
@@ -506,7 +508,7 @@ cmComputeTargetDepends
       int j = *ni;
       if(cmap[j] == c)
         {
-        cmTarget* dependee = this->Targets[j];
+        cmTarget const* dependee = this->Targets[j];
         e << "    depends on \"" << dependee->GetName() << "\""
           << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n";
         }

+ 8 - 6
Source/cmComputeTargetDepends.h

@@ -38,19 +38,21 @@ public:
 
   bool Compute();
 
-  std::vector<cmTarget*> const& GetTargets() const { return this->Targets; }
-  void GetTargetDirectDepends(cmTarget* t, cmTargetDependSet& deps);
+  std::vector<cmTarget const*> const&
+  GetTargets() const { return this->Targets; }
+  void GetTargetDirectDepends(cmTarget const* t, cmTargetDependSet& deps);
 private:
   void CollectTargets();
   void CollectDepends();
   void CollectTargetDepends(int depender_index);
   void AddTargetDepend(int depender_index, const char* dependee_name,
                        bool linking);
-  void AddTargetDepend(int depender_index, cmTarget* dependee, bool linking);
+  void AddTargetDepend(int depender_index, cmTarget const* dependee,
+                       bool linking);
   bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
   void AddInterfaceDepends(int depender_index, const char* dependee_name,
                            bool linking, std::set<cmStdString> &emitted);
-  void AddInterfaceDepends(int depender_index, cmTarget* dependee,
+  void AddInterfaceDepends(int depender_index, cmTarget const* dependee,
                            const char *config,
                            std::set<cmStdString> &emitted);
   cmGlobalGenerator* GlobalGenerator;
@@ -58,8 +60,8 @@ private:
   bool NoCycles;
 
   // Collect all targets.
-  std::vector<cmTarget*> Targets;
-  std::map<cmTarget*, int> TargetIndex;
+  std::vector<cmTarget const*> Targets;
+  std::map<cmTarget const*, int> TargetIndex;
 
   // Represent the target dependency graph.  The entry at each
   // top-level index corresponds to a depender whose dependencies are

+ 9 - 8
Source/cmGlobalGenerator.cxx

@@ -950,7 +950,7 @@ void cmGlobalGenerator::ClearEnabledLanguages()
 }
 
 bool cmGlobalGenerator::IsDependedOn(const char* project,
-                                     cmTarget* targetIn)
+                                     cmTarget const* targetIn)
 {
   // Get all local gens for this project
   std::vector<cmLocalGenerator*>* gens = &this->ProjectMap[project];
@@ -1214,8 +1214,8 @@ bool cmGlobalGenerator::ComputeTargetDepends()
     {
     return false;
     }
-  std::vector<cmTarget*> const& targets = ctd.GetTargets();
-  for(std::vector<cmTarget*>::const_iterator ti = targets.begin();
+  std::vector<cmTarget const*> const& targets = ctd.GetTargets();
+  for(std::vector<cmTarget const*>::const_iterator ti = targets.begin();
       ti != targets.end(); ++ti)
     {
     ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]);
@@ -1954,7 +1954,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
           clg = clg->GetParent())
         {
         // This local generator includes the target.
-        std::set<cmTarget*>& targetSet =
+        std::set<cmTarget const*>& targetSet =
           this->LocalGeneratorToTargetMap[clg];
         targetSet.insert(&target);
 
@@ -1965,7 +1965,8 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
         for(TargetDependSet::const_iterator ti = tgtdeps.begin();
             ti != tgtdeps.end(); ++ti)
           {
-          targetSet.insert(*ti);
+          cmTarget const* ttt = *ti;
+          targetSet.insert(ttt);
           }
         }
       }
@@ -2478,7 +2479,7 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*,
 
 //----------------------------------------------------------------------------
 cmGlobalGenerator::TargetDependSet const&
-cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target)
+cmGlobalGenerator::GetTargetDirectDepends(cmTarget const& target)
 {
   return this->TargetDependencies[&target];
 }
@@ -2600,7 +2601,7 @@ bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target)
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::AddTargetDepends(cmTarget* target,
+void cmGlobalGenerator::AddTargetDepends(cmTarget const* target,
                                          TargetDependSet& projectTargets)
 {
   // add the target itself
@@ -2611,7 +2612,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget* target,
     TargetDependSet const& ts = this->GetTargetDirectDepends(*target);
     for(TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i)
       {
-      cmTarget* dtarget = *i;
+      cmTarget const* dtarget = *i;
       this->AddTargetDepends(dtarget, projectTargets);
       }
     }

+ 7 - 5
Source/cmGlobalGenerator.h

@@ -218,7 +218,7 @@ public:
 
   /** If check to see if the target is linked to by any other
       target in the project */
-  bool IsDependedOn(const char* project, cmTarget* target);
+  bool IsDependedOn(const char* project, cmTarget const* target);
   ///! Find a local generator by its startdirectory
   cmLocalGenerator* FindLocalGenerator(const char* start_dir);
 
@@ -266,7 +266,7 @@ public:
 
   // what targets does the specified target depend on directly
   // via a target_link_libraries or add_dependencies
-  TargetDependSet const& GetTargetDirectDepends(cmTarget & target);
+  TargetDependSet const& GetTargetDirectDepends(cmTarget const& target);
 
   /** Get per-target generator information.  */
   cmGeneratorTarget* GetGeneratorTarget(cmTarget*) const;
@@ -323,7 +323,8 @@ protected:
                              TargetDependSet& originalTargets,
                              cmLocalGenerator* root, GeneratorVector const&);
   virtual bool IsRootOnlyTarget(cmTarget* target);
-  void AddTargetDepends(cmTarget* target, TargetDependSet& projectTargets);
+  void AddTargetDepends(cmTarget const* target,
+                        TargetDependSet& projectTargets);
   void SetLanguageEnabledFlag(const char* l, cmMakefile* mf);
   void SetLanguageEnabledMaps(const char* l, cmMakefile* mf);
   void FillExtensionToLanguageMap(const char* l, cmMakefile* mf);
@@ -362,7 +363,8 @@ protected:
   cmLocalGenerator* CurrentLocalGenerator;
   // map from project name to vector of local generators in that project
   std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap;
-  std::map<cmLocalGenerator*, std::set<cmTarget *> > LocalGeneratorToTargetMap;
+  std::map<cmLocalGenerator*, std::set<cmTarget const*> >
+                                                    LocalGeneratorToTargetMap;
 
   // Set of named installation components requested by the project.
   std::set<cmStdString> InstallComponents;
@@ -420,7 +422,7 @@ private:
   std::vector<std::string> FilesReplacedDuringGenerate;
 
   // Store computed inter-target dependencies.
-  typedef std::map<cmTarget *, TargetDependSet> TargetDependMap;
+  typedef std::map<cmTarget const*, TargetDependSet> TargetDependMap;
   TargetDependMap TargetDependencies;
 
   // Per-target generator information.

+ 2 - 2
Source/cmGlobalNinjaGenerator.cxx

@@ -830,7 +830,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
 
 void
 cmGlobalNinjaGenerator
-::AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs)
+::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs)
 {
   const char* configName =
     target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE");
@@ -879,7 +879,7 @@ cmGlobalNinjaGenerator
 
 void
 cmGlobalNinjaGenerator
-::AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs)
+::AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs)
 {
   if (target->GetType() == cmTarget::GLOBAL_TARGET) {
     // Global targets only depend on other utilities, which may not appear in

+ 2 - 2
Source/cmGlobalNinjaGenerator.h

@@ -283,8 +283,8 @@ public:
     ASD.insert(deps.begin(), deps.end());
   }
 
-  void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs);
-  void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs);
+  void AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs);
+  void AppendTargetDepends(cmTarget const* target, cmNinjaDeps& outputs);
   void AddDependencyToAll(cmTarget* target);
   void AddDependencyToAll(const std::string& input);
 

+ 8 - 7
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -841,7 +841,7 @@ cmGlobalUnixMakefileGenerator3
                               cmLocalGenerator::FULL,
                               cmLocalGenerator::SHELL);
       //
-      std::set<cmTarget *> emitted;
+      std::set<cmTarget const*> emitted;
       progCmd << " "
               << this->CountProgressMarksInTarget(t->second->Target, emitted);
       commands.push_back(progCmd.str());
@@ -919,8 +919,8 @@ cmGlobalUnixMakefileGenerator3
 //----------------------------------------------------------------------------
 size_t
 cmGlobalUnixMakefileGenerator3
-::CountProgressMarksInTarget(cmTarget* target,
-                             std::set<cmTarget*>& emitted)
+::CountProgressMarksInTarget(cmTarget const* target,
+                             std::set<cmTarget const*>& emitted)
 {
   size_t count = 0;
   if(emitted.insert(target).second)
@@ -946,9 +946,10 @@ cmGlobalUnixMakefileGenerator3
 ::CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg)
 {
   size_t count = 0;
-  std::set<cmTarget*> emitted;
-  std::set<cmTarget*> const& targets = this->LocalGeneratorToTargetMap[lg];
-  for(std::set<cmTarget*>::const_iterator t = targets.begin();
+  std::set<cmTarget const*> emitted;
+  std::set<cmTarget const*> const& targets
+                                        = this->LocalGeneratorToTargetMap[lg];
+  for(std::set<cmTarget const*>::const_iterator t = targets.begin();
       t != targets.end(); ++t)
     {
     count += this->CountProgressMarksInTarget(*t, emitted);
@@ -969,7 +970,7 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
 //----------------------------------------------------------------------------
 bool
 cmGlobalUnixMakefileGenerator3::ProgressMapCompare
-::operator()(cmTarget* l, cmTarget* r) const
+::operator()(cmTarget const* l, cmTarget const* r) const
 {
   // Order by target name.
   if(int c = strcmp(l->GetName(), r->GetName()))

+ 5 - 4
Source/cmGlobalUnixMakefileGenerator3.h

@@ -181,13 +181,14 @@ protected:
     std::vector<unsigned long> Marks;
     void WriteProgressVariables(unsigned long total, unsigned long& current);
   };
-  struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; };
-  typedef std::map<cmTarget*, TargetProgress,
+  struct ProgressMapCompare { bool operator()(cmTarget const*,
+                                              cmTarget const*) const; };
+  typedef std::map<cmTarget const*, TargetProgress,
                    ProgressMapCompare> ProgressMapType;
   ProgressMapType ProgressMap;
 
-  size_t CountProgressMarksInTarget(cmTarget* target,
-                                    std::set<cmTarget*>& emitted);
+  size_t CountProgressMarksInTarget(cmTarget const* target,
+                                    std::set<cmTarget const*>& emitted);
   size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg);
 
   cmGeneratedFileStream *CommandDatabase;

+ 3 - 3
Source/cmGlobalVisualStudio6Generator.cxx

@@ -205,7 +205,7 @@ void cmGlobalVisualStudio6Generator
         tt = orderedProjectTargets.begin();
       tt != orderedProjectTargets.end(); ++tt)
     {
-    cmTarget* target = *tt;
+    cmTarget const* target = *tt;
     if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
       {
       continue;
@@ -271,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile()
 void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
                                                   const char* dspname,
                                                   const char* dir,
-                                                  cmTarget& target)
+                                                  cmTarget const& target)
 {
   fout << "#########################################################"
     "######################\n\n";
@@ -364,7 +364,7 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout)
 
 //----------------------------------------------------------------------------
 std::string
-cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target)
+cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget const* target)
 {
   std::string pname = target->GetName();
   pname += "_UTILITY";

+ 2 - 2
Source/cmGlobalVisualStudio6Generator.h

@@ -99,12 +99,12 @@ private:
   void WriteDSWFile(std::ostream& fout);
   void WriteDSWHeader(std::ostream& fout);
   void WriteProject(std::ostream& fout,
-                    const char* name, const char* path, cmTarget &t);
+                    const char* name, const char* path, cmTarget const& t);
   void WriteExternalProject(std::ostream& fout,
                             const char* name, const char* path,
                             const std::set<cmStdString>& dependencies);
   void WriteDSWFooter(std::ostream& fout);
-  virtual std::string WriteUtilityDepend(cmTarget* target);
+  virtual std::string WriteUtilityDepend(cmTarget const* target);
   std::string MSDevCommand;
   bool MSDevCommandInitialized;
   std::string const& GetMSDevCommand();

+ 2 - 2
Source/cmGlobalVisualStudio71Generator.cxx

@@ -157,7 +157,7 @@ void
 cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
                                               const char* dspname,
                                               const char* dir,
-                                              cmTarget& t)
+                                              cmTarget const& t)
 {
   // check to see if this is a fortran build
   const char* ext = ".vcproj";
@@ -209,7 +209,7 @@ void
 cmGlobalVisualStudio71Generator
 ::WriteProjectDepends(std::ostream& fout,
                       const char*,
-                      const char*, cmTarget& target)
+                      const char*, cmTarget const& target)
 {
   VSDependSet const& depends = this->VSTargetDepends[&target];
   for(VSDependSet::const_iterator di = depends.begin();

+ 4 - 2
Source/cmGlobalVisualStudio71Generator.h

@@ -59,9 +59,11 @@ protected:
                             std::vector<cmLocalGenerator*>& generators);
   virtual void WriteSolutionConfigurations(std::ostream& fout);
   virtual void WriteProject(std::ostream& fout,
-                            const char* name, const char* path, cmTarget &t);
+                            const char* name, const char* path,
+                            cmTarget const& t);
   virtual void WriteProjectDepends(std::ostream& fout,
-                           const char* name, const char* path, cmTarget &t);
+                           const char* name, const char* path,
+                           cmTarget const& t);
   virtual void WriteProjectConfigurations(
     std::ostream& fout, const char* name, cmTarget::TargetType type,
     const std::set<std::string>& configsPartOfDefaultBuild,

+ 7 - 7
Source/cmGlobalVisualStudio7Generator.cxx

@@ -335,7 +335,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
   for(OrderedTargetDependSet::const_iterator tt =
         projectTargets.begin(); tt != projectTargets.end(); ++tt)
     {
-    cmTarget* target = *tt;
+    cmTarget const* target = *tt;
     if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
       {
       continue;
@@ -376,7 +376,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
   for(OrderedTargetDependSet::const_iterator tt =
         projectTargets.begin(); tt != projectTargets.end(); ++tt)
     {
-    cmTarget* target = *tt;
+    cmTarget const* target = *tt;
     if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
       {
       continue;
@@ -470,7 +470,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends(
   for(OrderedTargetDependSet::const_iterator tt =
         projectTargets.begin(); tt != projectTargets.end(); ++tt)
     {
-    cmTarget* target = *tt;
+    cmTarget const* target = *tt;
     if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
       {
       continue;
@@ -619,7 +619,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path)
 // the libraries it uses are also done here
 void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
                                const char* dspname,
-                               const char* dir, cmTarget& target)
+                               const char* dir, cmTarget const& target)
 {
    // check to see if this is a fortran build
   const char* ext = ".vcproj";
@@ -659,7 +659,7 @@ void
 cmGlobalVisualStudio7Generator
 ::WriteProjectDepends(std::ostream& fout,
                       const char* dspname,
-                      const char*, cmTarget& target)
+                      const char*, cmTarget const& target)
 {
   int depcount = 0;
   std::string dspguid = this->GetGUID(dspname);
@@ -819,7 +819,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
 
 //----------------------------------------------------------------------------
 std::string
-cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target)
+cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
 {
   std::string pname = target->GetName();
   pname += "_UTILITY";
@@ -940,7 +940,7 @@ cmGlobalVisualStudio7Generator
 
 std::set<std::string>
 cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project,
-                                                     cmTarget* target)
+                                                     cmTarget const* target)
 {
   std::set<std::string> activeConfigs;
   // if it is a utilitiy target then only make it part of the

+ 6 - 4
Source/cmGlobalVisualStudio7Generator.h

@@ -121,9 +121,11 @@ protected:
   virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
                             std::vector<cmLocalGenerator*>& generators);
   virtual void WriteProject(std::ostream& fout,
-                            const char* name, const char* path, cmTarget &t);
+                            const char* name, const char* path,
+                            cmTarget const& t);
   virtual void WriteProjectDepends(std::ostream& fout,
-                           const char* name, const char* path, cmTarget &t);
+                           const char* name, const char* path,
+                           cmTarget const&t);
   virtual void WriteProjectConfigurations(
     std::ostream& fout, const char* name, cmTarget::TargetType type,
     const std::set<std::string>& configsPartOfDefaultBuild,
@@ -132,7 +134,7 @@ protected:
                                       cmLocalGenerator* root);
   virtual void WriteSLNFooter(std::ostream& fout);
   virtual void WriteSLNHeader(std::ostream& fout);
-  virtual std::string WriteUtilityDepend(cmTarget* target);
+  virtual std::string WriteUtilityDepend(cmTarget const* target);
 
   virtual void WriteTargetsToSolution(
     std::ostream& fout,
@@ -158,7 +160,7 @@ protected:
   std::string ConvertToSolutionPath(const char* path);
 
   std::set<std::string> IsPartOfDefaultBuild(const char* project,
-                                             cmTarget* target);
+                                             cmTarget const* target);
   std::vector<std::string> Configurations;
   std::map<cmStdString, cmStdString> GUIDMap;
 

+ 1 - 1
Source/cmGlobalVisualStudio8Generator.cxx

@@ -415,7 +415,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
 
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudio8Generator::WriteProjectDepends(
-  std::ostream& fout, const char*, const char*, cmTarget& t)
+  std::ostream& fout, const char*, const char*, cmTarget const& t)
 {
   TargetDependSet const& unordered = this->GetTargetDirectDepends(t);
   OrderedTargetDependSet depends(unordered);

+ 1 - 1
Source/cmGlobalVisualStudio8Generator.h

@@ -84,7 +84,7 @@ protected:
     const char* platformMapping = NULL);
   virtual bool ComputeTargetDepends();
   virtual void WriteProjectDepends(std::ostream& fout, const char* name,
-                                   const char* path, cmTarget &t);
+                                   const char* path, cmTarget const& t);
 
   std::string Name;
   std::string WindowsCEVersion;

+ 13 - 11
Source/cmGlobalVisualStudioGenerator.cxx

@@ -315,7 +315,7 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase()
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget* target,
+void cmGlobalVisualStudioGenerator::FillLinkClosure(cmTarget const* target,
                                                     TargetSet& linked)
 {
   if(linked.insert(target).second)
@@ -348,7 +348,7 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmTarget* target)
 
 //----------------------------------------------------------------------------
 void cmGlobalVisualStudioGenerator::FollowLinkDepends(
-  cmTarget* target, std::set<cmTarget*>& linked)
+  cmTarget const* target, std::set<cmTarget const*>& linked)
 {
   if(target->GetType() == cmTarget::INTERFACE_LIBRARY)
     {
@@ -397,7 +397,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends()
 }
 
 //----------------------------------------------------------------------------
-static bool VSLinkable(cmTarget* t)
+static bool VSLinkable(cmTarget const* t)
 {
   return t->IsLinkable() || t->GetType() == cmTarget::OBJECT_LIBRARY;
 }
@@ -439,7 +439,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
   // Collect implicit link dependencies (target_link_libraries).
   // Static libraries cannot depend on their link implementation
   // due to behavior (2), but they do not really need to.
-  std::set<cmTarget*> linkDepends;
+  std::set<cmTarget const*> linkDepends;
   if(target.GetType() != cmTarget::STATIC_LIBRARY)
     {
     for(TargetDependSet::const_iterator di = depends.begin();
@@ -454,7 +454,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
     }
 
   // Collect explicit util dependencies (add_dependencies).
-  std::set<cmTarget*> utilDepends;
+  std::set<cmTarget const*> utilDepends;
   for(TargetDependSet::const_iterator di = depends.begin();
       di != depends.end(); ++di)
     {
@@ -474,18 +474,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target)
     }
 
   // Emit link dependencies.
-  for(std::set<cmTarget*>::iterator di = linkDepends.begin();
+  for(std::set<cmTarget const*>::iterator di = linkDepends.begin();
       di != linkDepends.end(); ++di)
     {
-    cmTarget* dep = *di;
+    cmTarget const* dep = *di;
     vsTargetDepend.insert(dep->GetName());
     }
 
   // Emit util dependencies.  Possibly use intermediate targets.
-  for(std::set<cmTarget*>::iterator di = utilDepends.begin();
+  for(std::set<cmTarget const*>::iterator di = utilDepends.begin();
       di != utilDepends.end(); ++di)
     {
-    cmTarget* dep = *di;
+    cmTarget const* dep = *di;
     if(allowLinkable || !VSLinkable(dep) || linked.count(dep))
       {
       // Direct dependency allowed.
@@ -523,7 +523,8 @@ void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf)
 }
 
 //----------------------------------------------------------------------------
-std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target)
+std::string
+cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget const* target)
 {
   UtilityDependsMap::iterator i = this->UtilityDepends.find(target);
   if(i == this->UtilityDepends.end())
@@ -845,7 +846,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
       }
     }
 }
-bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget& target)
+bool
+cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
 {
   // check to see if this is a fortran build
   std::set<cmStdString> languages;

+ 9 - 8
Source/cmGlobalVisualStudioGenerator.h

@@ -60,7 +60,7 @@ public:
                                      const char* vsSolutionFile = 0);
 
   // return true if target is fortran only
-  bool TargetIsFortranOnly(cmTarget& t);
+  bool TargetIsFortranOnly(cmTarget const& t);
 
   /** Get the top-level registry key for this VS version.  */
   std::string GetRegistryBase();
@@ -75,7 +75,7 @@ public:
   /** Return true if building for Windows CE */
   virtual bool TargetsWindowsCE() const { return false; }
 
-  class TargetSet: public std::set<cmTarget*> {};
+  class TargetSet: public std::set<cmTarget const*> {};
   struct TargetCompare
   {
     bool operator()(cmTarget const* l, cmTarget const* r) const;
@@ -96,15 +96,15 @@ protected:
 
   virtual bool ComputeTargetDepends();
   class VSDependSet: public std::set<cmStdString> {};
-  class VSDependMap: public std::map<cmTarget*, VSDependSet> {};
+  class VSDependMap: public std::map<cmTarget const*, VSDependSet> {};
   VSDependMap VSTargetDepends;
   void ComputeVSTargetDepends(cmTarget&);
 
   bool CheckTargetLinks(cmTarget& target, const char* name);
   std::string GetUtilityForTarget(cmTarget& target, const char*);
-  virtual std::string WriteUtilityDepend(cmTarget*) = 0;
-  std::string GetUtilityDepend(cmTarget* target);
-  typedef std::map<cmTarget*, cmStdString> UtilityDependsMap;
+  virtual std::string WriteUtilityDepend(cmTarget const*) = 0;
+  std::string GetUtilityDepend(cmTarget const* target);
+  typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap;
   UtilityDependsMap UtilityDepends;
   const char* AdditionalPlatformDefinition;
 
@@ -113,11 +113,12 @@ private:
   void PrintCompilerAdvice(std::ostream&, std::string, const char*) {}
   void ComputeTargetObjects(cmGeneratorTarget* gt) const;
 
-  void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked);
+  void FollowLinkDepends(cmTarget const* target,
+                         std::set<cmTarget const*>& linked);
 
   class TargetSetMap: public std::map<cmTarget*, TargetSet> {};
   TargetSetMap TargetLinkClosure;
-  void FillLinkClosure(cmTarget* target, TargetSet& linked);
+  void FillLinkClosure(cmTarget const* target, TargetSet& linked);
   TargetSet const& GetTargetLinkClosure(cmTarget* target);
 };
 

+ 1 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -2622,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
 }
 
 //----------------------------------------------------------------------------
-cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t)
+cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
 {
   if(!t)
     {

+ 1 - 1
Source/cmGlobalXCodeGenerator.h

@@ -125,7 +125,7 @@ private:
                                      multipleOutputPairs
                                 );
 
-  cmXCodeObject* FindXCodeTarget(cmTarget*);
+  cmXCodeObject* FindXCodeTarget(cmTarget const*);
   std::string GetOrCreateId(const char* name, const char* id);
 
   // create cmXCodeObject from these functions so that memory can be managed

+ 2 - 1
Source/cmTarget.cxx

@@ -828,7 +828,8 @@ void cmTarget::GetDirectLinkLibraries(const char *config,
 
 //----------------------------------------------------------------------------
 void cmTarget::GetInterfaceLinkLibraries(const char *config,
-                        std::vector<std::string> &libs, cmTarget *head) const
+                                         std::vector<std::string> &libs,
+                                         cmTarget const* head) const
 {
   const char *prop = this->GetProperty("INTERFACE_LINK_LIBRARIES");
   if (prop)

+ 1 - 1
Source/cmTarget.h

@@ -187,7 +187,7 @@ public:
                               cmTarget const* head) const;
   void GetInterfaceLinkLibraries(const char *config,
                               std::vector<std::string> &,
-                              cmTarget *head) const;
+                              cmTarget const* head) const;
 
   /** Compute the link type to use for the given configuration.  */
   LinkLibraryType ComputeLinkType(const char* config) const;

+ 5 - 5
Source/cmTargetDepend.h

@@ -20,17 +20,17 @@ class cmTarget;
     It may be marked as a 'link' or 'util' edge or both.  */
 class cmTargetDepend
 {
-  cmTarget* Target;
+  cmTarget const* Target;
 
   // The set order depends only on the Target, so we use
   // mutable members to acheive a map with set syntax.
   mutable bool Link;
   mutable bool Util;
 public:
-  cmTargetDepend(cmTarget* t): Target(t), Link(false), Util(false) {}
-  operator cmTarget*() const { return this->Target; }
-  cmTarget* operator->() const { return this->Target; }
-  cmTarget& operator*() const { return *this->Target; }
+  cmTargetDepend(cmTarget const* t): Target(t), Link(false), Util(false) {}
+  operator cmTarget const*() const { return this->Target; }
+  cmTarget const* operator->() const { return this->Target; }
+  cmTarget const& operator*() const { return *this->Target; }
   friend bool operator < (cmTargetDepend const& l, cmTargetDepend const& r)
     { return l.Target < r.Target; }
   void SetType(bool strong) const

+ 1 - 1
Source/cmVisualStudio10TargetGenerator.cxx

@@ -1841,7 +1841,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
   for( OrderedTargetDependSet::const_iterator i = depends.begin();
        i != depends.end(); ++i)
     {
-    cmTarget* dt = *i;
+    cmTarget const* dt = *i;
     if(dt->GetType() == cmTarget::INTERFACE_LIBRARY)
       {
       continue;