From fe8b0330ebb4b3347e130e8a556ec2a4edfada93 Mon Sep 17 00:00:00 2001
From: Stephen Kelly <steveire@gmail.com>
Date: Tue, 21 Jan 2014 15:16:43 +0100
Subject: cmMakefile: Constify some cmSourceGroup related code.

---
 Source/cmMakefile.cxx    | 11 ++++++-----
 Source/cmMakefile.h      |  2 +-
 Source/cmSourceGroup.cxx |  8 ++++----
 Source/cmSourceGroup.h   |  2 +-
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 6b18c06..5a3e721 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2114,19 +2114,20 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname)
 }
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
-cmSourceGroup* cmMakefile::GetSourceGroup(const std::vector<std::string>&name)
+cmSourceGroup*
+cmMakefile::GetSourceGroup(const std::vector<std::string>&name) const
 {
   cmSourceGroup* sg = 0;
 
   // first look for source group starting with the same as the one we wants
-  for (std::vector<cmSourceGroup>::iterator sgIt = this->SourceGroups.begin();
-       sgIt != this->SourceGroups.end(); ++sgIt)
-
+  for (std::vector<cmSourceGroup>::const_iterator
+      sgIt = this->SourceGroups.begin();
+      sgIt != this->SourceGroups.end(); ++sgIt)
     {
     std::string sgName = sgIt->GetName();
     if(sgName == name[0])
       {
-      sg = &(*sgIt);
+      sg = const_cast<cmSourceGroup*>(&(*sgIt));
       break;
       }
     }
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index d6a845f..bf77e56 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -639,7 +639,7 @@ public:
   /**
    * Get the source group
    */
-  cmSourceGroup* GetSourceGroup(const std::vector<std::string>&name);
+  cmSourceGroup* GetSourceGroup(const std::vector<std::string>&name) const;
 #endif
 
   /**
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index f09976f..dc0848c 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -126,12 +126,12 @@ void cmSourceGroup::AddChild(cmSourceGroup child)
 }
 
 //----------------------------------------------------------------------------
-cmSourceGroup *cmSourceGroup::lookupChild(const char* name)
+cmSourceGroup *cmSourceGroup::lookupChild(const char* name) const
 {
   // initializing iterators
-  std::vector<cmSourceGroup>::iterator iter =
+  std::vector<cmSourceGroup>::const_iterator iter =
     this->Internal->GroupChildren.begin();
-  std::vector<cmSourceGroup>::iterator end =
+  const std::vector<cmSourceGroup>::const_iterator end =
     this->Internal->GroupChildren.end();
 
   // st
@@ -142,7 +142,7 @@ cmSourceGroup *cmSourceGroup::lookupChild(const char* name)
     // look if descenened is the one were looking for
     if(sgName == name)
       {
-      return &(*iter); // if it so return it
+      return const_cast<cmSourceGroup*>(&(*iter)); // if it so return it
       }
     }
 
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index 11a0c74..fd806da 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -56,7 +56,7 @@ public:
   /**
    * Looks up child and returns it
    */
-  cmSourceGroup *lookupChild(const char *name);
+  cmSourceGroup *lookupChild(const char *name) const;
 
   /**
    * Get the name of this group.
-- 
cgit v0.12