浏览代码

Constify some code as suggested by clang-tidy

Cengizhan Pasaoglu 5 年之前
父节点
当前提交
bd705788f6

+ 1 - 1
Source/cmFindCommon.cxx

@@ -182,7 +182,7 @@ void cmFindCommon::SelectDefaultSearchModes()
       { this->NoCMakeSystemPath, "CMAKE_FIND_USE_CMAKE_SYSTEM_PATH" } }
       { this->NoCMakeSystemPath, "CMAKE_FIND_USE_CMAKE_SYSTEM_PATH" } }
   };
   };
 
 
-  for (auto& path : search_paths) {
+  for (auto const& path : search_paths) {
     cmProp def = this->Makefile->GetDefinition(path.second);
     cmProp def = this->Makefile->GetDefinition(path.second);
     if (def) {
     if (def) {
       path.first = !cmIsOn(*def);
       path.first = !cmIsOn(*def);

+ 1 - 1
Source/cmGeneratorExpressionEvaluator.h

@@ -60,7 +60,7 @@ struct TextContent : public cmGeneratorExpressionEvaluator
 
 
   void Extend(size_t length) { this->Length += length; }
   void Extend(size_t length) { this->Length += length; }
 
 
-  size_t GetLength() { return this->Length; }
+  size_t GetLength() const { return this->Length; }
 
 
 private:
 private:
   const char* Content;
   const char* Content;

+ 7 - 7
Source/cmGeneratorExpressionNode.cxx

@@ -677,7 +677,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
     }
     }
     static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
     static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
 
 
-    for (auto& param : parameters) {
+    for (auto const& param : parameters) {
 
 
       if (!compilerIdValidator.find(param)) {
       if (!compilerIdValidator.find(param)) {
         reportError(context, content->GetOriginalExpression(),
         reportError(context, content->GetOriginalExpression(),
@@ -805,7 +805,7 @@ struct PlatformIdNode : public cmGeneratorExpressionNode
       return parameters.front().empty() ? "1" : "0";
       return parameters.front().empty() ? "1" : "0";
     }
     }
 
 
-    for (auto& param : parameters) {
+    for (auto const& param : parameters) {
       if (param == platformId) {
       if (param == platformId) {
         return "1";
         return "1";
       }
       }
@@ -901,7 +901,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
       return std::string();
       return std::string();
     }
     }
     context->HadContextSensitiveCondition = true;
     context->HadContextSensitiveCondition = true;
-    for (auto& param : parameters) {
+    for (auto const& param : parameters) {
       if (context->Config.empty()) {
       if (context->Config.empty()) {
         if (param.empty()) {
         if (param.empty()) {
           return "1";
           return "1";
@@ -927,7 +927,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
         if (cmProp mapValue = context->CurrentTarget->GetProperty(mapProp)) {
         if (cmProp mapValue = context->CurrentTarget->GetProperty(mapProp)) {
           cmExpandList(cmSystemTools::UpperCase(*mapValue), mappedConfigs);
           cmExpandList(cmSystemTools::UpperCase(*mapValue), mappedConfigs);
 
 
-          for (auto& param : parameters) {
+          for (auto const& param : parameters) {
             if (cm::contains(mappedConfigs, cmSystemTools::UpperCase(param))) {
             if (cm::contains(mappedConfigs, cmSystemTools::UpperCase(param))) {
               return "1";
               return "1";
             }
             }
@@ -995,7 +995,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
       return context->Language;
       return context->Language;
     }
     }
 
 
-    for (auto& param : parameters) {
+    for (auto const& param : parameters) {
       if (context->Language == param) {
       if (context->Language == param) {
         return "1";
         return "1";
       }
       }
@@ -1101,7 +1101,7 @@ static const struct LinkLanguageNode : public cmGeneratorExpressionNode
       return context->Language;
       return context->Language;
     }
     }
 
 
-    for (auto& param : parameters) {
+    for (auto const& param : parameters) {
       if (context->Language == param) {
       if (context->Language == param) {
         return "1";
         return "1";
       }
       }
@@ -1129,7 +1129,7 @@ struct LinkerId
     }
     }
     static cmsys::RegularExpression linkerIdValidator("^[A-Za-z0-9_]*$");
     static cmsys::RegularExpression linkerIdValidator("^[A-Za-z0-9_]*$");
 
 
-    for (auto& param : parameters) {
+    for (auto const& param : parameters) {
       if (!linkerIdValidator.find(param)) {
       if (!linkerIdValidator.find(param)) {
         reportError(context, content->GetOriginalExpression(),
         reportError(context, content->GetOriginalExpression(),
                     "Expression syntax not recognized.");
                     "Expression syntax not recognized.");

+ 3 - 3
Source/cmGeneratorTarget.cxx

@@ -254,7 +254,7 @@ EvaluatedTargetPropertyEntries EvaluateTargetPropertyEntries(
 {
 {
   EvaluatedTargetPropertyEntries out;
   EvaluatedTargetPropertyEntries out;
   out.Entries.reserve(in.size());
   out.Entries.reserve(in.size());
-  for (auto& entry : in) {
+  for (auto const& entry : in) {
     out.Entries.emplace_back(EvaluateTargetPropertyEntry(
     out.Entries.emplace_back(EvaluateTargetPropertyEntry(
       thisTarget, config, lang, dagChecker, *entry));
       thisTarget, config, lang, dagChecker, *entry));
   }
   }
@@ -332,7 +332,7 @@ cmGeneratorTarget::~cmGeneratorTarget() = default;
 const std::string& cmGeneratorTarget::GetSourcesProperty() const
 const std::string& cmGeneratorTarget::GetSourcesProperty() const
 {
 {
   std::vector<std::string> values;
   std::vector<std::string> values;
-  for (auto& se : this->SourceEntries) {
+  for (auto const& se : this->SourceEntries) {
     values.push_back(se->GetInput());
     values.push_back(se->GetInput());
   }
   }
   static std::string value;
   static std::string value;
@@ -2504,7 +2504,7 @@ public:
     }
     }
   }
   }
 
 
-  bool GetHadLinkLanguageSensitiveCondition()
+  bool GetHadLinkLanguageSensitiveCondition() const
   {
   {
     return HadLinkLanguageSensitiveCondition;
     return HadLinkLanguageSensitiveCondition;
   }
   }

+ 3 - 3
Source/cmGlobalGenerator.cxx

@@ -2601,7 +2601,7 @@ void cmGlobalGenerator::AddGlobalTarget_Test(
 }
 }
 
 
 void cmGlobalGenerator::AddGlobalTarget_EditCache(
 void cmGlobalGenerator::AddGlobalTarget_EditCache(
-  std::vector<GlobalTargetInfo>& targets)
+  std::vector<GlobalTargetInfo>& targets) const
 {
 {
   const char* editCacheTargetName = this->GetEditCacheTargetName();
   const char* editCacheTargetName = this->GetEditCacheTargetName();
   if (!editCacheTargetName) {
   if (!editCacheTargetName) {
@@ -2635,7 +2635,7 @@ void cmGlobalGenerator::AddGlobalTarget_EditCache(
 }
 }
 
 
 void cmGlobalGenerator::AddGlobalTarget_RebuildCache(
 void cmGlobalGenerator::AddGlobalTarget_RebuildCache(
-  std::vector<GlobalTargetInfo>& targets)
+  std::vector<GlobalTargetInfo>& targets) const
 {
 {
   const char* rebuildCacheTargetName = this->GetRebuildCacheTargetName();
   const char* rebuildCacheTargetName = this->GetRebuildCacheTargetName();
   if (!rebuildCacheTargetName) {
   if (!rebuildCacheTargetName) {
@@ -2758,7 +2758,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install(
   }
   }
 }
 }
 
 
-std::string cmGlobalGenerator::GetPredefinedTargetsFolder()
+std::string cmGlobalGenerator::GetPredefinedTargetsFolder() const
 {
 {
   cmProp prop = this->GetCMakeInstance()->GetState()->GetGlobalProperty(
   cmProp prop = this->GetCMakeInstance()->GetState()->GetGlobalProperty(
     "PREDEFINED_TARGETS_FOLDER");
     "PREDEFINED_TARGETS_FOLDER");

+ 4 - 3
Source/cmGlobalGenerator.h

@@ -574,8 +574,9 @@ protected:
   void AddGlobalTarget_Package(std::vector<GlobalTargetInfo>& targets);
   void AddGlobalTarget_Package(std::vector<GlobalTargetInfo>& targets);
   void AddGlobalTarget_PackageSource(std::vector<GlobalTargetInfo>& targets);
   void AddGlobalTarget_PackageSource(std::vector<GlobalTargetInfo>& targets);
   void AddGlobalTarget_Test(std::vector<GlobalTargetInfo>& targets);
   void AddGlobalTarget_Test(std::vector<GlobalTargetInfo>& targets);
-  void AddGlobalTarget_EditCache(std::vector<GlobalTargetInfo>& targets);
-  void AddGlobalTarget_RebuildCache(std::vector<GlobalTargetInfo>& targets);
+  void AddGlobalTarget_EditCache(std::vector<GlobalTargetInfo>& targets) const;
+  void AddGlobalTarget_RebuildCache(
+    std::vector<GlobalTargetInfo>& targets) const;
   void AddGlobalTarget_Install(std::vector<GlobalTargetInfo>& targets);
   void AddGlobalTarget_Install(std::vector<GlobalTargetInfo>& targets);
   cmTarget CreateGlobalTarget(GlobalTargetInfo const& gti, cmMakefile* mf);
   cmTarget CreateGlobalTarget(GlobalTargetInfo const& gti, cmMakefile* mf);
 
 
@@ -601,7 +602,7 @@ protected:
 
 
   cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
   cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
 
 
-  std::string GetPredefinedTargetsFolder();
+  std::string GetPredefinedTargetsFolder() const;
 
 
 private:
 private:
   using TargetMap = std::unordered_map<std::string, cmTarget*>;
   using TargetMap = std::unordered_map<std::string, cmTarget*>;

+ 2 - 2
Source/cmGlobalGhsMultiGenerator.cxx

@@ -704,7 +704,7 @@ bool cmGlobalGhsMultiGenerator::ComputeTargetBuildOrder(
   std::set<cmGeneratorTarget const*> temp;
   std::set<cmGeneratorTarget const*> temp;
   std::set<cmGeneratorTarget const*> perm;
   std::set<cmGeneratorTarget const*> perm;
 
 
-  for (auto ti : tgt) {
+  for (auto const ti : tgt) {
     bool r = VisitTarget(temp, perm, build, ti);
     bool r = VisitTarget(temp, perm, build, ti);
     if (r) {
     if (r) {
       return r;
       return r;
@@ -726,7 +726,7 @@ bool cmGlobalGhsMultiGenerator::VisitTarget(
        * in the same order */
        * in the same order */
       OrderedTargetDependSet sortedTargets(this->GetTargetDirectDepends(ti),
       OrderedTargetDependSet sortedTargets(this->GetTargetDirectDepends(ti),
                                            "");
                                            "");
-      for (auto& di : sortedTargets) {
+      for (auto const& di : sortedTargets) {
         if (this->VisitTarget(temp, perm, order, di)) {
         if (this->VisitTarget(temp, perm, order, di)) {
           return true;
           return true;
         }
         }

+ 2 - 2
Source/cmGlobalNinjaGenerator.cxx

@@ -1057,7 +1057,7 @@ void cmGlobalNinjaGenerator::CloseCompileCommandsStream()
   }
   }
 }
 }
 
 
-void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os)
+void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os) const
 {
 {
   os << "# CMAKE generated file: DO NOT EDIT!\n"
   os << "# CMAKE generated file: DO NOT EDIT!\n"
      << "# Generated by \"" << this->GetName() << "\""
      << "# Generated by \"" << this->GetName() << "\""
@@ -1088,7 +1088,7 @@ std::string cmGlobalNinjaGenerator::OrderDependsTargetForTarget(
 
 
 void cmGlobalNinjaGenerator::AppendTargetOutputs(
 void cmGlobalNinjaGenerator::AppendTargetOutputs(
   cmGeneratorTarget const* target, cmNinjaDeps& outputs,
   cmGeneratorTarget const* target, cmNinjaDeps& outputs,
-  const std::string& config, cmNinjaTargetDepends depends)
+  const std::string& config, cmNinjaTargetDepends depends) const
 {
 {
   // for frameworks, we want the real name, not smple name
   // for frameworks, we want the real name, not smple name
   // frameworks always appear versioned, and the build.ninja
   // frameworks always appear versioned, and the build.ninja

+ 3 - 3
Source/cmGlobalNinjaGenerator.h

@@ -252,7 +252,7 @@ public:
       : GG(gg)
       : GG(gg)
     {
     {
     }
     }
-    std::string operator()(std::string const& path)
+    std::string operator()(std::string const& path) const
     {
     {
       return this->GG->ConvertToNinjaPath(path);
       return this->GG->ConvertToNinjaPath(path);
     }
     }
@@ -323,7 +323,7 @@ public:
 
 
   void AppendTargetOutputs(cmGeneratorTarget const* target,
   void AppendTargetOutputs(cmGeneratorTarget const* target,
                            cmNinjaDeps& outputs, const std::string& config,
                            cmNinjaDeps& outputs, const std::string& config,
-                           cmNinjaTargetDepends depends);
+                           cmNinjaTargetDepends depends) const;
   void AppendTargetDepends(cmGeneratorTarget const* target,
   void AppendTargetDepends(cmGeneratorTarget const* target,
                            cmNinjaDeps& outputs, const std::string& config,
                            cmNinjaDeps& outputs, const std::string& config,
                            const std::string& fileConfig,
                            const std::string& fileConfig,
@@ -463,7 +463,7 @@ private:
   void CleanMetaData();
   void CleanMetaData();
 
 
   /// Write the common disclaimer text at the top of each build file.
   /// Write the common disclaimer text at the top of each build file.
-  void WriteDisclaimer(std::ostream& os);
+  void WriteDisclaimer(std::ostream& os) const;
 
 
   void WriteAssumedSourceDependencies();
   void WriteAssumedSourceDependencies();
 
 

+ 2 - 2
Source/cmLocalGenerator.cxx

@@ -279,7 +279,7 @@ static void MoveSystemIncludesToEnd(std::vector<BT<std::string>>& includeDirs,
                    });
                    });
 }
 }
 
 
-void cmLocalGenerator::TraceDependencies()
+void cmLocalGenerator::TraceDependencies() const
 {
 {
   // Generate the rule files for each target.
   // Generate the rule files for each target.
   const auto& targets = this->GetGeneratorTargets();
   const auto& targets = this->GetGeneratorTargets();
@@ -3210,7 +3210,7 @@ std::string cmLocalGenerator::GetProjectName() const
 }
 }
 
 
 std::string cmLocalGenerator::ConstructComment(
 std::string cmLocalGenerator::ConstructComment(
-  cmCustomCommandGenerator const& ccg, const char* default_comment)
+  cmCustomCommandGenerator const& ccg, const char* default_comment) const
 {
 {
   // Check for a comment provided with the command.
   // Check for a comment provided with the command.
   if (ccg.GetComment()) {
   if (ccg.GetComment()) {

+ 2 - 2
Source/cmLocalGenerator.h

@@ -77,7 +77,7 @@ public:
   /**
   /**
    * Calls TraceVSDependencies() on all targets of this generator.
    * Calls TraceVSDependencies() on all targets of this generator.
    */
    */
-  void TraceDependencies();
+  void TraceDependencies() const;
 
 
   virtual void AddHelperCommands() {}
   virtual void AddHelperCommands() {}
 
 
@@ -451,7 +451,7 @@ public:
                                   const std::string& fname);
                                   const std::string& fname);
   /** Construct a comment for a custom command.  */
   /** Construct a comment for a custom command.  */
   std::string ConstructComment(cmCustomCommandGenerator const& ccg,
   std::string ConstructComment(cmCustomCommandGenerator const& ccg,
-                               const char* default_comment = "");
+                               const char* default_comment = "") const;
   // Compute object file names.
   // Compute object file names.
   std::string GetObjectFileNameWithoutTarget(
   std::string GetObjectFileNameWithoutTarget(
     const cmSourceFile& source, std::string const& dir_max,
     const cmSourceFile& source, std::string const& dir_max,

+ 2 - 2
Source/cmLocalUnixMakefileGenerator3.h

@@ -178,11 +178,11 @@ public:
   /** Get whether to create rules to generate preprocessed and
   /** Get whether to create rules to generate preprocessed and
       assembly sources.  This could be converted to a variable lookup
       assembly sources.  This could be converted to a variable lookup
       later.  */
       later.  */
-  bool GetCreatePreprocessedSourceRules()
+  bool GetCreatePreprocessedSourceRules() const
   {
   {
     return !this->SkipPreprocessedSourceRules;
     return !this->SkipPreprocessedSourceRules;
   }
   }
-  bool GetCreateAssemblySourceRules()
+  bool GetCreateAssemblySourceRules() const
   {
   {
     return !this->SkipAssemblySourceRules;
     return !this->SkipAssemblySourceRules;
   }
   }

+ 5 - 5
Source/cmMakefile.cxx

@@ -2029,7 +2029,7 @@ void cmMakefile::RemoveDefinition(const std::string& name)
 #endif
 #endif
 }
 }
 
 
-void cmMakefile::RemoveCacheDefinition(const std::string& name)
+void cmMakefile::RemoveCacheDefinition(const std::string& name) const
 {
 {
   this->GetState()->RemoveCacheEntry(name);
   this->GetState()->RemoveCacheEntry(name);
 }
 }
@@ -2839,7 +2839,7 @@ void cmMakefile::SetRecursionDepth(int recursionDepth)
   this->RecursionDepth = recursionDepth;
   this->RecursionDepth = recursionDepth;
 }
 }
 
 
-std::string cmMakefile::NewDeferId()
+std::string cmMakefile::NewDeferId() const
 {
 {
   return this->GetGlobalGenerator()->NewDeferId();
   return this->GetGlobalGenerator()->NewDeferId();
 }
 }
@@ -4039,7 +4039,7 @@ cmTest* cmMakefile::GetTest(const std::string& testName) const
 }
 }
 
 
 void cmMakefile::GetTests(const std::string& config,
 void cmMakefile::GetTests(const std::string& config,
-                          std::vector<cmTest*>& tests)
+                          std::vector<cmTest*>& tests) const
 {
 {
   for (const auto& generator : this->GetTestGenerators()) {
   for (const auto& generator : this->GetTestGenerators()) {
     if (generator->TestsForConfig(config)) {
     if (generator->TestsForConfig(config)) {
@@ -4389,7 +4389,7 @@ cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id,
   return this->StateSnapshot.GetPolicy(id, parent_scope);
   return this->StateSnapshot.GetPolicy(id, parent_scope);
 }
 }
 
 
-bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var)
+bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var) const
 {
 {
   // Check for an explicit CMAKE_POLICY_WARNING_CMP<NNNN> setting.
   // Check for an explicit CMAKE_POLICY_WARNING_CMP<NNNN> setting.
   if (cmProp val = this->GetDefinition(var)) {
   if (cmProp val = this->GetDefinition(var)) {
@@ -4494,7 +4494,7 @@ bool cmMakefile::HasCMP0054AlreadyBeenReported(
   return !this->CMP0054ReportedIds.insert(context).second;
   return !this->CMP0054ReportedIds.insert(context).second;
 }
 }
 
 
-void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm)
+void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm) const
 {
 {
   /* Record the setting of every policy.  */
   /* Record the setting of every policy.  */
   using PolicyID = cmPolicies::PolicyID;
   using PolicyID = cmPolicies::PolicyID;

+ 5 - 5
Source/cmMakefile.h

@@ -304,7 +304,7 @@ public:
    */
    */
   void RemoveDefinition(const std::string& name);
   void RemoveDefinition(const std::string& name);
   //! Remove a definition from the cache.
   //! Remove a definition from the cache.
-  void RemoveCacheDefinition(const std::string& name);
+  void RemoveCacheDefinition(const std::string& name) const;
 
 
   /**
   /**
    * Specify the name of the project for this build.
    * Specify the name of the project for this build.
@@ -345,7 +345,7 @@ public:
                                            bool parent_scope = false) const;
                                            bool parent_scope = false) const;
   bool SetPolicyVersion(std::string const& version_min,
   bool SetPolicyVersion(std::string const& version_min,
                         std::string const& version_max);
                         std::string const& version_max);
-  void RecordPolicies(cmPolicies::PolicyMap& pm);
+  void RecordPolicies(cmPolicies::PolicyMap& pm) const;
   //@}
   //@}
 
 
   /** Helper class to push and pop policies automatically.  */
   /** Helper class to push and pop policies automatically.  */
@@ -738,7 +738,7 @@ public:
   /**
   /**
    * Get all tests that run under the given configuration.
    * Get all tests that run under the given configuration.
    */
    */
-  void GetTests(const std::string& config, std::vector<cmTest*>& tests);
+  void GetTests(const std::string& config, std::vector<cmTest*>& tests) const;
 
 
   /**
   /**
    * Return a location of a file in cmake or custom modules directory
    * Return a location of a file in cmake or custom modules directory
@@ -885,7 +885,7 @@ public:
     return this->SystemIncludeDirectories;
     return this->SystemIncludeDirectories;
   }
   }
 
 
-  bool PolicyOptionalWarningEnabled(std::string const& var);
+  bool PolicyOptionalWarningEnabled(std::string const& var) const;
 
 
   void PushLoopBlock();
   void PushLoopBlock();
   void PopLoopBlock();
   void PopLoopBlock();
@@ -926,7 +926,7 @@ public:
   int GetRecursionDepth() const;
   int GetRecursionDepth() const;
   void SetRecursionDepth(int recursionDepth);
   void SetRecursionDepth(int recursionDepth);
 
 
-  std::string NewDeferId();
+  std::string NewDeferId() const;
   bool DeferCall(std::string id, std::string fileName, cmListFileFunction lff);
   bool DeferCall(std::string id, std::string fileName, cmListFileFunction lff);
   bool DeferCancelCall(std::string const& id);
   bool DeferCancelCall(std::string const& id);
   cm::optional<std::string> DeferGetCallIds() const;
   cm::optional<std::string> DeferGetCallIds() const;

+ 2 - 2
Source/cmQtAutoGen.h

@@ -29,13 +29,13 @@ public:
     {
     {
     }
     }
 
 
-    bool operator>(IntegerVersion const version)
+    bool operator>(IntegerVersion const version) const
     {
     {
       return (this->Major > version.Major) ||
       return (this->Major > version.Major) ||
         ((this->Major == version.Major) && (this->Minor > version.Minor));
         ((this->Major == version.Major) && (this->Minor > version.Minor));
     }
     }
 
 
-    bool operator>=(IntegerVersion const version)
+    bool operator>=(IntegerVersion const version) const
     {
     {
       return (this->Major > version.Major) ||
       return (this->Major > version.Major) ||
         ((this->Major == version.Major) && (this->Minor >= version.Minor));
         ((this->Major == version.Major) && (this->Minor >= version.Minor));

+ 5 - 4
Source/cmTarget.cxx

@@ -213,7 +213,7 @@ public:
   bool CheckImportedLibName(std::string const& prop,
   bool CheckImportedLibName(std::string const& prop,
                             std::string const& value) const;
                             std::string const& value) const;
 
 
-  std::string ProcessSourceItemCMP0049(const std::string& s);
+  std::string ProcessSourceItemCMP0049(const std::string& s) const;
 };
 };
 
 
 namespace {
 namespace {
@@ -740,7 +740,8 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
   }
   }
 }
 }
 
 
-std::string cmTargetInternals::ProcessSourceItemCMP0049(const std::string& s)
+std::string cmTargetInternals::ProcessSourceItemCMP0049(
+  const std::string& s) const
 {
 {
   std::string src = s;
   std::string src = s;
 
 
@@ -791,7 +792,7 @@ struct CreateLocation
   {
   {
   }
   }
 
 
-  cmSourceFileLocation operator()(const std::string& filename)
+  cmSourceFileLocation operator()(const std::string& filename) const
   {
   {
     return cmSourceFileLocation(this->Makefile, filename);
     return cmSourceFileLocation(this->Makefile, filename);
   }
   }
@@ -857,7 +858,7 @@ cmSourceFile* cmTarget::AddSource(const std::string& src, bool before)
                                            cmSourceFileLocationKind::Known);
                                            cmSourceFileLocationKind::Known);
 }
 }
 
 
-void cmTarget::ClearDependencyInformation(cmMakefile& mf)
+void cmTarget::ClearDependencyInformation(cmMakefile& mf) const
 {
 {
   std::string depname = cmStrCat(this->GetName(), "_LIB_DEPENDS");
   std::string depname = cmStrCat(this->GetName(), "_LIB_DEPENDS");
   mf.RemoveCacheDefinition(depname);
   mf.RemoveCacheDefinition(depname);

+ 1 - 1
Source/cmTarget.h

@@ -114,7 +114,7 @@ public:
   LinkLibraryVectorType const& GetOriginalLinkLibraries() const;
   LinkLibraryVectorType const& GetOriginalLinkLibraries() const;
 
 
   //! Clear the dependency information recorded for this target, if any.
   //! Clear the dependency information recorded for this target, if any.
-  void ClearDependencyInformation(cmMakefile& mf);
+  void ClearDependencyInformation(cmMakefile& mf) const;
 
 
   void AddLinkLibrary(cmMakefile& mf, std::string const& lib,
   void AddLinkLibrary(cmMakefile& mf, std::string const& lib,
                       cmTargetLinkLibraryType llt);
                       cmTargetLinkLibraryType llt);

+ 3 - 3
Source/cmake.cxx

@@ -1938,7 +1938,7 @@ int cmake::ActualConfigure()
     }
     }
   }
   }
 
 
-  auto& mf = this->GlobalGenerator->GetMakefiles()[0];
+  const auto& mf = this->GlobalGenerator->GetMakefiles()[0];
   if (mf->IsOn("CTEST_USE_LAUNCHERS") &&
   if (mf->IsOn("CTEST_USE_LAUNCHERS") &&
       !this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE")) {
       !this->State->GetGlobalProperty("RULE_LAUNCH_COMPILE")) {
     cmSystemTools::Error(
     cmSystemTools::Error(
@@ -2280,12 +2280,12 @@ cmProp cmake::GetCacheDefinition(const std::string& name) const
   return this->State->GetInitializedCacheValue(name);
   return this->State->GetInitializedCacheValue(name);
 }
 }
 
 
-void cmake::AddScriptingCommands()
+void cmake::AddScriptingCommands() const
 {
 {
   GetScriptingCommands(this->GetState());
   GetScriptingCommands(this->GetState());
 }
 }
 
 
-void cmake::AddProjectCommands()
+void cmake::AddProjectCommands() const
 {
 {
   GetProjectCommands(this->GetState());
   GetProjectCommands(this->GetState());
 }
 }

+ 8 - 8
Source/cmake.h

@@ -411,7 +411,7 @@ public:
   WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; }
   WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; }
 
 
   //! Debug the try compile stuff by not deleting the files
   //! Debug the try compile stuff by not deleting the files
-  bool GetDebugTryCompile() { return this->DebugTryCompile; }
+  bool GetDebugTryCompile() const { return this->DebugTryCompile; }
   void DebugTryCompileOn() { this->DebugTryCompile = true; }
   void DebugTryCompileOn() { this->DebugTryCompile = true; }
 
 
   /**
   /**
@@ -456,11 +456,11 @@ public:
   void SetShowLogContext(bool b) { this->LogContext = b; }
   void SetShowLogContext(bool b) { this->LogContext = b; }
 
 
   //! Do we want debug output during the cmake run.
   //! Do we want debug output during the cmake run.
-  bool GetDebugOutput() { return this->DebugOutput; }
+  bool GetDebugOutput() const { return this->DebugOutput; }
   void SetDebugOutputOn(bool b) { this->DebugOutput = b; }
   void SetDebugOutputOn(bool b) { this->DebugOutput = b; }
 
 
   //! Do we want debug output from the find commands during the cmake run.
   //! Do we want debug output from the find commands during the cmake run.
-  bool GetDebugFindOutput() { return this->DebugFindOutput; }
+  bool GetDebugFindOutput() const { return this->DebugFindOutput; }
   void SetDebugFindOutputOn(bool b) { this->DebugFindOutput = b; }
   void SetDebugFindOutputOn(bool b) { this->DebugFindOutput = b; }
 
 
   //! Do we want trace output during the cmake run.
   //! Do we want trace output during the cmake run.
@@ -482,11 +482,11 @@ public:
   void SetTraceFile(std::string const& file);
   void SetTraceFile(std::string const& file);
   void PrintTraceFormatVersion();
   void PrintTraceFormatVersion();
 
 
-  bool GetWarnUninitialized() { return this->WarnUninitialized; }
+  bool GetWarnUninitialized() const { return this->WarnUninitialized; }
   void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
   void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
-  bool GetWarnUnusedCli() { return this->WarnUnusedCli; }
+  bool GetWarnUnusedCli() const { return this->WarnUnusedCli; }
   void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b; }
   void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b; }
-  bool GetCheckSystemVars() { return this->CheckSystemVars; }
+  bool GetCheckSystemVars() const { return this->CheckSystemVars; }
   void SetCheckSystemVars(bool b) { this->CheckSystemVars = b; }
   void SetCheckSystemVars(bool b) { this->CheckSystemVars = b; }
 
 
   void MarkCliAsUsed(const std::string& variable);
   void MarkCliAsUsed(const std::string& variable);
@@ -591,8 +591,8 @@ protected:
   using RegisteredExtraGeneratorsVector =
   using RegisteredExtraGeneratorsVector =
     std::vector<cmExternalMakefileProjectGeneratorFactory*>;
     std::vector<cmExternalMakefileProjectGeneratorFactory*>;
   RegisteredExtraGeneratorsVector ExtraGenerators;
   RegisteredExtraGeneratorsVector ExtraGenerators;
-  void AddScriptingCommands();
-  void AddProjectCommands();
+  void AddScriptingCommands() const;
+  void AddProjectCommands() const;
   void AddDefaultGenerators();
   void AddDefaultGenerators();
   void AddDefaultExtraGenerators();
   void AddDefaultExtraGenerators();