diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 9ae1cb9730890ddacce5a828807dd6cc49011e0f..97ef4812e29f3d5c4ca8b7a397a2c46c6aae8665 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -663,7 +663,7 @@ bool cmFindPackageCommand::FindModule(bool& found)
   module += this->Name;
   module += ".cmake";
   bool system = false;
-  std::string mfile = this->Makefile->GetModulesFile(module.c_str(), system);
+  std::string mfile = this->Makefile->GetModulesFile(module, system);
   if (!mfile.empty()) {
     if (system) {
       auto it = this->DeprecatedFindModules.find(this->Name);
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 2d36315652e930588df707b6f60f30ba2790cbb8..b2b0e3895365b64a7c04ac74b555eaeb56837bbd 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -353,8 +353,7 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
   }
   if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") ||
       cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
-    std::string setMakeProgram =
-      mf->GetModulesFile(this->FindMakeProgramFile.c_str());
+    std::string setMakeProgram = mf->GetModulesFile(this->FindMakeProgramFile);
     if (!setMakeProgram.empty()) {
       mf->ReadListFile(setMakeProgram);
     }
@@ -464,11 +463,10 @@ void cmGlobalGenerator::EnableLanguage(
 
   if (this->TryCompileOuterMakefile) {
     // In a try-compile we can only enable languages provided by caller.
-    for (std::string const& li : languages) {
-      if (li == "NONE") {
+    for (std::string const& lang : languages) {
+      if (lang == "NONE") {
         this->SetLanguageEnabled("NONE", mf);
       } else {
-        const char* lang = li.c_str();
         if (this->LanguagesReady.find(lang) == this->LanguagesReady.end()) {
           std::ostringstream e;
           e << "The test project needs language " << lang
@@ -616,10 +614,9 @@ void cmGlobalGenerator::EnableLanguage(
   // load the CMakeDetermine(LANG)Compiler.cmake file to find
   // the compiler
 
-  for (std::string const& l : languages) {
-    const char* lang = l.c_str();
+  for (std::string const& lang : languages) {
     needSetLanguageEnabledMaps[lang] = false;
-    if (l == "NONE") {
+    if (lang == "NONE") {
       this->SetLanguageEnabled("NONE", mf);
       continue;
     }
@@ -661,8 +658,7 @@ void cmGlobalGenerator::EnableLanguage(
       std::string determineCompiler = "CMakeDetermine";
       determineCompiler += lang;
       determineCompiler += "Compiler.cmake";
-      std::string determineFile =
-        mf->GetModulesFile(determineCompiler.c_str());
+      std::string determineFile = mf->GetModulesFile(determineCompiler);
       if (!mf->ReadListFile(determineFile)) {
         cmSystemTools::Error("Could not find cmake module file: ",
                              determineCompiler.c_str());
@@ -721,9 +717,8 @@ void cmGlobalGenerator::EnableLanguage(
   }
   // loop over languages again loading CMake(LANG)Information.cmake
   //
-  for (std::string const& l : languages) {
-    const char* lang = l.c_str();
-    if (l == "NONE") {
+  for (std::string const& lang : languages) {
+    if (lang == "NONE") {
       this->SetLanguageEnabled("NONE", mf);
       continue;
     }
@@ -744,7 +739,7 @@ void cmGlobalGenerator::EnableLanguage(
         "No " << compilerName << " could be found.\n"
         ;
       /* clang-format on */
-    } else if (strcmp(lang, "RC") != 0 && strcmp(lang, "ASM_MASM") != 0) {
+    } else if ((lang != "RC") && (lang != "ASM_MASM")) {
       if (!cmSystemTools::FileIsFullPath(compilerFile)) {
         /* clang-format off */
         noCompiler <<
@@ -790,7 +785,7 @@ void cmGlobalGenerator::EnableLanguage(
       fpath = "CMake";
       fpath += lang;
       fpath += "Information.cmake";
-      std::string informationFile = mf->GetModulesFile(fpath.c_str());
+      std::string informationFile = mf->GetModulesFile(fpath);
       if (informationFile.empty()) {
         cmSystemTools::Error("Could not find cmake module file: ",
                              fpath.c_str());
@@ -814,7 +809,7 @@ void cmGlobalGenerator::EnableLanguage(
         std::string testLang = "CMakeTest";
         testLang += lang;
         testLang += "Compiler.cmake";
-        std::string ifpath = mf->GetModulesFile(testLang.c_str());
+        std::string ifpath = mf->GetModulesFile(testLang);
         if (!mf->ReadListFile(ifpath)) {
           cmSystemTools::Error("Could not find cmake module file: ",
                                testLang.c_str());
@@ -2861,7 +2856,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
       if (strncmp(line.c_str(), rhi->second.Data, 32) != 0) {
         // The rule has changed.  Delete the output so it will be
         // built again.
-        fname = cmSystemTools::CollapseFullPath(fname, home.c_str());
+        fname = cmSystemTools::CollapseFullPath(fname, home);
         cmSystemTools::RemoveFile(fname);
       }
     } else {
@@ -2871,7 +2866,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
       // Instead, we keep the rule hash as long as the file exists so
       // that if the feature is turned back on and the rule has
       // changed the file is still rebuilt.
-      std::string fpath = cmSystemTools::CollapseFullPath(fname, home.c_str());
+      std::string fpath = cmSystemTools::CollapseFullPath(fname, home);
       if (cmSystemTools::FileExists(fpath)) {
         RuleHash hash;
         memcpy(hash.Data, line.c_str(), 32);
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index a67d09e46c2de56aab4c7c196bcd209dee02f6e7..0d608bb9d0baf2892acba660c995fff045f7f242 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -67,7 +67,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
     // Not a path. Maybe module.
     std::string module = fname;
     module += ".cmake";
-    std::string mfile = this->Makefile->GetModulesFile(module.c_str());
+    std::string mfile = this->Makefile->GetModulesFile(module);
     if (!mfile.empty()) {
       fname = mfile;
     }
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 97e684bda1133f59ba725ff613c9c4817e329beb..09537bbec1bdca55b7724f39f8b9b0ecd1d826e6 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2783,7 +2783,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
   const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
   std::string inFile = (in && *in) ? in : "MacOSXBundleInfo.plist.in";
   if (!cmSystemTools::FileIsFullPath(inFile)) {
-    std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
+    std::string inMod = this->Makefile->GetModulesFile(inFile);
     if (!inMod.empty()) {
       inFile = inMod;
     }
@@ -2821,7 +2821,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
   const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
   std::string inFile = (in && *in) ? in : "MacOSXFrameworkInfo.plist.in";
   if (!cmSystemTools::FileIsFullPath(inFile)) {
-    std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
+    std::string inMod = this->Makefile->GetModulesFile(inFile);
     if (!inMod.empty()) {
       inFile = inMod;
     }
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 9589b7f23623f49ae58183891a957b7a696dff26..500776e9a8c7b7ec21b614473846c3559d533e27 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3516,7 +3516,7 @@ void cmMakefile::DisplayStatus(const char* message, float s) const
   cm->UpdateProgress(message, s);
 }
 
-std::string cmMakefile::GetModulesFile(const char* filename,
+std::string cmMakefile::GetModulesFile(const std::string& filename,
                                        bool& system) const
 {
   std::string result;
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index abe2cd1ac68c25d9bfc3e556ba2a72e6acc46fa2..e88bb0b2dcf2f78164203f9bc56fdb4a5e7db383 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -689,13 +689,13 @@ public:
   /**
    * Return a location of a file in cmake or custom modules directory
    */
-  std::string GetModulesFile(const char* name) const
+  std::string GetModulesFile(const std::string& name) const
   {
     bool system;
     return this->GetModulesFile(name, system);
   }
 
-  std::string GetModulesFile(const char* name, bool& system) const;
+  std::string GetModulesFile(const std::string& name, bool& system) const;
 
   ///! Set/Get a property of this directory
   void SetProperty(const std::string& prop, const char* value);