Browse Source

Reduce raw string pointers usage.

* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
Pavel Solodovnikov 8 years ago
parent
commit
653b894683
100 changed files with 400 additions and 435 deletions
  1. 1 2
      Source/CPack/cmCPackArchiveGenerator.cxx
  2. 6 8
      Source/CPack/cmCPackGenerator.cxx
  3. 5 7
      Source/CPack/cmCPackNSISGenerator.cxx
  4. 1 1
      Source/CPack/cpack.cxx
  5. 3 3
      Source/CTest/cmCTestBuildAndTestHandler.cxx
  6. 1 1
      Source/CTest/cmCTestBuildHandler.cxx
  7. 1 1
      Source/CTest/cmCTestConfigureCommand.cxx
  8. 10 10
      Source/CTest/cmCTestCoverageHandler.cxx
  9. 6 6
      Source/CTest/cmCTestGIT.cxx
  10. 4 6
      Source/CTest/cmCTestLaunch.cxx
  11. 10 14
      Source/CTest/cmCTestMemCheckHandler.cxx
  12. 4 4
      Source/CTest/cmCTestMultiProcessHandler.cxx
  13. 2 2
      Source/CTest/cmCTestRunTest.cxx
  14. 10 10
      Source/CTest/cmCTestScriptHandler.cxx
  15. 1 1
      Source/CTest/cmCTestSubmitCommand.cxx
  16. 6 6
      Source/CTest/cmCTestSubmitHandler.cxx
  17. 6 6
      Source/CTest/cmCTestTestHandler.cxx
  18. 7 7
      Source/CTest/cmCTestUpdateHandler.cxx
  19. 1 1
      Source/CTest/cmCTestUploadCommand.cxx
  20. 1 1
      Source/CTest/cmCTestVC.cxx
  21. 1 1
      Source/CTest/cmParseCoberturaCoverage.cxx
  22. 1 1
      Source/cmAddCompileOptionsCommand.cxx
  23. 3 3
      Source/cmAddCustomCommandCommand.cxx
  24. 1 1
      Source/cmAddCustomTargetCommand.cxx
  25. 1 1
      Source/cmAddDefinitionsCommand.cxx
  26. 1 1
      Source/cmAddExecutableCommand.cxx
  27. 1 1
      Source/cmAddLibraryCommand.cxx
  28. 2 2
      Source/cmAddSubDirectoryCommand.cxx
  29. 1 1
      Source/cmAuxSourceDirectoryCommand.cxx
  30. 2 2
      Source/cmCPluginAPI.cxx
  31. 18 20
      Source/cmCTest.cxx
  32. 3 3
      Source/cmCacheManager.cxx
  33. 6 5
      Source/cmComputeLinkInformation.cxx
  34. 1 1
      Source/cmConditionEvaluator.cxx
  35. 1 1
      Source/cmConfigureFileCommand.cxx
  36. 9 11
      Source/cmCoreTryCompile.cxx
  37. 1 1
      Source/cmCoreTryCompile.h
  38. 1 1
      Source/cmCustomCommandGenerator.cxx
  39. 10 13
      Source/cmDependsC.cxx
  40. 10 10
      Source/cmDependsFortran.cxx
  41. 2 2
      Source/cmExecProgramCommand.cxx
  42. 1 1
      Source/cmExecuteProcessCommand.cxx
  43. 1 2
      Source/cmExportBuildAndroidMKGenerator.cxx
  44. 4 4
      Source/cmExportCommand.cxx
  45. 12 10
      Source/cmExportFileGenerator.cxx
  46. 7 7
      Source/cmExportInstallFileGenerator.cxx
  47. 6 8
      Source/cmExtraCodeBlocksGenerator.cxx
  48. 8 11
      Source/cmExtraCodeLiteGenerator.cxx
  49. 8 8
      Source/cmExtraKateGenerator.cxx
  50. 2 1
      Source/cmExtraKateGenerator.h
  51. 1 2
      Source/cmExtraSublimeTextGenerator.cxx
  52. 21 23
      Source/cmFileCommand.cxx
  53. 1 1
      Source/cmFindLibraryCommand.cxx
  54. 6 7
      Source/cmFindPackageCommand.cxx
  55. 2 2
      Source/cmFindPathCommand.cxx
  56. 3 3
      Source/cmFortranParserImpl.cxx
  57. 1 1
      Source/cmGeneratedFileStream.cxx
  58. 1 1
      Source/cmGeneratorExpression.cxx
  59. 1 2
      Source/cmGeneratorExpressionNode.cxx
  60. 5 5
      Source/cmGeneratorTarget.cxx
  61. 1 1
      Source/cmGetDirectoryPropertyCommand.cxx
  62. 1 1
      Source/cmGetPropertyCommand.cxx
  63. 1 1
      Source/cmGhsMultiTargetGenerator.cxx
  64. 10 10
      Source/cmGlobalGenerator.cxx
  65. 2 2
      Source/cmGlobalGhsMultiGenerator.cxx
  66. 2 2
      Source/cmGlobalNinjaGenerator.cxx
  67. 3 4
      Source/cmGlobalUnixMakefileGenerator3.cxx
  68. 1 1
      Source/cmGlobalVisualStudioGenerator.cxx
  69. 2 1
      Source/cmGlobalXCodeGenerator.cxx
  70. 1 1
      Source/cmGlobalXCodeGenerator.h
  71. 2 2
      Source/cmIncludeCommand.cxx
  72. 1 1
      Source/cmIncludeDirectoryCommand.cxx
  73. 4 4
      Source/cmInstallCommand.cxx
  74. 1 1
      Source/cmInstallDirectoryGenerator.cxx
  75. 1 1
      Source/cmInstallExportGenerator.cxx
  76. 2 2
      Source/cmInstallFilesCommand.cxx
  77. 2 2
      Source/cmInstallGenerator.cxx
  78. 2 2
      Source/cmInstallProgramsCommand.cxx
  79. 1 1
      Source/cmLinkDirectoriesCommand.cxx
  80. 1 1
      Source/cmLoadCacheCommand.cxx
  81. 14 14
      Source/cmLocalGenerator.cxx
  82. 2 2
      Source/cmLocalGenerator.h
  83. 9 10
      Source/cmLocalUnixMakefileGenerator3.cxx
  84. 2 1
      Source/cmLocalUnixMakefileGenerator3.h
  85. 1 2
      Source/cmLocalVisualStudio7Generator.cxx
  86. 2 2
      Source/cmMakeDirectoryCommand.cxx
  87. 15 15
      Source/cmMakefile.cxx
  88. 10 9
      Source/cmMakefile.h
  89. 5 5
      Source/cmMakefileExecutableTargetGenerator.cxx
  90. 5 5
      Source/cmMakefileLibraryTargetGenerator.cxx
  91. 10 18
      Source/cmMakefileTargetGenerator.cxx
  92. 3 5
      Source/cmMakefileUtilityTargetGenerator.cxx
  93. 4 4
      Source/cmNinjaTargetGenerator.cxx
  94. 5 5
      Source/cmOSXBundleGenerator.cxx
  95. 1 1
      Source/cmOrderDirectories.cxx
  96. 2 2
      Source/cmOutputConverter.cxx
  97. 11 11
      Source/cmOutputRequiredFilesCommand.cxx
  98. 1 1
      Source/cmQTWrapCPPCommand.cxx
  99. 1 1
      Source/cmQTWrapUICommand.cxx
  100. 3 3
      Source/cmQtAutoGenInitializer.cxx

+ 1 - 2
Source/CPack/cmCPackArchiveGenerator.cxx

@@ -239,8 +239,7 @@ int cmCPackArchiveGenerator::PackageFiles()
   cmWorkingDirectory workdir(toplevel);
   for (std::string const& file : files) {
     // Get the relative path to the file
-    std::string rp =
-      cmSystemTools::RelativePath(toplevel.c_str(), file.c_str());
+    std::string rp = cmSystemTools::RelativePath(toplevel, file);
     archive.Add(rp, 0, nullptr, false);
     if (!archive) {
       cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< "

+ 6 - 8
Source/CPack/cmCPackGenerator.cxx

@@ -187,7 +187,7 @@ int cmCPackGenerator::InstallProject()
 
   const char* tempInstallDirectory = tempInstallDirectoryStr.c_str();
   int res = 1;
-  if (!cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory.c_str())) {
+  if (!cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory)) {
     cmCPackLogger(cmCPackLog::LOG_ERROR,
                   "Problem creating temporary directory: "
                     << (tempInstallDirectory ? tempInstallDirectory : "(NULL)")
@@ -374,15 +374,14 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
           continue;
         }
         std::string filePath = tempDir;
-        filePath += "/" + subdir + "/" +
-          cmSystemTools::RelativePath(top.c_str(), gf.c_str());
+        filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(top, gf);
         cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
                         << inFile << " -> " << filePath << std::endl);
         /* If the file is a symlink we will have to re-create it */
         if (cmSystemTools::FileIsSymlink(inFile)) {
           std::string targetFile;
           std::string inFileRelative =
-            cmSystemTools::RelativePath(top.c_str(), inFile.c_str());
+            cmSystemTools::RelativePath(top, inFile);
           cmSystemTools::ReadSymlink(inFile, targetFile);
           symlinkedFiles.emplace_back(std::move(targetFile),
                                       std::move(inFileRelative));
@@ -772,9 +771,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
         }
         // Remember the list of files before installation
         // of the current component (if we are in component install)
-        const char* InstallPrefix = tempInstallDirectory.c_str();
+        std::string const& InstallPrefix = tempInstallDirectory;
         std::vector<std::string> filesBefore;
-        std::string findExpr(InstallPrefix);
+        std::string findExpr = tempInstallDirectory;
         if (componentInstall) {
           cmsys::Glob glB;
           findExpr += "/*";
@@ -829,8 +828,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
           std::string localFileName;
           // Populate the File field of each component
           for (fit = result.begin(); fit != diff; ++fit) {
-            localFileName =
-              cmSystemTools::RelativePath(InstallPrefix, fit->c_str());
+            localFileName = cmSystemTools::RelativePath(InstallPrefix, *fit);
             localFileName =
               localFileName.substr(localFileName.find_first_not_of('/'));
             Components[installComponent].Files.push_back(localFileName);

+ 5 - 7
Source/CPack/cmCPackNSISGenerator.cxx

@@ -62,8 +62,7 @@ int cmCPackNSISGenerator::PackageFiles()
   std::ostringstream str;
   for (std::string const& file : files) {
     std::string outputDir = "$INSTDIR";
-    std::string fileN =
-      cmSystemTools::RelativePath(toplevel.c_str(), file.c_str());
+    std::string fileN = cmSystemTools::RelativePath(toplevel, file);
     if (!this->Components.empty()) {
       const std::string::size_type pos = fileN.find('/');
 
@@ -90,8 +89,7 @@ int cmCPackNSISGenerator::PackageFiles()
   std::ostringstream dstr;
   for (std::string const& dir : dirs) {
     std::string componentName;
-    std::string fileN =
-      cmSystemTools::RelativePath(toplevel.c_str(), dir.c_str());
+    std::string fileN = cmSystemTools::RelativePath(toplevel, dir);
     if (fileN.empty()) {
       continue;
     }
@@ -669,8 +667,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
       uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
       uploadDirectory += "/CPackUploads";
     }
-    if (!cmSystemTools::FileExists(uploadDirectory.c_str())) {
-      if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) {
+    if (!cmSystemTools::FileExists(uploadDirectory)) {
+      if (!cmSystemTools::MakeDirectory(uploadDirectory)) {
         cmCPackLogger(cmCPackLog::LOG_ERROR,
                       "Unable to create NSIS upload directory "
                         << uploadDirectory << std::endl);
@@ -683,7 +681,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
     cmCPackLogger(cmCPackLog::LOG_OUTPUT,
                   "-   Building downloaded component archive: " << archiveFile
                                                                 << std::endl);
-    if (cmSystemTools::FileExists(archiveFile.c_str(), true)) {
+    if (cmSystemTools::FileExists(archiveFile, true)) {
       if (!cmSystemTools::RemoveFile(archiveFile)) {
         cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to remove archive file "
                         << archiveFile << std::endl);

+ 1 - 1
Source/CPack/cpack.cxx

@@ -260,7 +260,7 @@ int main(int argc, char const* const* argv)
       globalMF.AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
     }
 
-    if (cmSystemTools::FileExists(cpackConfigFile.c_str())) {
+    if (cmSystemTools::FileExists(cpackConfigFile)) {
       cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
       cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
                   "Read CPack configuration file: " << cpackConfigFile

+ 3 - 3
Source/CTest/cmCTestBuildAndTestHandler.cxx

@@ -193,7 +193,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
   out << "Internal cmake changing into directory: " << this->BinaryDir
       << std::endl;
   if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) {
-    cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
+    cmSystemTools::MakeDirectory(this->BinaryDir);
   }
   cmWorkingDirectory workdir(this->BinaryDir);
 
@@ -280,7 +280,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
     cmCTestTestHandler::FindExecutable(this->CTest, this->TestCommand.c_str(),
                                        resultingConfig, extraPaths, failed);
 
-  if (!cmSystemTools::FileExists(fullPath.c_str())) {
+  if (!cmSystemTools::FileExists(fullPath)) {
     out << "Could not find path to executable, perhaps it was not built: "
         << this->TestCommand << "\n";
     out << "tried to find it in these places:\n";
@@ -358,7 +358,7 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
       idx++;
       this->BinaryDir = allArgs[idx];
       // dir must exist before CollapseFullPath is called
-      cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
+      cmSystemTools::MakeDirectory(this->BinaryDir);
       this->BinaryDir = cmSystemTools::CollapseFullPath(this->BinaryDir);
       this->SourceDir = cmSystemTools::CollapseFullPath(this->SourceDir);
     } else {

+ 1 - 1
Source/CTest/cmCTestBuildHandler.cxx

@@ -709,7 +709,7 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
 
     if (this->Handler->UseCTestLaunch) {
       // Enable launcher fragments.
-      cmSystemTools::MakeDirectory(launchDir.c_str());
+      cmSystemTools::MakeDirectory(launchDir);
       this->WriteLauncherConfig();
       std::string launchEnv = "CTEST_LAUNCH_LOGS=";
       launchEnv += launchDir;

+ 1 - 1
Source/CTest/cmCTestConfigureCommand.cxx

@@ -57,7 +57,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
       }
 
       const std::string cmakelists_file = source_dir + "/CMakeLists.txt";
-      if (!cmSystemTools::FileExists(cmakelists_file.c_str())) {
+      if (!cmSystemTools::FileExists(cmakelists_file)) {
         std::ostringstream e;
         e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]";
         this->SetError(e.str());

+ 10 - 10
Source/CTest/cmCTestCoverageHandler.cxx

@@ -240,7 +240,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file,
   // If it is the same as fileDir, then ignore, otherwise check.
   std::string relPath;
   if (!checkDir.empty()) {
-    relPath = cmSystemTools::RelativePath(checkDir.c_str(), fFile.c_str());
+    relPath = cmSystemTools::RelativePath(checkDir, fFile);
   } else {
     relPath = fFile;
   }
@@ -450,7 +450,7 @@ int cmCTestCoverageHandler::ProcessHandler()
                        "Process file: " << fullFileName << std::endl,
                        this->Quiet);
 
-    if (!cmSystemTools::FileExists(fullFileName.c_str())) {
+    if (!cmSystemTools::FileExists(fullFileName)) {
       cmCTestLog(this->CTest, ERROR_MESSAGE,
                  "Cannot find file: " << fullFileName << std::endl);
       continue;
@@ -718,7 +718,7 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage(
   // build the find file string with the directory from above
   coverageXMLFile += "/coverage.xml";
 
-  if (cmSystemTools::FileExists(coverageXMLFile.c_str())) {
+  if (cmSystemTools::FileExists(coverageXMLFile)) {
     // If file exists, parse it
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                        "Parsing Cobertura XML file: " << coverageXMLFile
@@ -741,7 +741,7 @@ int cmCTestCoverageHandler::HandleMumpsCoverage(
   cmParseGTMCoverage cov(*cont, this->CTest);
   std::string coverageFile =
     this->CTest->GetBinaryDir() + "/gtm_coverage.mcov";
-  if (cmSystemTools::FileExists(coverageFile.c_str())) {
+  if (cmSystemTools::FileExists(coverageFile)) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                        "Parsing Cache Coverage: " << coverageFile << std::endl,
                        this->Quiet);
@@ -754,7 +754,7 @@ int cmCTestCoverageHandler::HandleMumpsCoverage(
                      this->Quiet);
   cmParseCacheCoverage ccov(*cont, this->CTest);
   coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov";
-  if (cmSystemTools::FileExists(coverageFile.c_str())) {
+  if (cmSystemTools::FileExists(coverageFile)) {
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                        "Parsing Cache Coverage: " << coverageFile << std::endl,
                        this->Quiet);
@@ -975,7 +975,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
 
   std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
   std::string tempDir = testingDir + "/CoverageInfo";
-  cmSystemTools::MakeDirectory(tempDir.c_str());
+  cmSystemTools::MakeDirectory(tempDir);
   cmWorkingDirectory workdir(tempDir);
 
   int gcovStyle = 0;
@@ -1646,7 +1646,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
 
   std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
   std::string tempDir = testingDir + "/CoverageInfo";
-  cmSystemTools::MakeDirectory(tempDir.c_str());
+  cmSystemTools::MakeDirectory(tempDir);
 
   int file_count = 0;
   for (std::string const& file : files) {
@@ -1742,11 +1742,11 @@ std::string cmCTestCoverageHandler::FindFile(
     cmSystemTools::GetFilenameWithoutLastExtension(fileName);
   // First check in source and binary directory
   std::string fullName = cont->SourceDir + "/" + fileNameNoE + ".py";
-  if (cmSystemTools::FileExists(fullName.c_str())) {
+  if (cmSystemTools::FileExists(fullName)) {
     return fullName;
   }
   fullName = cont->BinaryDir + "/" + fileNameNoE + ".py";
-  if (cmSystemTools::FileExists(fullName.c_str())) {
+  if (cmSystemTools::FileExists(fullName)) {
     return fullName;
   }
   return "";
@@ -2012,7 +2012,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
       }
       std::string file = sourceFile;
       coveredFileNames.insert(file);
-      if (!cmSystemTools::FileIsFullPath(sourceFile.c_str())) {
+      if (!cmSystemTools::FileIsFullPath(sourceFile)) {
         // file will be relative to the binary dir
         file = cont->BinaryDir;
         file += "/";

+ 6 - 6
Source/CTest/cmCTestGIT.cxx

@@ -113,7 +113,7 @@ std::string cmCTestGIT::FindGitDir()
     // are a Windows application.  Run "cygpath" to get Windows path.
     std::string cygpath_exe = cmSystemTools::GetFilenamePath(git);
     cygpath_exe += "/cygpath.exe";
-    if (cmSystemTools::FileExists(cygpath_exe.c_str())) {
+    if (cmSystemTools::FileExists(cygpath_exe)) {
       char const* cygpath[] = { cygpath_exe.c_str(), "-w", git_dir.c_str(),
                                 0 };
       OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line);
@@ -249,7 +249,7 @@ bool cmCTestGIT::UpdateImpl()
   if (this->GetGitVersion() < cmCTestGITVersion(1, 6, 5, 0)) {
     recursive = nullptr;
     // No need to require >= 1.6.5 if there are no submodules.
-    if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
+    if (cmSystemTools::FileExists(top_dir + "/.gitmodules")) {
       this->Log << "Git < 1.6.5 cannot update submodules recursively\n";
     }
   }
@@ -258,7 +258,7 @@ bool cmCTestGIT::UpdateImpl()
   if (this->GetGitVersion() < cmCTestGITVersion(1, 8, 1, 0)) {
     sync_recursive = nullptr;
     // No need to require >= 1.8.1 if there are no submodules.
-    if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
+    if (cmSystemTools::FileExists(top_dir + "/.gitmodules")) {
       this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n";
     }
   }
@@ -553,15 +553,15 @@ private:
   void DoHeaderLine()
   {
     // Look for header fields that we need.
-    if (cmHasLiteralPrefix(this->Line.c_str(), "commit ")) {
+    if (cmHasLiteralPrefix(this->Line, "commit ")) {
       this->Rev.Rev = this->Line.c_str() + 7;
-    } else if (cmHasLiteralPrefix(this->Line.c_str(), "author ")) {
+    } else if (cmHasLiteralPrefix(this->Line, "author ")) {
       Person author;
       this->ParsePerson(this->Line.c_str() + 7, author);
       this->Rev.Author = author.Name;
       this->Rev.EMail = author.EMail;
       this->Rev.Date = this->FormatDateTime(author);
-    } else if (cmHasLiteralPrefix(this->Line.c_str(), "committer ")) {
+    } else if (cmHasLiteralPrefix(this->Line, "committer ")) {
       Person committer;
       this->ParsePerson(this->Line.c_str() + 10, committer);
       this->Rev.Committer = committer.Name;

+ 4 - 6
Source/CTest/cmCTestLaunch.cxx

@@ -377,11 +377,10 @@ void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml)
     cmSystemTools::ConvertToUnixSlashes(source);
 
     // If file is in source tree use its relative location.
-    if (cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) &&
-        cmSystemTools::FileIsFullPath(source.c_str()) &&
+    if (cmSystemTools::FileIsFullPath(this->SourceDir) &&
+        cmSystemTools::FileIsFullPath(source) &&
         cmSystemTools::IsSubDirectory(source, this->SourceDir)) {
-      source =
-        cmSystemTools::RelativePath(this->SourceDir.c_str(), source.c_str());
+      source = cmSystemTools::RelativePath(this->SourceDir, source);
     }
 
     xml.Element("SourceFile", source);
@@ -629,8 +628,7 @@ void cmCTestLaunch::LoadConfig()
   cmMakefile mf(&gg, cm.GetCurrentSnapshot());
   std::string fname = this->LogDir;
   fname += "CTestLaunchConfig.cmake";
-  if (cmSystemTools::FileExists(fname.c_str()) &&
-      mf.ReadListFile(fname.c_str())) {
+  if (cmSystemTools::FileExists(fname) && mf.ReadListFile(fname.c_str())) {
     this->SourceDir = mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
     cmSystemTools::ConvertToUnixSlashes(this->SourceDir);
   }

+ 10 - 14
Source/CTest/cmCTestMemCheckHandler.cxx

@@ -163,7 +163,7 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
   std::string index;
   std::ostringstream stream;
   std::string memcheckcommand =
-    cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
+    cmSystemTools::ConvertToOutputPath(this->MemoryTester);
   stream << test;
   index = stream.str();
   for (std::string arg : this->MemoryTesterDynamicOptions) {
@@ -426,7 +426,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
   this->MemoryTester.clear();
   // Setup the command
   if (cmSystemTools::FileExists(
-        this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str())) {
+        this->CTest->GetCTestConfiguration("MemoryCheckCommand"))) {
     this->MemoryTester =
       this->CTest->GetCTestConfiguration("MemoryCheckCommand");
     std::string testerName =
@@ -443,17 +443,15 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
       this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN;
     }
   } else if (cmSystemTools::FileExists(
-               this->CTest->GetCTestConfiguration("PurifyCommand").c_str())) {
+               this->CTest->GetCTestConfiguration("PurifyCommand"))) {
     this->MemoryTester = this->CTest->GetCTestConfiguration("PurifyCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
   } else if (cmSystemTools::FileExists(
-               this->CTest->GetCTestConfiguration("ValgrindCommand")
-                 .c_str())) {
+               this->CTest->GetCTestConfiguration("ValgrindCommand"))) {
     this->MemoryTester = this->CTest->GetCTestConfiguration("ValgrindCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
   } else if (cmSystemTools::FileExists(
-               this->CTest->GetCTestConfiguration("BoundsCheckerCommand")
-                 .c_str())) {
+               this->CTest->GetCTestConfiguration("BoundsCheckerCommand"))) {
     this->MemoryTester =
       this->CTest->GetCTestConfiguration("BoundsCheckerCommand");
     this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
@@ -537,9 +535,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
       }
       if (!this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
              .empty()) {
-        if (!cmSystemTools::FileExists(
-              this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
-                .c_str())) {
+        if (!cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
+              "MemoryCheckSuppressionFile"))) {
           cmCTestLog(this->CTest, ERROR_MESSAGE,
                      "Cannot find memory checker suppression file: "
                        << this->CTest->GetCTestConfiguration(
@@ -560,9 +557,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
 #ifdef _WIN32
       if (this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
             .size()) {
-        if (!cmSystemTools::FileExists(
-              this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
-                .c_str())) {
+        if (!cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
+              "MemoryCheckSuppressionFile"))) {
           cmCTestLog(
             this->CTest, ERROR_MESSAGE,
             "Cannot find memory checker suppression file: "
@@ -1093,7 +1089,7 @@ void cmCTestMemCheckHandler::TestOutputFileNames(
       files = g.GetFiles();
       return;
     }
-  } else if (!cmSystemTools::FileExists(ofile.c_str())) {
+  } else if (!cmSystemTools::FileExists(ofile)) {
     std::string log = "Cannot find memory tester output file: " + ofile;
     cmCTestLog(this->CTest, ERROR_MESSAGE, log << std::endl);
     ofile.clear();

+ 4 - 4
Source/CTest/cmCTestMultiProcessHandler.cxx

@@ -413,7 +413,7 @@ void cmCTestMultiProcessHandler::UpdateCostData()
 
   PropertiesMap temp = this->Properties;
 
-  if (cmSystemTools::FileExists(fname.c_str())) {
+  if (cmSystemTools::FileExists(fname)) {
     cmsys::ifstream fin;
     fin.open(fname.c_str());
 
@@ -466,7 +466,7 @@ void cmCTestMultiProcessHandler::ReadCostData()
 {
   std::string fname = this->CTest->GetCostDataFile();
 
-  if (cmSystemTools::FileExists(fname.c_str(), true)) {
+  if (cmSystemTools::FileExists(fname, true)) {
     cmsys::ifstream fin;
     fin.open(fname.c_str());
     std::string line;
@@ -741,7 +741,7 @@ void cmCTestMultiProcessHandler::CheckResume()
   std::string fname =
     this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt";
   if (this->CTest->GetFailover()) {
-    if (cmSystemTools::FileExists(fname.c_str(), true)) {
+    if (cmSystemTools::FileExists(fname, true)) {
       *this->TestHandler->LogFile
         << "Resuming previously interrupted test set" << std::endl
         << "----------------------------------------------------------"
@@ -756,7 +756,7 @@ void cmCTestMultiProcessHandler::CheckResume()
       }
       fin.close();
     }
-  } else if (cmSystemTools::FileExists(fname.c_str(), true)) {
+  } else if (cmSystemTools::FileExists(fname, true)) {
     cmSystemTools::RemoveFile(fname);
   }
 }

+ 2 - 2
Source/CTest/cmCTestRunTest.cxx

@@ -467,7 +467,7 @@ bool cmCTestRunTest::StartTest(size_t total)
 
   // Check if all required files exist
   for (std::string const& file : this->TestProperties->RequiredFiles) {
-    if (!cmSystemTools::FileExists(file.c_str())) {
+    if (!cmSystemTools::FileExists(file)) {
       // Required file was not found
       this->TestProcess = cm::make_unique<cmProcess>(*this);
       *this->TestHandler->LogFile << "Unable to find required file: " << file
@@ -537,7 +537,7 @@ void cmCTestRunTest::ComputeArguments()
     ++j; // skip the executable (it will be actualCommand)
   }
   std::string testCommand =
-    cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
+    cmSystemTools::ConvertToOutputPath(this->ActualCommand);
 
   // Prepends memcheck args to our command string
   this->TestHandler->GenerateTestCommand(this->Arguments, this->Index);

+ 10 - 10
Source/CTest/cmCTestScriptHandler.cxx

@@ -327,7 +327,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
     script_arg = total_script_arg.substr(comma_pos + 1);
   }
   // make sure the file exists
-  if (!cmSystemTools::FileExists(script.c_str())) {
+  if (!cmSystemTools::FileExists(script)) {
     cmSystemTools::Error("Cannot find file: ", script.c_str());
     return 1;
   }
@@ -598,7 +598,7 @@ int cmCTestScriptHandler::CheckOutSourceDir()
   int retVal;
   bool res;
 
-  if (!cmSystemTools::FileExists(this->SourceDir.c_str()) &&
+  if (!cmSystemTools::FileExists(this->SourceDir) &&
       !this->CVSCheckOut.empty()) {
     // we must now checkout the src dir
     output.clear();
@@ -630,10 +630,10 @@ int cmCTestScriptHandler::BackupDirectories()
   // backup the binary and src directories if requested
   if (this->Backup) {
     // if for some reason those directories exist then first delete them
-    if (cmSystemTools::FileExists(this->BackupSourceDir.c_str())) {
+    if (cmSystemTools::FileExists(this->BackupSourceDir)) {
       cmSystemTools::RemoveADirectory(this->BackupSourceDir);
     }
-    if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str())) {
+    if (cmSystemTools::FileExists(this->BackupBinaryDir)) {
       cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
     }
 
@@ -716,9 +716,9 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
   }
 
   // make sure the binary directory exists if it isn't the srcdir
-  if (!cmSystemTools::FileExists(this->BinaryDir.c_str()) &&
+  if (!cmSystemTools::FileExists(this->BinaryDir) &&
       this->SourceDir != this->BinaryDir) {
-    if (!cmSystemTools::MakeDirectory(this->BinaryDir.c_str())) {
+    if (!cmSystemTools::MakeDirectory(this->BinaryDir)) {
       cmSystemTools::Error("Unable to create the binary directory:\n",
                            this->BinaryDir.c_str());
       this->RestoreBackupDirectories();
@@ -782,7 +782,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
 
     if (!this->CMOutFile.empty()) {
       std::string cmakeOutputFile = this->CMOutFile;
-      if (!cmSystemTools::FileIsFullPath(cmakeOutputFile.c_str())) {
+      if (!cmSystemTools::FileIsFullPath(cmakeOutputFile)) {
         cmakeOutputFile = this->BinaryDir + "/" + cmakeOutputFile;
       }
 
@@ -876,10 +876,10 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
   // the backed up dirs
   if (this->Backup) {
     // if for some reason those directories exist then first delete them
-    if (cmSystemTools::FileExists(this->SourceDir.c_str())) {
+    if (cmSystemTools::FileExists(this->SourceDir)) {
       cmSystemTools::RemoveADirectory(this->SourceDir);
     }
-    if (cmSystemTools::FileExists(this->BinaryDir.c_str())) {
+    if (cmSystemTools::FileExists(this->BinaryDir)) {
       cmSystemTools::RemoveADirectory(this->BinaryDir);
     }
     // rename the src and binary directories
@@ -918,7 +918,7 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char* sname)
   std::string check = sname;
   check += "/CMakeCache.txt";
 
-  if (!cmSystemTools::FileExists(check.c_str())) {
+  if (!cmSystemTools::FileExists(check)) {
     return false;
   }
 

+ 1 - 1
Source/CTest/cmCTestSubmitCommand.cxx

@@ -229,7 +229,7 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
   }
 
   if (this->ArgumentDoing == ArgumentDoingFiles) {
-    if (cmSystemTools::FileExists(arg.c_str())) {
+    if (cmSystemTools::FileExists(arg)) {
       this->Files.insert(arg);
     } else {
       std::ostringstream e;

+ 6 - 6
Source/CTest/cmCTestSubmitHandler.cxx

@@ -194,13 +194,13 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
       ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
 
       std::string local_file = file;
-      if (!cmSystemTools::FileExists(local_file.c_str())) {
+      if (!cmSystemTools::FileExists(local_file)) {
         local_file = localprefix + "/" + file;
       }
       std::string upload_as =
         url + "/" + remoteprefix + cmSystemTools::GetFilenameName(file);
 
-      if (!cmSystemTools::FileExists(local_file.c_str())) {
+      if (!cmSystemTools::FileExists(local_file)) {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
                    "   Cannot find file: " << local_file << std::endl);
         ::curl_easy_cleanup(curl);
@@ -387,7 +387,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
       ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
 
       std::string local_file = file;
-      if (!cmSystemTools::FileExists(local_file.c_str())) {
+      if (!cmSystemTools::FileExists(local_file)) {
         local_file = localprefix + "/" + file;
       }
       std::string remote_file =
@@ -429,7 +429,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
           cmSystemTools::ComputeFileHash(local_file, cmCryptoHash::AlgoMD5);
       }
 
-      if (!cmSystemTools::FileExists(local_file.c_str())) {
+      if (!cmSystemTools::FileExists(local_file)) {
         cmCTestLog(this->CTest, ERROR_MESSAGE,
                    "   Cannot find file: " << local_file << std::endl);
         ::curl_easy_cleanup(curl);
@@ -772,7 +772,7 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command,
     std::string lfname = localprefix;
     cmSystemTools::ConvertToUnixSlashes(lfname);
     lfname += "/" + file;
-    lfname = cmSystemTools::ConvertToOutputPath(lfname.c_str());
+    lfname = cmSystemTools::ConvertToOutputPath(lfname);
     argv[1] = lfname.c_str();
     std::string rfname = url + "/" + remoteprefix + file;
     argv[2] = rfname.c_str();
@@ -898,7 +898,7 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(
     xmlrpc_value* result;
 
     std::string local_file = file;
-    if (!cmSystemTools::FileExists(local_file.c_str())) {
+    if (!cmSystemTools::FileExists(local_file)) {
       local_file = localprefix + "/" + file;
     }
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,

+ 6 - 6
Source/CTest/cmCTestTestHandler.cxx

@@ -70,7 +70,7 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
   for (std::string const& arg : args) {
     std::string fname;
 
-    if (cmSystemTools::FileIsFullPath(arg.c_str())) {
+    if (cmSystemTools::FileIsFullPath(arg)) {
       fname = arg;
     } else {
       fname = cwd;
@@ -145,7 +145,7 @@ bool cmCTestAddSubdirectoryCommand::InitialPass(
   fname += "/";
   fname += args[0];
 
-  if (!cmSystemTools::FileExists(fname.c_str())) {
+  if (!cmSystemTools::FileExists(fname)) {
     // No subdirectory? So what...
     return true;
   }
@@ -1576,7 +1576,7 @@ std::string cmCTestTestHandler::FindExecutable(
   // now look in the paths we specified above
   for (unsigned int ai = 0; ai < attempted.size() && fullPath.empty(); ++ai) {
     // first check without exe extension
-    if (cmSystemTools::FileExists(attempted[ai].c_str()) &&
+    if (cmSystemTools::FileExists(attempted[ai]) &&
         !cmSystemTools::FileIsDirectory(attempted[ai])) {
       fullPath = cmSystemTools::CollapseFullPath(attempted[ai]);
       resultingConfig = attemptedConfigs[ai];
@@ -1586,7 +1586,7 @@ std::string cmCTestTestHandler::FindExecutable(
       failed.push_back(attempted[ai]);
       tempPath = attempted[ai];
       tempPath += cmSystemTools::GetExecutableExtension();
-      if (cmSystemTools::FileExists(tempPath.c_str()) &&
+      if (cmSystemTools::FileExists(tempPath) &&
           !cmSystemTools::FileIsDirectory(tempPath)) {
         fullPath = cmSystemTools::CollapseFullPath(tempPath);
         resultingConfig = attemptedConfigs[ai];
@@ -1822,7 +1822,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
   std::string lastTestsFailedLog =
     this->CTest->GetBinaryDir() + "/Testing/Temporary/" + logName;
 
-  if (!cmSystemTools::FileExists(lastTestsFailedLog.c_str())) {
+  if (!cmSystemTools::FileExists(lastTestsFailedLog)) {
     if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) {
       cmCTestLog(this->CTest, ERROR_MESSAGE, lastTestsFailedLog
                    << " does not exist!" << std::endl);
@@ -1935,7 +1935,7 @@ void cmCTestTestHandler::GenerateRegressionImages(cmXMLWriter& xml,
     } else if (measurementfile.find(cxml)) {
       const std::string& filename =
         cmCTest::CleanString(measurementfile.match(5));
-      if (cmSystemTools::FileExists(filename.c_str())) {
+      if (cmSystemTools::FileExists(filename)) {
         long len = cmSystemTools::FileLength(filename);
         if (len == 0) {
           std::string k1 = measurementfile.match(1);

+ 7 - 7
Source/CTest/cmCTestUpdateHandler.cxx

@@ -257,37 +257,37 @@ int cmCTestUpdateHandler::DetectVCS(const char* dir)
                      "Check directory: " << sourceDirectory << std::endl,
                      this->Quiet);
   sourceDirectory += "/.svn";
-  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+  if (cmSystemTools::FileExists(sourceDirectory)) {
     return cmCTestUpdateHandler::e_SVN;
   }
   sourceDirectory = dir;
   sourceDirectory += "/CVS";
-  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+  if (cmSystemTools::FileExists(sourceDirectory)) {
     return cmCTestUpdateHandler::e_CVS;
   }
   sourceDirectory = dir;
   sourceDirectory += "/.bzr";
-  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+  if (cmSystemTools::FileExists(sourceDirectory)) {
     return cmCTestUpdateHandler::e_BZR;
   }
   sourceDirectory = dir;
   sourceDirectory += "/.git";
-  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+  if (cmSystemTools::FileExists(sourceDirectory)) {
     return cmCTestUpdateHandler::e_GIT;
   }
   sourceDirectory = dir;
   sourceDirectory += "/.hg";
-  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+  if (cmSystemTools::FileExists(sourceDirectory)) {
     return cmCTestUpdateHandler::e_HG;
   }
   sourceDirectory = dir;
   sourceDirectory += "/.p4";
-  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+  if (cmSystemTools::FileExists(sourceDirectory)) {
     return cmCTestUpdateHandler::e_P4;
   }
   sourceDirectory = dir;
   sourceDirectory += "/.p4config";
-  if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+  if (cmSystemTools::FileExists(sourceDirectory)) {
     return cmCTestUpdateHandler::e_P4;
   }
   return cmCTestUpdateHandler::e_UNKNOWN;

+ 1 - 1
Source/CTest/cmCTestUploadCommand.cxx

@@ -51,7 +51,7 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
     return true;
   }
   if (this->ArgumentDoing == ArgumentDoingFiles) {
-    if (cmSystemTools::FileExists(arg.c_str())) {
+    if (cmSystemTools::FileExists(arg)) {
       this->Files.insert(arg);
       return true;
     }

+ 1 - 1
Source/CTest/cmCTestVC.cxx

@@ -47,7 +47,7 @@ bool cmCTestVC::InitialCheckout(const char* command)
   std::string parent = cmSystemTools::GetFilenamePath(this->SourceDirectory);
   cmCTestLog(this->CTest, HANDLER_OUTPUT,
              "   Perform checkout in directory: " << parent << "\n");
-  if (!cmSystemTools::MakeDirectory(parent.c_str())) {
+  if (!cmSystemTools::MakeDirectory(parent)) {
     cmCTestLog(this->CTest, ERROR_MESSAGE,
                "Cannot create directory: " << parent << std::endl);
     return false;

+ 1 - 1
Source/CTest/cmParseCoberturaCoverage.cxx

@@ -83,7 +83,7 @@ protected:
             // binary directories.
             for (std::string const& filePath : FilePaths) {
               finalpath = filePath + "/" + filename;
-              if (cmSystemTools::FileExists(finalpath.c_str())) {
+              if (cmSystemTools::FileExists(finalpath)) {
                 this->CurFileName = finalpath;
                 break;
               }

+ 1 - 1
Source/cmAddCompileOptionsCommand.cxx

@@ -14,7 +14,7 @@ bool cmAddCompileOptionsCommand::InitialPass(
   }
 
   for (std::string const& i : args) {
-    this->Makefile->AddCompileOption(i.c_str());
+    this->Makefile->AddCompileOption(i);
   }
   return true;
 }

+ 3 - 3
Source/cmAddCustomCommandCommand.cxx

@@ -127,7 +127,7 @@ bool cmAddCustomCommandCommand::InitialPass(
         case doing_output:
         case doing_outputs:
         case doing_byproducts:
-          if (!cmSystemTools::FileIsFullPath(copy.c_str())) {
+          if (!cmSystemTools::FileIsFullPath(copy)) {
             // This is an output to be generated, so it should be
             // under the build tree.  CMake 2.4 placed this under the
             // source tree.  However the only case that this change
@@ -154,7 +154,7 @@ bool cmAddCustomCommandCommand::InitialPass(
           break;
       }
 
-      if (cmSystemTools::FileIsFullPath(filename.c_str())) {
+      if (cmSystemTools::FileIsFullPath(filename)) {
         filename = cmSystemTools::CollapseFullPath(filename);
       }
       switch (doing) {
@@ -355,7 +355,7 @@ bool cmAddCustomCommandCommand::CheckOutputs(
   for (std::string const& o : outputs) {
     // Make sure the file will not be generated into the source
     // directory during an out of source build.
-    if (!this->Makefile->CanIWriteThisFile(o.c_str())) {
+    if (!this->Makefile->CanIWriteThisFile(o)) {
       std::string e = "attempted to have a file \"" + o +
         "\" in a source directory as an output of custom command.";
       this->SetError(e);

+ 1 - 1
Source/cmAddCustomTargetCommand.cxx

@@ -117,7 +117,7 @@ bool cmAddCustomTargetCommand::InitialPass(
           break;
         case doing_byproducts: {
           std::string filename;
-          if (!cmSystemTools::FileIsFullPath(copy.c_str())) {
+          if (!cmSystemTools::FileIsFullPath(copy)) {
             filename = this->Makefile->GetCurrentBinaryDirectory();
             filename += "/";
           }

+ 1 - 1
Source/cmAddDefinitionsCommand.cxx

@@ -16,7 +16,7 @@ bool cmAddDefinitionsCommand::InitialPass(std::vector<std::string> const& args,
   }
 
   for (std::string const& i : args) {
-    this->Makefile->AddDefineFlag(i.c_str());
+    this->Makefile->AddDefineFlag(i);
   }
   return true;
 }

+ 1 - 1
Source/cmAddExecutableCommand.cxx

@@ -99,7 +99,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args,
       return false;
     }
 
-    const char* aliasedName = s->c_str();
+    std::string const& aliasedName = *s;
     if (this->Makefile->IsAlias(aliasedName)) {
       std::ostringstream e;
       e << "cannot create ALIAS target \"" << exename << "\" because target \""

+ 1 - 1
Source/cmAddLibraryCommand.cxx

@@ -198,7 +198,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
       return false;
     }
 
-    const char* aliasedName = s->c_str();
+    std::string const& aliasedName = *s;
     if (this->Makefile->IsAlias(aliasedName)) {
       std::ostringstream e;
       e << "cannot create ALIAS target \"" << libName << "\" because target \""

+ 2 - 2
Source/cmAddSubDirectoryCommand.cxx

@@ -44,7 +44,7 @@ bool cmAddSubDirectoryCommand::InitialPass(
   // Compute the full path to the specified source directory.
   // Interpret a relative path with respect to the current source directory.
   std::string srcPath;
-  if (cmSystemTools::FileIsFullPath(srcArg.c_str())) {
+  if (cmSystemTools::FileIsFullPath(srcArg)) {
     srcPath = srcArg;
   } else {
     srcPath = this->Makefile->GetCurrentSourceDirectory();
@@ -94,7 +94,7 @@ bool cmAddSubDirectoryCommand::InitialPass(
   } else {
     // Use the binary directory specified.
     // Interpret a relative path with respect to the current binary directory.
-    if (cmSystemTools::FileIsFullPath(binArg.c_str())) {
+    if (cmSystemTools::FileIsFullPath(binArg)) {
       binPath = binArg;
     } else {
       binPath = this->Makefile->GetCurrentBinaryDirectory();

+ 1 - 1
Source/cmAuxSourceDirectoryCommand.cxx

@@ -26,7 +26,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass(
   std::string sourceListValue;
   std::string const& templateDirectory = args[0];
   std::string tdir;
-  if (!cmSystemTools::FileIsFullPath(templateDirectory.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(templateDirectory)) {
     tdir = this->Makefile->GetCurrentSourceDirectory();
     tdir += "/";
     tdir += templateDirectory;

+ 2 - 2
Source/cmCPluginAPI.cxx

@@ -108,12 +108,12 @@ const char* CCONV cmGetProjectName(void* arg)
 const char* CCONV cmGetHomeDirectory(void* arg)
 {
   cmMakefile* mf = static_cast<cmMakefile*>(arg);
-  return mf->GetHomeDirectory();
+  return mf->GetHomeDirectory().c_str();
 }
 const char* CCONV cmGetHomeOutputDirectory(void* arg)
 {
   cmMakefile* mf = static_cast<cmMakefile*>(arg);
-  return mf->GetHomeOutputDirectory();
+  return mf->GetHomeOutputDirectory().c_str();
 }
 const char* CCONV cmGetStartDirectory(void* arg)
 {

+ 18 - 20
Source/cmCTest.cxx

@@ -184,7 +184,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
       ::curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fields.c_str());
       break;
     case cmCTest::HTTP_PUT:
-      if (!cmSystemTools::FileExists(putFile.c_str())) {
+      if (!cmSystemTools::FileExists(putFile)) {
         response = "Error: File ";
         response += putFile + " does not exist.\n";
         return -1;
@@ -429,7 +429,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
     // Verify "Testing" directory exists:
     //
     std::string testingDir = this->BinaryDir + "/Testing";
-    if (cmSystemTools::FileExists(testingDir.c_str())) {
+    if (cmSystemTools::FileExists(testingDir)) {
       if (!cmSystemTools::FileIsDirectory(testingDir)) {
         cmCTestLog(this, ERROR_MESSAGE, "File "
                      << testingDir
@@ -438,7 +438,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
         return 0;
       }
     } else {
-      if (!cmSystemTools::MakeDirectory(testingDir.c_str())) {
+      if (!cmSystemTools::MakeDirectory(testingDir)) {
         cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory "
                      << testingDir << std::endl);
         return 0;
@@ -556,9 +556,9 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
   bld_dir_fname += "/CTestConfig.cmake";
   cmSystemTools::ConvertToUnixSlashes(bld_dir_fname);
 
-  if (cmSystemTools::FileExists(bld_dir_fname.c_str())) {
+  if (cmSystemTools::FileExists(bld_dir_fname)) {
     fname = bld_dir_fname;
-  } else if (cmSystemTools::FileExists(src_dir_fname.c_str())) {
+  } else if (cmSystemTools::FileExists(src_dir_fname)) {
     fname = src_dir_fname;
   }
 
@@ -619,12 +619,12 @@ bool cmCTest::UpdateCTestConfiguration()
     return true;
   }
   std::string fileName = this->BinaryDir + "/CTestConfiguration.ini";
-  if (!cmSystemTools::FileExists(fileName.c_str())) {
+  if (!cmSystemTools::FileExists(fileName)) {
     fileName = this->BinaryDir + "/DartConfiguration.tcl";
   }
   cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
              "UpdateCTestConfiguration  from :" << fileName << "\n");
-  if (!cmSystemTools::FileExists(fileName.c_str())) {
+  if (!cmSystemTools::FileExists(fileName)) {
     // No need to exit if we are not producing XML
     if (this->ProduceXML) {
       cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName
@@ -741,7 +741,7 @@ bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name,
   if (!path.empty()) {
     testingDir += "/" + path;
   }
-  if (cmSystemTools::FileExists(testingDir.c_str())) {
+  if (cmSystemTools::FileExists(testingDir)) {
     if (!cmSystemTools::FileIsDirectory(testingDir)) {
       cmCTestLog(this, ERROR_MESSAGE, "File "
                    << testingDir << " is in the place of the testing directory"
@@ -749,7 +749,7 @@ bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name,
       return false;
     }
   } else {
-    if (!cmSystemTools::MakeDirectory(testingDir.c_str())) {
+    if (!cmSystemTools::MakeDirectory(testingDir)) {
       cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory " << testingDir
                                                                  << std::endl);
       return false;
@@ -790,7 +790,7 @@ bool cmCTest::CTestFileExists(const std::string& filename)
 {
   std::string testingDir =
     this->BinaryDir + "/Testing/" + this->CurrentTag + "/" + filename;
-  return cmSystemTools::FileExists(testingDir.c_str());
+  return cmSystemTools::FileExists(testingDir);
 }
 
 cmCTestGenericHandler* cmCTest::GetInitializedHandler(const char* handler)
@@ -890,7 +890,7 @@ int cmCTest::ProcessSteps()
       for (kk = 0; kk < d.GetNumberOfFiles(); kk++) {
         const char* file = d.GetFile(kk);
         std::string fullname = notes_dir + "/" + file;
-        if (cmSystemTools::FileExists(fullname.c_str()) &&
+        if (cmSystemTools::FileExists(fullname) &&
             !cmSystemTools::FileIsDirectory(fullname)) {
           if (!this->NotesFiles.empty()) {
             this->NotesFiles += ";";
@@ -939,10 +939,10 @@ int cmCTest::GetTestModelFromString(const char* str)
     return cmCTest::EXPERIMENTAL;
   }
   std::string rstr = cmSystemTools::LowerCase(str);
-  if (cmHasLiteralPrefix(rstr.c_str(), "cont")) {
+  if (cmHasLiteralPrefix(rstr, "cont")) {
     return cmCTest::CONTINUOUS;
   }
-  if (cmHasLiteralPrefix(rstr.c_str(), "nigh")) {
+  if (cmHasLiteralPrefix(rstr, "nigh")) {
     return cmCTest::NIGHTLY;
   }
   return cmCTest::EXPERIMENTAL;
@@ -1523,7 +1523,7 @@ std::string cmCTest::Base64EncodeFile(std::string const& file)
 bool cmCTest::SubmitExtraFiles(const VectorOfStrings& files)
 {
   for (cmsys::String const& file : files) {
-    if (!cmSystemTools::FileExists(file.c_str())) {
+    if (!cmSystemTools::FileExists(file)) {
       cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: "
                    << file << " to submit." << std::endl;);
       return false;
@@ -2307,7 +2307,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
   std::string fname = dir;
   fname += "/CTestCustom.cmake";
   cmCTestLog(this, DEBUG, "* Check for file: " << fname << std::endl);
-  if (cmSystemTools::FileExists(fname.c_str())) {
+  if (cmSystemTools::FileExists(fname)) {
     cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
                  << fname << std::endl);
     bool erroroc = cmSystemTools::GetErrorOccuredFlag();
@@ -2327,7 +2327,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
   std::string rexpr = dir;
   rexpr += "/CTestCustom.ctest";
   cmCTestLog(this, DEBUG, "* Check for file: " << rexpr << std::endl);
-  if (!found && cmSystemTools::FileExists(rexpr.c_str())) {
+  if (!found && cmSystemTools::FileExists(rexpr)) {
     cmsys::Glob gl;
     gl.RecurseOn();
     gl.FindFiles(rexpr);
@@ -2394,10 +2394,8 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
   std::string fname = cmSystemTools::CollapseFullPath(cfname);
 
   // Find relative paths to both directories
-  std::string srcRelpath =
-    cmSystemTools::RelativePath(sourceDir.c_str(), fname.c_str());
-  std::string bldRelpath =
-    cmSystemTools::RelativePath(buildDir.c_str(), fname.c_str());
+  std::string srcRelpath = cmSystemTools::RelativePath(sourceDir, fname);
+  std::string bldRelpath = cmSystemTools::RelativePath(buildDir, fname);
 
   // If any contains "." it is not parent directory
   bool inSrc = srcRelpath.find("..") == std::string::npos;

+ 3 - 3
Source/cmCacheManager.cxx

@@ -43,7 +43,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
   if (internal) {
     this->Cache.clear();
   }
-  if (!cmSystemTools::FileExists(cacheFile.c_str())) {
+  if (!cmSystemTools::FileExists(cacheFile)) {
     this->CleanCMakeFiles(path);
     return false;
   }
@@ -358,7 +358,7 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
   fout.Close();
   std::string checkCacheFile = path;
   checkCacheFile += cmake::GetCMakeFilesDirectory();
-  cmSystemTools::MakeDirectory(checkCacheFile.c_str());
+  cmSystemTools::MakeDirectory(checkCacheFile);
   checkCacheFile += "/cmake.check_cache";
   cmsys::ofstream checkCache(checkCacheFile.c_str());
   if (!checkCache) {
@@ -377,7 +377,7 @@ bool cmCacheManager::DeleteCache(const std::string& path)
   cmSystemTools::ConvertToUnixSlashes(cacheFile);
   std::string cmakeFiles = cacheFile;
   cacheFile += "/CMakeCache.txt";
-  if (cmSystemTools::FileExists(cacheFile.c_str())) {
+  if (cmSystemTools::FileExists(cacheFile)) {
     cmSystemTools::RemoveFile(cacheFile);
     // now remove the files in the CMakeFiles directory
     // this cleans up language cache files

+ 6 - 5
Source/cmComputeLinkInformation.cxx

@@ -632,7 +632,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
     }
   } else {
     // This is not a CMake target.  Use the name given.
-    if (cmSystemTools::FileIsFullPath(item.c_str())) {
+    if (cmSystemTools::FileIsFullPath(item)) {
       if (cmSystemTools::FileIsDirectory(item)) {
         // This is a directory.
         this->AddDirectoryItem(item);
@@ -668,13 +668,13 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
   } else {
     // Skip items that are not full paths.  We will not be able to
     // reliably specify them.
-    if (!cmSystemTools::FileIsFullPath(item.c_str())) {
+    if (!cmSystemTools::FileIsFullPath(item)) {
       return;
     }
 
     // Get the name of the library from the file name.
     std::string file = cmSystemTools::GetFilenameName(item);
-    if (!this->ExtractSharedLibraryName.find(file.c_str())) {
+    if (!this->ExtractSharedLibraryName.find(file)) {
       // This is not the name of a shared library.
       return;
     }
@@ -1746,8 +1746,9 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
         }
       } else if (use_link_rpath) {
         // Do not add any path inside the source or build tree.
-        const char* topSourceDir = this->CMakeInstance->GetHomeDirectory();
-        const char* topBinaryDir =
+        std::string const& topSourceDir =
+          this->CMakeInstance->GetHomeDirectory();
+        std::string const& topBinaryDir =
           this->CMakeInstance->GetHomeOutputDirectory();
         if (!cmSystemTools::ComparePath(ri, topSourceDir) &&
             !cmSystemTools::ComparePath(ri, topBinaryDir) &&

+ 1 - 1
Source/cmConditionEvaluator.cxx

@@ -494,7 +494,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
         if (argP1len > 4 && argP1->GetValue().substr(0, 4) == "ENV{" &&
             argP1->GetValue().operator[](argP1len - 1) == '}') {
           std::string env = argP1->GetValue().substr(4, argP1len - 5);
-          bdef = cmSystemTools::HasEnv(env.c_str());
+          bdef = cmSystemTools::HasEnv(env);
         } else {
           bdef = this->Makefile.IsDefinitionSet(argP1->GetValue());
         }

+ 1 - 1
Source/cmConfigureFileCommand.cxx

@@ -51,7 +51,7 @@ bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args,
     this->OutputFile += cmSystemTools::GetFilenameName(inFile);
   }
 
-  if (!this->Makefile->CanIWriteThisFile(this->OutputFile.c_str())) {
+  if (!this->Makefile->CanIWriteThisFile(this->OutputFile)) {
     std::string e = "attempted to configure a file: " + this->OutputFile +
       " into a source directory.";
     this->SetError(e);

+ 9 - 11
Source/cmCoreTryCompile.cxx

@@ -391,7 +391,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
     }
   }
   // make sure the binary directory exists
-  cmSystemTools::MakeDirectory(this->BinaryDirectory.c_str());
+  cmSystemTools::MakeDirectory(this->BinaryDirectory);
 
   // do not allow recursive try Compiles
   if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory()) {
@@ -864,18 +864,17 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
   return res;
 }
 
-void cmCoreTryCompile::CleanupFiles(const char* binDir)
+void cmCoreTryCompile::CleanupFiles(std::string const& binDir)
 {
-  if (!binDir) {
+  if (binDir.empty()) {
     return;
   }
 
-  std::string bdir = binDir;
-  if (bdir.find("CMakeTmp") == std::string::npos) {
+  if (binDir.find("CMakeTmp") == std::string::npos) {
     cmSystemTools::Error(
       "TRY_COMPILE attempt to remove -rf directory that does not contain "
       "CMakeTmp:",
-      binDir);
+      binDir.c_str());
     return;
   }
 
@@ -889,7 +888,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
         std::string const fullPath =
           std::string(binDir).append("/").append(fileName);
         if (cmSystemTools::FileIsDirectory(fullPath)) {
-          this->CleanupFiles(fullPath.c_str());
+          this->CleanupFiles(fullPath);
           cmSystemTools::RemoveADirectory(fullPath);
         } else {
 #ifdef _WIN32
@@ -897,9 +896,8 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
           // cannot delete them immediately.  Try a few times.
           cmSystemTools::WindowsFileRetry retry =
             cmSystemTools::GetWindowsFileRetry();
-          while (!cmSystemTools::RemoveFile(fullPath.c_str()) &&
-                 --retry.Count &&
-                 cmSystemTools::FileExists(fullPath.c_str())) {
+          while (!cmSystemTools::RemoveFile(fullPath) && --retry.Count &&
+                 cmSystemTools::FileExists(fullPath)) {
             cmSystemTools::Delay(retry.Delay);
           }
           if (retry.Count == 0)
@@ -959,7 +957,7 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
     std::string command = this->BinaryDirectory;
     command += sdir;
     command += tmpOutputFile;
-    if (cmSystemTools::FileExists(command.c_str())) {
+    if (cmSystemTools::FileExists(command)) {
       this->OutputFile = cmSystemTools::CollapseFullPath(command);
       return;
     }

+ 1 - 1
Source/cmCoreTryCompile.h

@@ -33,7 +33,7 @@ protected:
    * This way we do not have to rely on the timing and
    * dependencies of makefiles.
    */
-  void CleanupFiles(const char* binDir);
+  void CleanupFiles(std::string const& binDir);
 
   /**
    * This tries to find the (executable) file created by

+ 1 - 1
Source/cmCustomCommandGenerator.cxx

@@ -51,7 +51,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
     cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config),
                                       result);
     for (std::string& it : result) {
-      if (cmSystemTools::FileIsFullPath(it.c_str())) {
+      if (cmSystemTools::FileIsFullPath(it)) {
         it = cmSystemTools::CollapseFullPath(it);
       }
     }

+ 10 - 13
Source/cmDependsC.cxx

@@ -131,14 +131,12 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
 
       // If not a full path, find the file in the include path.
       std::string fullName;
-      if ((srcFiles > 0) ||
-          cmSystemTools::FileIsFullPath(current.FileName.c_str())) {
-        if (cmSystemTools::FileExists(current.FileName.c_str(), true)) {
+      if ((srcFiles > 0) || cmSystemTools::FileIsFullPath(current.FileName)) {
+        if (cmSystemTools::FileExists(current.FileName, true)) {
           fullName = current.FileName;
         }
       } else if (!current.QuotedLocation.empty() &&
-                 cmSystemTools::FileExists(current.QuotedLocation.c_str(),
-                                           true)) {
+                 cmSystemTools::FileExists(current.QuotedLocation, true)) {
         // The include statement producing this entry was a double-quote
         // include and the included file is present in the directory of
         // the source containing the include statement.
@@ -157,7 +155,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
               cmSystemTools::CollapseCombinedPath(i, current.FileName);
 
             // Look for the file in this location.
-            if (cmSystemTools::FileExists(tempPathStr.c_str(), true)) {
+            if (cmSystemTools::FileExists(tempPathStr, true)) {
               fullName = tempPathStr;
               HeaderLocationCache[current.FileName] = fullName;
               break;
@@ -226,15 +224,14 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
   // directory.  We must do the same here.
   std::string binDir = this->LocalGenerator->GetBinaryDirectory();
   std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj);
-  std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
+  std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i);
   internalDepends << obj_i << std::endl;
 
   for (std::string const& dep : dependencies) {
-    makeDepends
-      << obj_m << ": "
-      << cmSystemTools::ConvertToOutputPath(
-           this->LocalGenerator->ConvertToRelativePath(binDir, dep).c_str())
-      << std::endl;
+    makeDepends << obj_m << ": "
+                << cmSystemTools::ConvertToOutputPath(
+                     this->LocalGenerator->ConvertToRelativePath(binDir, dep))
+                << std::endl;
     internalDepends << " " << dep << std::endl;
   }
   makeDepends << std::endl;
@@ -363,7 +360,7 @@ void cmDependsC::Scan(std::istream& is, const char* directory,
       entry.FileName = this->IncludeRegexLine.match(2);
       cmSystemTools::ConvertToUnixSlashes(entry.FileName);
       if (this->IncludeRegexLine.match(3) == "\"" &&
-          !cmSystemTools::FileIsFullPath(entry.FileName.c_str())) {
+          !cmSystemTools::FileIsFullPath(entry.FileName)) {
         // This was a double-quoted include with a relative path.  We
         // must check for the file in the directory containing the
         // file we are scanning.

+ 10 - 10
Source/cmDependsFortran.cxx

@@ -312,13 +312,13 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
   // Write the include dependencies to the output stream.
   std::string binDir = this->LocalGenerator->GetBinaryDirectory();
   std::string obj_i = this->MaybeConvertToRelativePath(binDir, obj);
-  std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
+  std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i);
   internalDepends << obj_i << std::endl;
   internalDepends << " " << src << std::endl;
   for (std::string const& i : info.Includes) {
     makeDepends << obj_m << ": "
                 << cmSystemTools::ConvertToOutputPath(
-                     this->MaybeConvertToRelativePath(binDir, i).c_str())
+                     this->MaybeConvertToRelativePath(binDir, i))
                 << std::endl;
     internalDepends << " " << i << std::endl;
   }
@@ -341,7 +341,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
     if (!required->second.empty()) {
       // This module is known.  Depend on its timestamp file.
       std::string stampFile = cmSystemTools::ConvertToOutputPath(
-        this->MaybeConvertToRelativePath(binDir, required->second).c_str());
+        this->MaybeConvertToRelativePath(binDir, required->second));
       makeDepends << obj_m << ": " << stampFile << "\n";
     } else {
       // This module is not known to CMake.  Try to locate it where
@@ -349,7 +349,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
       std::string module;
       if (this->FindModule(i, module)) {
         module = cmSystemTools::ConvertToOutputPath(
-          this->MaybeConvertToRelativePath(binDir, module).c_str());
+          this->MaybeConvertToRelativePath(binDir, module));
         makeDepends << obj_m << ": " << module << "\n";
       }
     }
@@ -382,7 +382,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
         this->LocalGenerator->ConvertToOutputFormat(stampFile,
                                                     cmOutputConverter::SHELL);
       std::string const stampFileForMake =
-        cmSystemTools::ConvertToOutputPath(stampFile.c_str());
+        cmSystemTools::ConvertToOutputPath(stampFile);
 
       makeDepends << obj_m << ".provides.build"
                   << ": " << stampFileForMake << "\n";
@@ -413,7 +413,7 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
     std::string driver = this->TargetDirectory;
     driver += "/build";
     driver = cmSystemTools::ConvertToOutputPath(
-      this->MaybeConvertToRelativePath(binDir, driver).c_str());
+      this->MaybeConvertToRelativePath(binDir, driver));
     makeDepends << driver << ": " << obj_m << ".provides.build\n";
   }
 
@@ -435,7 +435,7 @@ bool cmDependsFortran::FindModule(std::string const& name, std::string& module)
     fullName = ip;
     fullName += "/";
     fullName += mod_lower;
-    if (cmSystemTools::FileExists(fullName.c_str(), true)) {
+    if (cmSystemTools::FileExists(fullName, true)) {
       module = fullName;
       return true;
     }
@@ -444,7 +444,7 @@ bool cmDependsFortran::FindModule(std::string const& name, std::string& module)
     fullName = ip;
     fullName += "/";
     fullName += mod_upper;
-    if (cmSystemTools::FileExists(fullName.c_str(), true)) {
+    if (cmSystemTools::FileExists(fullName, true)) {
       module = fullName;
       return true;
     }
@@ -481,7 +481,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
   mod += ".mod";
   mod_upper += ".mod";
   mod_lower += ".mod";
-  if (cmSystemTools::FileExists(mod_upper.c_str(), true)) {
+  if (cmSystemTools::FileExists(mod_upper, true)) {
     if (cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
                                         compilerId.c_str())) {
       if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
@@ -492,7 +492,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
     }
     return true;
   }
-  if (cmSystemTools::FileExists(mod_lower.c_str(), true)) {
+  if (cmSystemTools::FileExists(mod_lower, true)) {
     if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
                                         compilerId.c_str())) {
       if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {

+ 2 - 2
Source/cmExecProgramCommand.cxx

@@ -81,7 +81,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
   std::string output;
   bool result = true;
   if (args.size() - count == 2) {
-    cmSystemTools::MakeDirectory(args[1].c_str());
+    cmSystemTools::MakeDirectory(args[1]);
     result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal,
                                               args[1].c_str(), verbose);
   } else {
@@ -149,7 +149,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
       if (quoted.find(command)) {
         std::string cmd = quoted.match(1);
         std::string args = quoted.match(2);
-        if (!cmSystemTools::FileExists(cmd.c_str())) {
+        if (!cmSystemTools::FileExists(cmd)) {
           shortCmd = cmd;
         } else if (!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd)) {
           cmSystemTools::Error("GetShortPath failed for ", cmd.c_str());

+ 1 - 1
Source/cmExecuteProcessCommand.cxx

@@ -157,7 +157,7 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
     }
   }
 
-  if (!this->Makefile->CanIWriteThisFile(output_file.c_str())) {
+  if (!this->Makefile->CanIWriteThisFile(output_file)) {
     std::string e = "attempted to output into a file: " + output_file +
       " into a source directory.";
     this->SetError(e);

+ 1 - 2
Source/cmExportBuildAndroidMKGenerator.cxx

@@ -48,8 +48,7 @@ void cmExportBuildAndroidMKGenerator::GenerateImportTargetCode(
   os << "LOCAL_MODULE := ";
   os << targetName << "\n";
   os << "LOCAL_SRC_FILES := ";
-  std::string path =
-    cmSystemTools::ConvertToOutputPath(target->GetFullPath().c_str());
+  std::string path = cmSystemTools::ConvertToOutputPath(target->GetFullPath());
   os << path << "\n";
 }
 

+ 4 - 4
Source/cmExportCommand.cxx

@@ -92,8 +92,8 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
   }
 
   // Get the file to write.
-  if (cmSystemTools::FileIsFullPath(fname.c_str())) {
-    if (!this->Makefile->CanIWriteThisFile(fname.c_str())) {
+  if (cmSystemTools::FileIsFullPath(fname)) {
+    if (!this->Makefile->CanIWriteThisFile(fname)) {
       std::ostringstream e;
       e << "FILE option given filename \"" << fname
         << "\" which is in the source tree.\n";
@@ -346,10 +346,10 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
   fname += "/.cmake/packages/";
   fname += package;
 #endif
-  cmSystemTools::MakeDirectory(fname.c_str());
+  cmSystemTools::MakeDirectory(fname);
   fname += "/";
   fname += hash;
-  if (!cmSystemTools::FileExists(fname.c_str())) {
+  if (!cmSystemTools::FileExists(fname)) {
     cmGeneratedFileStream entry(fname.c_str(), true);
     if (entry) {
       entry << content << "\n";

+ 12 - 10
Source/cmExportFileGenerator.cxx

@@ -183,7 +183,7 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
   return false;
 }
 
-static bool isSubDirectory(const char* a, const char* b)
+static bool isSubDirectory(std::string const& a, std::string const& b)
 {
   return (cmSystemTools::ComparePath(a, b) ||
           cmSystemTools::IsSubDirectory(a, b));
@@ -195,13 +195,15 @@ static bool checkInterfaceDirs(const std::string& prepro,
 {
   const char* installDir =
     target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
-  const char* topSourceDir = target->GetLocalGenerator()->GetSourceDirectory();
-  const char* topBinaryDir = target->GetLocalGenerator()->GetBinaryDirectory();
+  std::string const& topSourceDir =
+    target->GetLocalGenerator()->GetSourceDirectory();
+  std::string const& topBinaryDir =
+    target->GetLocalGenerator()->GetBinaryDirectory();
 
   std::vector<std::string> parts;
   cmGeneratorExpression::Split(prepro, parts);
 
-  const bool inSourceBuild = strcmp(topSourceDir, topBinaryDir) == 0;
+  const bool inSourceBuild = topSourceDir == topBinaryDir;
 
   bool hadFatalError = false;
 
@@ -231,10 +233,10 @@ static bool checkInterfaceDirs(const std::string& prepro,
         hadFatalError = true;
       }
     }
-    if (cmHasLiteralPrefix(li.c_str(), "${_IMPORT_PREFIX}")) {
+    if (cmHasLiteralPrefix(li, "${_IMPORT_PREFIX}")) {
       continue;
     }
-    if (!cmSystemTools::FileIsFullPath(li.c_str())) {
+    if (!cmSystemTools::FileIsFullPath(li)) {
       /* clang-format off */
       e << "Target \"" << target->GetName() << "\" " << prop <<
            " property contains relative path:\n"
@@ -242,9 +244,9 @@ static bool checkInterfaceDirs(const std::string& prepro,
       /* clang-format on */
       target->GetLocalGenerator()->IssueMessage(messageType, e.str());
     }
-    bool inBinary = isSubDirectory(li.c_str(), topBinaryDir);
-    bool inSource = isSubDirectory(li.c_str(), topSourceDir);
-    if (isSubDirectory(li.c_str(), installDir)) {
+    bool inBinary = isSubDirectory(li, topBinaryDir);
+    bool inSource = isSubDirectory(li, topSourceDir);
+    if (isSubDirectory(li, installDir)) {
       // The include directory is inside the install tree.  If the
       // install tree is not inside the source tree or build tree then
       // fall through to the checks below that the include directory is not
@@ -317,7 +319,7 @@ static void prefixItems(std::string& exportDirs)
   for (std::string const& e : entries) {
     exportDirs += sep;
     sep = ";";
-    if (!cmSystemTools::FileIsFullPath(e.c_str()) &&
+    if (!cmSystemTools::FileIsFullPath(e) &&
         e.find("${_IMPORT_PREFIX}") == std::string::npos) {
       exportDirs += "${_IMPORT_PREFIX}/";
     }

+ 7 - 7
Source/cmExportInstallFileGenerator.cxx

@@ -185,12 +185,12 @@ void cmExportInstallFileGenerator::GenerateImportPrefix(std::ostream& os)
     os << "# Compute the installation prefix relative to this file.\n"
        << "get_filename_component(_IMPORT_PREFIX"
        << " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
-    if (cmHasLiteralPrefix(absDestS.c_str(), "/lib/") ||
-        cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") ||
-        cmHasLiteralPrefix(absDestS.c_str(), "/libx32/") ||
-        cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") ||
-        cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/") ||
-        cmHasLiteralPrefix(absDestS.c_str(), "/usr/libx32/")) {
+    if (cmHasLiteralPrefix(absDestS, "/lib/") ||
+        cmHasLiteralPrefix(absDestS, "/lib64/") ||
+        cmHasLiteralPrefix(absDestS, "/libx32/") ||
+        cmHasLiteralPrefix(absDestS, "/usr/lib/") ||
+        cmHasLiteralPrefix(absDestS, "/usr/lib64/") ||
+        cmHasLiteralPrefix(absDestS, "/usr/libx32/")) {
       // Handle "/usr move" symlinks created by some Linux distros.
       /* clang-format off */
       os <<
@@ -370,7 +370,7 @@ void cmExportInstallFileGenerator::SetImportLocationProperty(
   // Construct the installed location of the target.
   std::string dest = itgen->GetDestination(config);
   std::string value;
-  if (!cmSystemTools::FileIsFullPath(dest.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(dest)) {
     // The target is installed relative to the installation prefix.
     value = "${_IMPORT_PREFIX}/";
   }

+ 6 - 8
Source/cmExtraCodeBlocksGenerator.cxx

@@ -5,7 +5,6 @@
 #include <map>
 #include <ostream>
 #include <set>
-#include <string.h>
 #include <utility>
 
 #include "cmAlgorithms.h"
@@ -225,7 +224,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
       }
 
       const std::string& relative = cmSystemTools::RelativePath(
-        it.second[0]->GetSourceDirectory(), listFile.c_str());
+        it.second[0]->GetSourceDirectory(), listFile);
       std::vector<std::string> splitted;
       cmSystemTools::SplitPath(relative, splitted, false);
       // Split filename from path
@@ -296,8 +295,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
         case cmStateEnums::GLOBAL_TARGET: {
           // Only add the global targets from CMAKE_BINARY_DIR,
           // not from the subdirs
-          if (strcmp(lg->GetCurrentBinaryDirectory(),
-                     lg->GetBinaryDirectory()) == 0) {
+          if (lg->GetCurrentBinaryDirectory() == lg->GetBinaryDirectory()) {
             this->AppendTarget(xml, targetName, nullptr, make.c_str(), lg,
                                compiler.c_str(), makeArgs);
           }
@@ -382,12 +380,12 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
             std::string const& fullPath = s->GetFullPath();
 
             // Check file position relative to project root dir.
-            const std::string& relative = cmSystemTools::RelativePath(
-              (*lg).GetSourceDirectory(), fullPath.c_str());
+            const std::string& relative =
+              cmSystemTools::RelativePath(lg->GetSourceDirectory(), fullPath);
             // Do not add this file if it has ".." in relative path and
             // if CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable is on.
             const bool excludeExternal =
-              cmSystemTools::IsOn((*lg).GetMakefile()->GetSafeDefinition(
+              cmSystemTools::IsOn(lg->GetMakefile()->GetSafeDefinition(
                 "CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES"));
             if (excludeExternal &&
                 (relative.find("..") != std::string::npos)) {
@@ -433,7 +431,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
         break;
       }
 
-      if (cmSystemTools::FileExists(hname.c_str())) {
+      if (cmSystemTools::FileExists(hname)) {
         allFiles[hname].Targets = allFiles[fileName].Targets;
         break;
       }

+ 8 - 11
Source/cmExtraCodeLiteGenerator.cxx

@@ -64,8 +64,8 @@ void cmExtraCodeLiteGenerator::Generate()
     const cmMakefile* mf = it.second[0]->GetMakefile();
     this->ConfigName = GetConfigurationName(mf);
 
-    if (strcmp(it.second[0]->GetCurrentBinaryDirectory(),
-               it.second[0]->GetBinaryDirectory()) == 0) {
+    if (it.second[0]->GetCurrentBinaryDirectory() ==
+        it.second[0]->GetBinaryDirectory()) {
       workspaceOutputDir = it.second[0]->GetCurrentBinaryDirectory();
       workspaceProjectName = it.second[0]->GetProjectName();
       workspaceSourcePath = it.second[0]->GetSourceDirectory();
@@ -127,8 +127,8 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByTarget(
       std::string filename = outputDir + "/" + targetName + ".project";
       retval.push_back(targetName);
       // Make the project file relative to the workspace
-      std::string relafilename = cmSystemTools::RelativePath(
-        this->WorkspacePath.c_str(), filename.c_str());
+      std::string relafilename =
+        cmSystemTools::RelativePath(this->WorkspacePath, filename);
       std::string visualname = targetName;
       switch (type) {
         case cmStateEnums::SHARED_LIBRARY:
@@ -167,8 +167,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps(
     std::string filename = outputDir + "/" + projectName + ".project";
 
     // Make the project file relative to the workspace
-    filename = cmSystemTools::RelativePath(this->WorkspacePath.c_str(),
-                                           filename.c_str());
+    filename = cmSystemTools::RelativePath(this->WorkspacePath, filename);
 
     // create a project file
     this->CreateProjectFile(it.second);
@@ -318,7 +317,7 @@ void cmExtraCodeLiteGenerator::FindMatchingHeaderfiles(
         break;
       }
 
-      if (cmSystemTools::FileExists(hname.c_str())) {
+      if (cmSystemTools::FileExists(hname)) {
         otherFiles.insert(hname);
         break;
       }
@@ -335,8 +334,7 @@ void cmExtraCodeLiteGenerator::CreateFoldersAndFiles(
   size_t numOfEndEl = 0;
 
   for (std::string const& cFile : cFiles) {
-    std::string frelapath =
-      cmSystemTools::RelativePath(projectPath.c_str(), cFile.c_str());
+    std::string frelapath = cmSystemTools::RelativePath(projectPath, cFile);
     cmsys::SystemTools::SplitPath(frelapath, components, false);
     components.pop_back(); // erase last member -> it is file, not folder
     components.erase(components.begin()); // erase "root"
@@ -474,8 +472,7 @@ void cmExtraCodeLiteGenerator::CreateProjectSourceEntries(
   std::string outputPath = mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
   std::string relapath;
   if (!outputPath.empty()) {
-    relapath = cmSystemTools::RelativePath(this->WorkspacePath.c_str(),
-                                           outputPath.c_str());
+    relapath = cmSystemTools::RelativePath(this->WorkspacePath, outputPath);
     xml.Attribute("OutputFile", relapath + "/$(ProjectName)");
   } else {
     xml.Attribute("OutputFile", "$(IntermediateDirectory)/$(ProjectName)");

+ 8 - 8
Source/cmExtraKateGenerator.cxx

@@ -81,12 +81,12 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
   const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
   const std::string makeArgs =
     mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS");
-  const char* homeOutputDir = lg->GetBinaryDirectory();
+  std::string const& homeOutputDir = lg->GetBinaryDirectory();
 
   /* clang-format off */
   fout <<
   "\t\"build\": {\n"
-  "\t\t\"directory\": \"" << lg->GetBinaryDirectory() << "\",\n"
+  "\t\t\"directory\": \"" << homeOutputDir << "\",\n"
   "\t\t\"default_target\": \"all\",\n"
   "\t\t\"clean_target\": \"clean\",\n";
   /* clang-format on */
@@ -195,13 +195,13 @@ void cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout,
                                         const std::string& make,
                                         const std::string& makeArgs,
                                         const std::string& path,
-                                        const char* homeOutputDir) const
+                                        const std::string& homeOutputDir) const
 {
   static char JsonSep = ' ';
 
   fout << "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", "
                                                              "\"build_cmd\":\""
-       << make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path.c_str())
+       << make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path)
        << "\\\" " << makeArgs << " " << target << "\"}\n";
 
   JsonSep = ',';
@@ -228,14 +228,14 @@ std::string cmExtraKateGenerator::GenerateFilesString(
 {
   std::string s = lg->GetSourceDirectory();
   s += "/.git";
-  if (cmSystemTools::FileExists(s.c_str())) {
-    return std::string("\"git\": 1 ");
+  if (cmSystemTools::FileExists(s)) {
+    return "\"git\": 1 ";
   }
 
   s = lg->GetSourceDirectory();
   s += "/.svn";
-  if (cmSystemTools::FileExists(s.c_str())) {
-    return std::string("\"svn\": 1 ");
+  if (cmSystemTools::FileExists(s)) {
+    return "\"svn\": 1 ";
   }
 
   s = lg->GetSourceDirectory();

+ 2 - 1
Source/cmExtraKateGenerator.h

@@ -31,7 +31,8 @@ private:
                     cmGeneratedFileStream& fout) const;
   void AppendTarget(cmGeneratedFileStream& fout, const std::string& target,
                     const std::string& make, const std::string& makeArgs,
-                    const std::string& path, const char* homeOutputDir) const;
+                    const std::string& path,
+                    const std::string& homeOutputDir) const;
 
   std::string GenerateFilesString(const cmLocalGenerator* lg) const;
   std::string GetPathBasename(const std::string& path) const;

+ 1 - 2
Source/cmExtraSublimeTextGenerator.cxx

@@ -188,8 +188,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets(
         case cmStateEnums::GLOBAL_TARGET: {
           // Only add the global targets from CMAKE_BINARY_DIR,
           // not from the subdirs
-          if (strcmp(lg->GetCurrentBinaryDirectory(),
-                     lg->GetBinaryDirectory()) == 0) {
+          if (lg->GetCurrentBinaryDirectory() == lg->GetBinaryDirectory()) {
             this->AppendTarget(fout, targetName, lg, nullptr, make.c_str(),
                                makefile, compiler.c_str(), sourceFileFlags,
                                false);

+ 21 - 23
Source/cmFileCommand.cxx

@@ -183,14 +183,14 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
   i++; // Get rid of subcommand
 
   std::string fileName = *i;
-  if (!cmsys::SystemTools::FileIsFullPath(i->c_str())) {
+  if (!cmsys::SystemTools::FileIsFullPath(*i)) {
     fileName = this->Makefile->GetCurrentSourceDirectory();
     fileName += "/" + *i;
   }
 
   i++;
 
-  if (!this->Makefile->CanIWriteThisFile(fileName.c_str())) {
+  if (!this->Makefile->CanIWriteThisFile(fileName)) {
     std::string e =
       "attempted to write a file: " + fileName + " into a source directory.";
     this->SetError(e);
@@ -198,7 +198,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
     return false;
   }
   std::string dir = cmSystemTools::GetFilenamePath(fileName);
-  cmSystemTools::MakeDirectory(dir.c_str());
+  cmSystemTools::MakeDirectory(dir);
 
   mode_t mode = 0;
 
@@ -258,7 +258,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
   argHelper.Parse(&args, nullptr);
 
   std::string fileName = fileNameArg.GetString();
-  if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) {
+  if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
     fileName = this->Makefile->GetCurrentSourceDirectory();
     fileName += "/" + fileNameArg.GetString();
   }
@@ -374,7 +374,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
 
   // Get the file to read.
   std::string fileName = args[1];
-  if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) {
+  if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
     fileName = this->Makefile->GetCurrentSourceDirectory();
     fileName += "/" + args[1];
   }
@@ -800,7 +800,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
     }
 
     cmsys::Glob::GlobMessages globMessages;
-    if (!cmsys::SystemTools::FileIsFullPath(i->c_str())) {
+    if (!cmsys::SystemTools::FileIsFullPath(*i)) {
       std::string expr = this->Makefile->GetCurrentSourceDirectory();
       // Handle script mode
       if (!expr.empty()) {
@@ -884,19 +884,19 @@ bool cmFileCommand::HandleMakeDirectoryCommand(
   std::string expr;
   for (; i != args.end(); ++i) {
     const std::string* cdir = &(*i);
-    if (!cmsys::SystemTools::FileIsFullPath(i->c_str())) {
+    if (!cmsys::SystemTools::FileIsFullPath(*i)) {
       expr = this->Makefile->GetCurrentSourceDirectory();
       expr += "/" + *i;
       cdir = &expr;
     }
-    if (!this->Makefile->CanIWriteThisFile(cdir->c_str())) {
+    if (!this->Makefile->CanIWriteThisFile(*cdir)) {
       std::string e = "attempted to create a directory: " + *cdir +
         " into a source directory.";
       this->SetError(e);
       cmSystemTools::SetFatalErrorOccured();
       return false;
     }
-    if (!cmSystemTools::MakeDirectory(cdir->c_str())) {
+    if (!cmSystemTools::MakeDirectory(*cdir)) {
       std::string error = "problem creating directory: " + *cdir;
       this->SetError(error);
       return false;
@@ -1294,7 +1294,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
       this->Files.push_back(arg);
       break;
     case DoingDestination:
-      if (arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str())) {
+      if (arg.empty() || cmSystemTools::FileIsFullPath(arg)) {
         this->Destination = arg;
       } else {
         this->Destination = this->Makefile->GetCurrentBinaryDirectory();
@@ -1303,7 +1303,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
       this->Doing = DoingNone;
       break;
     case DoingFilesFromDir:
-      if (cmSystemTools::FileIsFullPath(arg.c_str())) {
+      if (cmSystemTools::FileIsFullPath(arg)) {
         this->FilesFromDir = arg;
       } else {
         this->FilesFromDir = this->Makefile->GetCurrentSourceDirectory();
@@ -1991,7 +1991,7 @@ bool cmFileInstaller::HandleInstallDestination()
   }
 
   if (this->InstallType != cmInstallType_DIRECTORY) {
-    if (!cmSystemTools::FileExists(destination.c_str())) {
+    if (!cmSystemTools::FileExists(destination)) {
       if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) {
         std::string errstring = "cannot create directory: " + destination +
           ". Maybe need administrative privileges.";
@@ -2293,22 +2293,21 @@ bool cmFileCommand::HandleRelativePathCommand(
   const std::string& directoryName = args[2];
   const std::string& fileName = args[3];
 
-  if (!cmSystemTools::FileIsFullPath(directoryName.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(directoryName)) {
     std::string errstring =
       "RELATIVE_PATH must be passed a full path to the directory: " +
       directoryName;
     this->SetError(errstring);
     return false;
   }
-  if (!cmSystemTools::FileIsFullPath(fileName.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(fileName)) {
     std::string errstring =
       "RELATIVE_PATH must be passed a full path to the file: " + fileName;
     this->SetError(errstring);
     return false;
   }
 
-  std::string res =
-    cmSystemTools::RelativePath(directoryName.c_str(), fileName.c_str());
+  std::string res = cmSystemTools::RelativePath(directoryName, fileName);
   this->Makefile->AddDefinition(outVar, res.c_str());
   return true;
 }
@@ -2322,12 +2321,12 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args)
 
   // Compute full path for old and new names.
   std::string oldname = args[1];
-  if (!cmsys::SystemTools::FileIsFullPath(oldname.c_str())) {
+  if (!cmsys::SystemTools::FileIsFullPath(oldname)) {
     oldname = this->Makefile->GetCurrentSourceDirectory();
     oldname += "/" + args[1];
   }
   std::string newname = args[2];
-  if (!cmsys::SystemTools::FileIsFullPath(newname.c_str())) {
+  if (!cmsys::SystemTools::FileIsFullPath(newname)) {
     newname = this->Makefile->GetCurrentSourceDirectory();
     newname += "/" + args[2];
   }
@@ -2358,7 +2357,7 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
   i++; // Get rid of subcommand
   for (; i != args.end(); ++i) {
     std::string fileName = *i;
-    if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) {
+    if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
       fileName = this->Makefile->GetCurrentSourceDirectory();
       fileName += "/" + *i;
     }
@@ -2400,7 +2399,7 @@ bool cmFileCommand::HandleCMakePathCommand(
     if (!nativePath) {
       cmSystemTools::ConvertToUnixSlashes(*j);
     } else {
-      *j = cmSystemTools::ConvertToOutputPath(j->c_str());
+      *j = cmSystemTools::ConvertToOutputPath(*j);
       // remove double quotes in the path
       cmsys::String& s = *j;
 
@@ -2736,7 +2735,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   // and the existing file already has the expected hash, then simply
   // return.
   //
-  if (cmSystemTools::FileExists(file.c_str()) && hash.get()) {
+  if (cmSystemTools::FileExists(file) && hash.get()) {
     std::string msg;
     std::string actualHash = hash->HashFile(file);
     if (actualHash == expectedHash) {
@@ -2755,8 +2754,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   // as we receive downloaded bits from curl...
   //
   std::string dir = cmSystemTools::GetFilenamePath(file);
-  if (!cmSystemTools::FileExists(dir.c_str()) &&
-      !cmSystemTools::MakeDirectory(dir.c_str())) {
+  if (!cmSystemTools::FileExists(dir) && !cmSystemTools::MakeDirectory(dir)) {
     std::string errstring = "DOWNLOAD error: cannot create directory '" + dir +
       "' - Specify file by full path name and verify that you "
       "have directory creation and file write privileges.";

+ 1 - 1
Source/cmFindLibraryCommand.cxx

@@ -353,7 +353,7 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
   if (name.TryRaw) {
     this->TestPath = path;
     this->TestPath += name.Raw;
-    if (cmSystemTools::FileExists(this->TestPath.c_str(), true)) {
+    if (cmSystemTools::FileExists(this->TestPath, true)) {
       this->BestPath = cmSystemTools::CollapseFullPath(this->TestPath);
       cmSystemTools::ConvertToUnixSlashes(this->BestPath);
       return true;

+ 6 - 7
Source/cmFindPackageCommand.cxx

@@ -660,7 +660,7 @@ bool cmFindPackageCommand::HandlePackageMode()
       cmSystemTools::ConvertToUnixSlashes(dir);
 
       // Treat relative paths with respect to the current source dir.
-      if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
+      if (!cmSystemTools::FileIsFullPath(dir)) {
         dir = "/" + dir;
         dir = this->Makefile->GetCurrentSourceDirectory() + dir;
       }
@@ -1346,10 +1346,10 @@ bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname,
                                                      cmSearchPath& outPaths)
 {
   // Parse the content of one package registry entry.
-  if (cmSystemTools::FileIsFullPath(fname.c_str())) {
+  if (cmSystemTools::FileIsFullPath(fname)) {
     // The first line in the stream is the full path to a file or
     // directory containing the package.
-    if (cmSystemTools::FileExists(fname.c_str())) {
+    if (cmSystemTools::FileExists(fname)) {
       // The path exists.  Look for the package here.
       if (!cmSystemTools::FileIsDirectory(fname)) {
         outPaths.AddPath(cmSystemTools::GetFilenamePath(fname));
@@ -1442,8 +1442,7 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir,
     if (this->DebugMode) {
       fprintf(stderr, "Checking file [%s]\n", file.c_str());
     }
-    if (cmSystemTools::FileExists(file.c_str(), true) &&
-        this->CheckVersion(file)) {
+    if (cmSystemTools::FileExists(file, true) && this->CheckVersion(file)) {
       return true;
     }
   }
@@ -1463,7 +1462,7 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
   // Look for foo-config-version.cmake
   std::string version_file = version_file_base;
   version_file += "-version.cmake";
-  if (!haveResult && cmSystemTools::FileExists(version_file.c_str(), true)) {
+  if (!haveResult && cmSystemTools::FileExists(version_file, true)) {
     result = this->CheckVersionFile(version_file, version);
     haveResult = true;
   }
@@ -1471,7 +1470,7 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
   // Look for fooConfigVersion.cmake
   version_file = version_file_base;
   version_file += "Version.cmake";
-  if (!haveResult && cmSystemTools::FileExists(version_file.c_str(), true)) {
+  if (!haveResult && cmSystemTools::FileExists(version_file, true)) {
     result = this->CheckVersionFile(version_file, version);
     haveResult = true;
   }

+ 2 - 2
Source/cmFindPathCommand.cxx

@@ -94,7 +94,7 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
       std::string intPath = fpath;
       intPath += "/Headers/";
       intPath += fileName;
-      if (cmSystemTools::FileExists(intPath.c_str())) {
+      if (cmSystemTools::FileExists(intPath)) {
         if (this->IncludeFileInPath) {
           return intPath;
         }
@@ -128,7 +128,7 @@ std::string cmFindPathCommand::FindNormalHeader()
     for (std::string const& sp : this->SearchPaths) {
       tryPath = sp;
       tryPath += n;
-      if (cmSystemTools::FileExists(tryPath.c_str())) {
+      if (cmSystemTools::FileExists(tryPath)) {
         if (this->IncludeFileInPath) {
           return tryPath;
         }

+ 3 - 3
Source/cmFortranParserImpl.cxx

@@ -17,14 +17,14 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
   // If the file is a full path, include it directly.
   if (cmSystemTools::FileIsFullPath(includeName)) {
     fileName = includeName;
-    return cmSystemTools::FileExists(fileName.c_str(), true);
+    return cmSystemTools::FileExists(fileName, true);
   }
   // Check for the file in the directory containing the including
   // file.
   std::string fullName = dir;
   fullName += "/";
   fullName += includeName;
-  if (cmSystemTools::FileExists(fullName.c_str(), true)) {
+  if (cmSystemTools::FileExists(fullName, true)) {
     fileName = fullName;
     return true;
   }
@@ -34,7 +34,7 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
     fullName = i;
     fullName += "/";
     fullName += includeName;
-    if (cmSystemTools::FileExists(fullName.c_str(), true)) {
+    if (cmSystemTools::FileExists(fullName, true)) {
       fileName = fullName;
       return true;
     }

+ 1 - 1
Source/cmGeneratedFileStream.cxx

@@ -147,7 +147,7 @@ void cmGeneratedFileStreamBase::Open(const char* name)
   cmSystemTools::RemoveFile(this->TempName);
 
   std::string dir = cmSystemTools::GetFilenamePath(this->TempName);
-  cmSystemTools::MakeDirectory(dir.c_str());
+  cmSystemTools::MakeDirectory(dir);
 }
 
 bool cmGeneratedFileStreamBase::Close()

+ 1 - 1
Source/cmGeneratorExpression.cxx

@@ -203,7 +203,7 @@ static void prefixItems(const std::string& content, std::string& result,
   for (std::string const& e : entries) {
     result += sep;
     sep = ";";
-    if (!cmSystemTools::FileIsFullPath(e.c_str()) &&
+    if (!cmSystemTools::FileIsFullPath(e) &&
         cmGeneratorExpression::Find(e) != 0) {
       result += prefix;
     }

+ 1 - 2
Source/cmGeneratorExpressionNode.cxx

@@ -1074,8 +1074,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
 
     CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME)
     // Note that the above macro terminates with an else
-    /* else */ if (cmHasLiteralPrefix(propertyName.c_str(),
-                                      "COMPILE_DEFINITIONS_")) {
+    /* else */ if (cmHasLiteralPrefix(propertyName, "COMPILE_DEFINITIONS_")) {
       cmPolicies::PolicyStatus polSt =
         context->LG->GetPolicyStatus(cmPolicies::CMP0043);
       if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {

+ 5 - 5
Source/cmGeneratorTarget.cxx

@@ -842,7 +842,7 @@ static bool processSources(
         return contextDependent;
       }
 
-      if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) {
+      if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src)) {
         std::ostringstream err;
         if (!targetName.empty()) {
           err << "Target \"" << targetName
@@ -2237,7 +2237,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
     // If we find the target and the dep was given as a full path,
     // then make sure it was not a full path to something else, and
     // the fact that the name matched a target was just a coincidence.
-    if (cmSystemTools::FileIsFullPath(dep.c_str())) {
+    if (cmSystemTools::FileIsFullPath(dep)) {
       if (t->GetType() >= cmStateEnums::EXECUTABLE &&
           t->GetType() <= cmStateEnums::MODULE_LIBRARY) {
         // This is really only for compatibility so we do not need to
@@ -2437,7 +2437,7 @@ static void processIncludeDirectories(
 
     std::string usedIncludes;
     for (std::string& entryInclude : entryIncludes) {
-      if (fromImported && !cmSystemTools::FileExists(entryInclude.c_str())) {
+      if (fromImported && !cmSystemTools::FileExists(entryInclude)) {
         std::ostringstream e;
         cmake::MessageType messageType = cmake::FATAL_ERROR;
         if (checkCMP0027) {
@@ -2469,7 +2469,7 @@ static void processIncludeDirectories(
         return;
       }
 
-      if (!cmSystemTools::FileIsFullPath(entryInclude.c_str())) {
+      if (!cmSystemTools::FileIsFullPath(entryInclude)) {
         std::ostringstream e;
         bool noMessage = false;
         cmake::MessageType messageType = cmake::FATAL_ERROR;
@@ -3540,7 +3540,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
   for (std::string const& p : props) {
     std::string pname = cmSystemTools::HelpFileName(p);
     std::string pfile = pdir + pname + ".rst";
-    if (cmSystemTools::FileExists(pfile.c_str(), true)) {
+    if (cmSystemTools::FileExists(pfile, true)) {
       std::ostringstream e;
       e << "Target \"" << dependee->GetName() << "\" has property \"" << p
         << "\" listed in its " << propName

+ 1 - 1
Source/cmGetDirectoryPropertyCommand.cxx

@@ -34,7 +34,7 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
     }
     std::string sd = *i;
     // make sure the start dir is a full path
-    if (!cmSystemTools::FileIsFullPath(sd.c_str())) {
+    if (!cmSystemTools::FileIsFullPath(sd)) {
       sd = this->Makefile->GetCurrentSourceDirectory();
       sd += "/";
       sd += *i;

+ 1 - 1
Source/cmGetPropertyCommand.cxx

@@ -206,7 +206,7 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
     // Construct the directory name.  Interpret relative paths with
     // respect to the current directory.
     std::string dir = this->Name;
-    if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
+    if (!cmSystemTools::FileIsFullPath(dir)) {
       dir = this->Makefile->GetCurrentSourceDirectory();
       dir += "/";
       dir += this->Name;

+ 1 - 1
Source/cmGhsMultiTargetGenerator.cxx

@@ -493,7 +493,7 @@ void cmGhsMultiTargetGenerator::WriteSources(
     cmSystemTools::ConvertToUnixSlashes(sgPath);
     cmGlobalGhsMultiGenerator::AddFilesUpToPath(
       this->GetFolderBuildStreams(), &this->FolderBuildStreams,
-      this->LocalGenerator->GetBinaryDirectory(), sgPath,
+      this->LocalGenerator->GetBinaryDirectory().c_str(), sgPath,
       GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath);
 
     std::string fullSourcePath((*si)->GetFullPath());

+ 10 - 10
Source/cmGlobalGenerator.cxx

@@ -510,7 +510,7 @@ void cmGlobalGenerator::EnableLanguage(
   bool const readCMakeSystem = !mf->GetDefinition("CMAKE_SYSTEM_LOADED");
   if (readCMakeSystem) {
     fpath += "/CMakeSystem.cmake";
-    if (cmSystemTools::FileExists(fpath.c_str())) {
+    if (cmSystemTools::FileExists(fpath)) {
       mf->ReadListFile(fpath.c_str());
     }
   }
@@ -623,7 +623,7 @@ void cmGlobalGenerator::EnableLanguage(
       // If the existing build tree was already configured with this
       // version of CMake then try to load the configured file first
       // to avoid duplicate compiler tests.
-      if (cmSystemTools::FileExists(fpath.c_str())) {
+      if (cmSystemTools::FileExists(fpath)) {
         if (!mf->ReadListFile(fpath.c_str())) {
           cmSystemTools::Error("Could not find cmake module file: ",
                                fpath.c_str());
@@ -842,7 +842,7 @@ void cmGlobalGenerator::EnableLanguage(
   projectCompatibility += "/Modules/";
   projectCompatibility += mf->GetSafeDefinition("PROJECT_NAME");
   projectCompatibility += "Compatibility.cmake";
-  if (cmSystemTools::FileExists(projectCompatibility.c_str())) {
+  if (cmSystemTools::FileExists(projectCompatibility)) {
     mf->ReadListFile(projectCompatibility.c_str());
   }
   // Inform any extra generator of the new language.
@@ -1205,7 +1205,7 @@ void cmGlobalGenerator::Configure()
         f += this->CMakeInstance->GetCMakeFilesDirectory();
         f += "/";
         f += *log;
-        if (cmSystemTools::FileExists(f.c_str())) {
+        if (cmSystemTools::FileExists(f)) {
           msg << "\nSee also \"" << f << "\".";
         }
       }
@@ -1901,7 +1901,7 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
   const std::string& native, bool ignoreErrors)
 {
   std::string makeCommand = cmSystemTools::GetCMakeCommand();
-  makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
+  makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand);
   makeCommand += " --build .";
   if (!config.empty()) {
     makeCommand += " --config \"";
@@ -2269,7 +2269,7 @@ void cmGlobalGenerator::AddGlobalTarget_Package(
   cmMakefile* mf = this->Makefiles[0];
   std::string configFile = mf->GetCurrentBinaryDirectory();
   configFile += "/CPackConfig.cmake";
-  if (!cmSystemTools::FileExists(configFile.c_str())) {
+  if (!cmSystemTools::FileExists(configFile)) {
     return;
   }
 
@@ -2319,7 +2319,7 @@ void cmGlobalGenerator::AddGlobalTarget_PackageSource(
   cmMakefile* mf = this->Makefiles[0];
   std::string configFile = mf->GetCurrentBinaryDirectory();
   configFile += "/CPackSourceConfig.cmake";
-  if (!cmSystemTools::FileExists(configFile.c_str())) {
+  if (!cmSystemTools::FileExists(configFile)) {
     return;
   }
 
@@ -2854,7 +2854,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
       // 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());
-      if (cmSystemTools::FileExists(fpath.c_str())) {
+      if (cmSystemTools::FileExists(fpath)) {
         RuleHash hash;
         strncpy(hash.Data, line.c_str(), 32);
         this->RuleHashes[fname] = hash;
@@ -2920,7 +2920,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
     Json::Value& lj_target_labels = lj_target["labels"] = Json::arrayValue;
     Json::Value& lj_sources = lj_root["sources"] = Json::arrayValue;
 
-    cmSystemTools::MakeDirectory(dir.c_str());
+    cmSystemTools::MakeDirectory(dir);
     cmGeneratedFileStream fout(file.c_str());
 
     std::vector<std::string> labels;
@@ -3066,7 +3066,7 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile()
   std::string path = this->CMakeInstance->GetHomeOutputDirectory();
   path += "/CPackProperties.cmake";
 
-  if (!cmSystemTools::FileExists(path.c_str()) && installedFiles.empty()) {
+  if (!cmSystemTools::FileExists(path) && installedFiles.empty()) {
     return true;
   }
 

+ 2 - 2
Source/cmGlobalGhsMultiGenerator.cxx

@@ -447,8 +447,8 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles(
           this->TargetFolderBuildStreams.find(folderName)) {
         this->AddFilesUpToPath(
           GetBuildFileStream(), &this->TargetFolderBuildStreams,
-          this->GetCMakeInstance()->GetHomeOutputDirectory(), folderName,
-          GhsMultiGpj::PROJECT);
+          this->GetCMakeInstance()->GetHomeOutputDirectory().c_str(),
+          folderName, GhsMultiGpj::PROJECT);
       }
       std::vector<cmsys::String> splitPath = cmSystemTools::SplitString(
         cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt));

+ 2 - 2
Source/cmGlobalNinjaGenerator.cxx

@@ -870,7 +870,7 @@ std::string const& cmGlobalNinjaGenerator::ConvertToNinjaPath(
 
   cmLocalNinjaGenerator* ng =
     static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
-  const char* bin_dir = ng->GetState()->GetBinaryDirectory();
+  std::string const& bin_dir = ng->GetState()->GetBinaryDirectory();
   std::string convPath = ng->ConvertToRelativePath(bin_dir, path);
   convPath = this->NinjaOutputPath(convPath);
 #ifdef _WIN32
@@ -902,7 +902,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
   }
 
   std::string sourceFileName = sourceFile;
-  if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(sourceFileName)) {
     sourceFileName = cmSystemTools::CollapseFullPath(
       sourceFileName, this->GetCMakeInstance()->GetHomeOutputDirectory());
   }

+ 3 - 4
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -459,10 +459,9 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2(
   }
 
   // Begin the directory-level rules section.
-  std::string dir = cmSystemTools::ConvertToOutputPath(
-    lg->ConvertToRelativePath(lg->GetBinaryDirectory(),
-                              lg->GetCurrentBinaryDirectory())
-      .c_str());
+  std::string dir =
+    cmSystemTools::ConvertToOutputPath(lg->ConvertToRelativePath(
+      lg->GetBinaryDirectory(), lg->GetCurrentBinaryDirectory()));
   lg->WriteDivider(ruleFileStream);
   ruleFileStream << "# Directory level rules for directory " << dir << "\n\n";
 

+ 1 - 1
Source/cmGlobalVisualStudioGenerator.cxx

@@ -916,7 +916,7 @@ bool cmGlobalVisualStudioGenerator::Open(const std::string& bindir,
                                          const std::string& projectName,
                                          bool dryRun)
 {
-  std::string buildDir = cmSystemTools::ConvertToOutputPath(bindir.c_str());
+  std::string buildDir = cmSystemTools::ConvertToOutputPath(bindir);
   std::string sln = buildDir + "\\" + projectName + ".sln";
 
   if (dryRun) {

+ 2 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -3442,7 +3442,8 @@ void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry)
   entry.Brief = "Generate Xcode project files.";
 }
 
-std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(const char* p)
+std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(
+  std::string const& p)
 {
   return cmSystemTools::ConvertToOutputPath(p);
 }

+ 1 - 1
Source/cmGlobalXCodeGenerator.h

@@ -119,7 +119,7 @@ private:
   std::string XCodeEscapePath(const std::string& p);
   std::string RelativeToSource(const char* p);
   std::string RelativeToBinary(const char* p);
-  std::string ConvertToRelativeForMake(const char* p);
+  std::string ConvertToRelativeForMake(std::string const& p);
   void CreateCustomCommands(cmXCodeObject* buildPhases,
                             cmXCodeObject* sourceBuildPhase,
                             cmXCodeObject* headerBuildPhase,

+ 2 - 2
Source/cmIncludeCommand.cxx

@@ -63,7 +63,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
     return true;
   }
 
-  if (!cmSystemTools::FileIsFullPath(fname.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(fname)) {
     // Not a path. Maybe module.
     std::string module = fname;
     module += ".cmake";
@@ -112,7 +112,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
 
   std::string listFile = cmSystemTools::CollapseFullPath(
     fname, this->Makefile->GetCurrentSourceDirectory());
-  if (optional && !cmSystemTools::FileExists(listFile.c_str())) {
+  if (optional && !cmSystemTools::FileExists(listFile)) {
     if (!resultVarName.empty()) {
       this->Makefile->AddDefinition(resultVarName, "NOTFOUND");
     }

+ 1 - 1
Source/cmIncludeDirectoryCommand.cxx

@@ -123,7 +123,7 @@ void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc)
   if (!cmSystemTools::IsOff(inc.c_str())) {
     cmSystemTools::ConvertToUnixSlashes(inc);
 
-    if (!cmSystemTools::FileIsFullPath(inc.c_str())) {
+    if (!cmSystemTools::FileIsFullPath(inc)) {
       if (!StartsWithGeneratorExpression(inc)) {
         std::string tmp = this->Makefile->GetCurrentSourceDirectory();
         tmp += "/";

+ 4 - 4
Source/cmInstallCommand.cxx

@@ -155,7 +155,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
     } else if (doing_script) {
       doing_script = false;
       std::string script = arg;
-      if (!cmSystemTools::FileIsFullPath(script.c_str())) {
+      if (!cmSystemTools::FileIsFullPath(script)) {
         script = this->Makefile->GetCurrentSourceDirectory();
         script += "/";
         script += arg;
@@ -1045,14 +1045,14 @@ bool cmInstallCommand::HandleDirectoryMode(
       // Convert this directory to a full path.
       std::string dir = args[i];
       std::string::size_type gpos = cmGeneratorExpression::Find(dir);
-      if (gpos != 0 && !cmSystemTools::FileIsFullPath(dir.c_str())) {
+      if (gpos != 0 && !cmSystemTools::FileIsFullPath(dir)) {
         dir = this->Makefile->GetCurrentSourceDirectory();
         dir += "/";
         dir += args[i];
       }
 
       // Make sure the name is a directory.
-      if (cmSystemTools::FileExists(dir.c_str()) &&
+      if (cmSystemTools::FileExists(dir) &&
           !cmSystemTools::FileIsDirectory(dir)) {
         std::ostringstream e;
         e << args[0] << " given non-directory \"" << args[i]
@@ -1375,7 +1375,7 @@ bool cmInstallCommand::MakeFilesFullPath(
   for (std::string const& relFile : relFiles) {
     std::string file = relFile;
     std::string::size_type gpos = cmGeneratorExpression::Find(file);
-    if (gpos != 0 && !cmSystemTools::FileIsFullPath(file.c_str())) {
+    if (gpos != 0 && !cmSystemTools::FileIsFullPath(file)) {
       file = this->Makefile->GetCurrentSourceDirectory();
       file += "/";
       file += relFile;

+ 1 - 1
Source/cmInstallDirectoryGenerator.cxx

@@ -72,7 +72,7 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig(
   // Make sure all dirs have absolute paths.
   cmMakefile const& mf = *this->LocalGenerator->GetMakefile();
   for (std::string& d : dirs) {
-    if (!cmSystemTools::FileIsFullPath(d.c_str())) {
+    if (!cmSystemTools::FileIsFullPath(d)) {
       d = std::string(mf.GetCurrentSourceDirectory()) + "/" + d;
     }
   }

+ 1 - 1
Source/cmInstallExportGenerator.cxx

@@ -132,7 +132,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
 
   // Create the temporary directory in which to store the files.
   this->ComputeTempDir();
-  cmSystemTools::MakeDirectory(this->TempDir.c_str());
+  cmSystemTools::MakeDirectory(this->TempDir);
 
   // Construct a temporary location for the file.
   this->MainImportFile = this->TempDir;

+ 2 - 2
Source/cmInstallFilesCommand.cxx

@@ -137,11 +137,11 @@ std::string cmInstallFilesCommand::FindInstallSource(const char* name) const
   ts += "/";
   ts += name;
 
-  if (cmSystemTools::FileExists(tb.c_str())) {
+  if (cmSystemTools::FileExists(tb)) {
     // The file exists in the binary tree.  Use it.
     return tb;
   }
-  if (cmSystemTools::FileExists(ts.c_str())) {
+  if (cmSystemTools::FileExists(ts)) {
     // The file exists in the source tree.  Use it.
     return ts;
   }

+ 2 - 2
Source/cmInstallGenerator.cxx

@@ -55,7 +55,7 @@ void cmInstallGenerator::AddInstallRule(
       break;
   }
   os << indent;
-  if (cmSystemTools::FileIsFullPath(dest.c_str())) {
+  if (cmSystemTools::FileIsFullPath(dest)) {
     os << "list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n";
     os << indent << " \"";
     for (std::vector<std::string>::const_iterator fi = files.begin();
@@ -165,7 +165,7 @@ std::string cmInstallGenerator::ConvertToAbsoluteDestination(
   std::string const& dest) const
 {
   std::string result;
-  if (!dest.empty() && !cmSystemTools::FileIsFullPath(dest.c_str())) {
+  if (!dest.empty() && !cmSystemTools::FileIsFullPath(dest)) {
     result = "${CMAKE_INSTALL_PREFIX}/";
   }
   result += dest;

+ 2 - 2
Source/cmInstallProgramsCommand.cxx

@@ -109,11 +109,11 @@ std::string cmInstallProgramsCommand::FindInstallSource(const char* name) const
   ts += "/";
   ts += name;
 
-  if (cmSystemTools::FileExists(tb.c_str())) {
+  if (cmSystemTools::FileExists(tb)) {
     // The file exists in the binary tree.  Use it.
     return tb;
   }
-  if (cmSystemTools::FileExists(ts.c_str())) {
+  if (cmSystemTools::FileExists(ts)) {
     // The file exists in the source tree.  Use it.
     return ts;
   }

+ 1 - 1
Source/cmLinkDirectoriesCommand.cxx

@@ -29,7 +29,7 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
 {
   std::string unixPath = dir;
   cmSystemTools::ConvertToUnixSlashes(unixPath);
-  if (!cmSystemTools::FileIsFullPath(unixPath.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(unixPath)) {
     bool convertToAbsolute = false;
     std::ostringstream e;
     /* clang-format off */

+ 1 - 1
Source/cmLoadCacheCommand.cxx

@@ -82,7 +82,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
 
   // Make sure the cache file exists.
   std::string cacheFile = args[0] + "/CMakeCache.txt";
-  if (!cmSystemTools::FileExists(cacheFile.c_str())) {
+  if (!cmSystemTools::FileExists(cacheFile)) {
     std::string e = "Cannot load cache file from " + cacheFile;
     this->SetError(e);
     return false;

+ 14 - 14
Source/cmLocalGenerator.cxx

@@ -904,8 +904,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
   // Support putting all the in-project include directories first if
   // it is requested by the project.
   if (this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")) {
-    const char* topSourceDir = this->GetState()->GetSourceDirectory();
-    const char* topBinaryDir = this->GetState()->GetBinaryDirectory();
+    std::string const &topSourceDir = this->GetState()->GetSourceDirectory(),
+                      &topBinaryDir = this->GetState()->GetBinaryDirectory();
     for (std::string const& i : includes) {
       // Emit this directory only if it is a subdirectory of the
       // top-level source or binary tree.
@@ -1416,7 +1416,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
   if (cmGeneratorTarget* target = this->FindGeneratorTargetToUse(name)) {
     // make sure it is not just a coincidence that the target name
     // found is part of the inName
-    if (cmSystemTools::FileIsFullPath(inName.c_str())) {
+    if (cmSystemTools::FileIsFullPath(inName)) {
       std::string tLocation;
       if (target->GetType() >= cmStateEnums::EXECUTABLE &&
           target->GetType() <= cmStateEnums::MODULE_LIBRARY) {
@@ -1460,7 +1460,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
   }
 
   // The name was not that of a CMake target.  It must name a file.
-  if (cmSystemTools::FileIsFullPath(inName.c_str())) {
+  if (cmSystemTools::FileIsFullPath(inName)) {
     // This is a full path.  Return it as given.
     dep = inName;
     return true;
@@ -1966,7 +1966,7 @@ void cmLocalGenerator::AppendIncludeDirectories(
   std::unordered_set<std::string> uniqueIncludes;
 
   for (const std::string& include : includes_vec) {
-    if (!cmSystemTools::FileIsFullPath(include.c_str())) {
+    if (!cmSystemTools::FileIsFullPath(include)) {
       std::ostringstream e;
       e << "Found relative path while evaluating include directories of "
            "\""
@@ -2389,14 +2389,14 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
   std::string relFromSource =
     this->ConvertToRelativePath(this->GetCurrentSourceDirectory(), fullPath);
   assert(!relFromSource.empty());
-  bool relSource = !cmSystemTools::FileIsFullPath(relFromSource.c_str());
+  bool relSource = !cmSystemTools::FileIsFullPath(relFromSource);
   bool subSource = relSource && relFromSource[0] != '.';
 
   // Try referencing the source relative to the binary tree.
   std::string relFromBinary =
     this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), fullPath);
   assert(!relFromBinary.empty());
-  bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary.c_str());
+  bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary);
   bool subBinary = relBinary && relFromBinary[0] != '.';
 
   // Select a nice-looking reference to the source file to construct
@@ -2415,7 +2415,7 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
   // if it is still a full path check for the try compile case
   // try compile never have in source sources, and should not
   // have conflicting source file names in the same target
-  if (cmSystemTools::FileIsFullPath(objectName.c_str())) {
+  if (cmSystemTools::FileIsFullPath(objectName)) {
     if (this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) {
       objectName = cmSystemTools::GetFilenameName(source.GetFullPath());
     }
@@ -2473,12 +2473,12 @@ cmake* cmLocalGenerator::GetCMakeInstance() const
   return this->GlobalGenerator->GetCMakeInstance();
 }
 
-const char* cmLocalGenerator::GetSourceDirectory() const
+std::string const& cmLocalGenerator::GetSourceDirectory() const
 {
   return this->GetCMakeInstance()->GetHomeDirectory();
 }
 
-const char* cmLocalGenerator::GetBinaryDirectory() const
+std::string const& cmLocalGenerator::GetBinaryDirectory() const
 {
   return this->GetCMakeInstance()->GetHomeOutputDirectory();
 }
@@ -2617,13 +2617,13 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
   // Find the Info.plist template.
   const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
   std::string inFile = (in && *in) ? in : "MacOSXBundleInfo.plist.in";
-  if (!cmSystemTools::FileIsFullPath(inFile.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(inFile)) {
     std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
     if (!inMod.empty()) {
       inFile = inMod;
     }
   }
-  if (!cmSystemTools::FileExists(inFile.c_str(), true)) {
+  if (!cmSystemTools::FileExists(inFile, true)) {
     std::ostringstream e;
     e << "Target " << target->GetName() << " Info.plist template \"" << inFile
       << "\" could not be found.";
@@ -2655,13 +2655,13 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
   // Find the Info.plist template.
   const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
   std::string inFile = (in && *in) ? in : "MacOSXFrameworkInfo.plist.in";
-  if (!cmSystemTools::FileIsFullPath(inFile.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(inFile)) {
     std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
     if (!inMod.empty()) {
       inFile = inMod;
     }
   }
-  if (!cmSystemTools::FileExists(inFile.c_str(), true)) {
+  if (!cmSystemTools::FileExists(inFile, true)) {
     std::ostringstream e;
     e << "Target " << target->GetName() << " Info.plist template \"" << inFile
       << "\" could not be found.";

+ 2 - 2
Source/cmLocalGenerator.h

@@ -287,8 +287,8 @@ public:
 
   cmake* GetCMakeInstance() const;
 
-  const char* GetSourceDirectory() const;
-  const char* GetBinaryDirectory() const;
+  std::string const& GetSourceDirectory() const;
+  std::string const& GetBinaryDirectory() const;
 
   const char* GetCurrentBinaryDirectory() const;
   const char* GetCurrentSourceDirectory() const;

+ 9 - 10
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -172,7 +172,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
       bool hasSourceExtension = true;
       std::string objectName =
         this->GetObjectFileNameWithoutTarget(*sf, dir, &hasSourceExtension);
-      if (cmSystemTools::FileIsFullPath(objectName.c_str())) {
+      if (cmSystemTools::FileIsFullPath(objectName)) {
         objectName = cmSystemTools::GetFilenameName(objectName);
       }
       LocalObjectInfo& info = localObjectFiles[objectName];
@@ -525,8 +525,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
 
   // Construct the left hand side of the rule.
   std::string tgt = cmSystemTools::ConvertToOutputPath(
-    this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), target)
-      .c_str());
+    this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), target));
 
   const char* space = "";
   if (tgt.size() == 1) {
@@ -554,7 +553,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
     for (std::string const& depend : depends) {
       replace = depend;
       replace = cmSystemTools::ConvertToOutputPath(
-        this->MaybeConvertToRelativePath(binDir, replace).c_str());
+        this->MaybeConvertToRelativePath(binDir, replace));
       os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n";
     }
   }
@@ -574,7 +573,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
 std::string cmLocalUnixMakefileGenerator3::MaybeConvertWatcomShellCommand(
   std::string const& cmd)
 {
-  if (this->IsWatcomWMake() && cmSystemTools::FileIsFullPath(cmd.c_str()) &&
+  if (this->IsWatcomWMake() && cmSystemTools::FileIsFullPath(cmd) &&
       cmd.find_first_of("( )") != std::string::npos) {
     // On Watcom WMake use the windows short path for the command
     // name.  This is needed to avoid funny quoting problems on
@@ -1028,7 +1027,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
   }
 
   // Setup the proper working directory for the commands.
-  this->CreateCDCommand(commands1, dir.c_str(), relative);
+  this->CreateCDCommand(commands1, dir, relative);
 
   // push back the custom commands
   commands.insert(commands.end(), commands1.begin(), commands1.end());
@@ -1476,8 +1475,8 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
 
     // If the depender is missing then delete the dependee to make
     // sure both will be regenerated.
-    if (cmSystemTools::FileExists(dependee.c_str()) &&
-        !cmSystemTools::FileExists(depender.c_str())) {
+    if (cmSystemTools::FileExists(dependee) &&
+        !cmSystemTools::FileExists(depender)) {
       if (verbose) {
         std::ostringstream msg;
         msg << "Deleting primary custom command output \"" << dependee
@@ -1828,7 +1827,7 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
     this->GetIncludeDirectories(includes, target, implicitLang.first, config);
     std::string binaryDir = this->GetState()->GetBinaryDirectory();
     if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) {
-      const char* sourceDir = this->GetState()->GetSourceDirectory();
+      std::string const& sourceDir = this->GetState()->GetSourceDirectory();
       cmEraseIf(includes, ::NotInProjectDir(sourceDir, binaryDir));
     }
     for (std::string const& include : includes) {
@@ -2029,7 +2028,7 @@ void cmLocalUnixMakefileGenerator3::AddImplicitDepends(
 }
 
 void cmLocalUnixMakefileGenerator3::CreateCDCommand(
-  std::vector<std::string>& commands, const char* tgtDir,
+  std::vector<std::string>& commands, std::string const& tgtDir,
   std::string const& relDir)
 {
   // do we need to cd?

+ 2 - 1
Source/cmLocalUnixMakefileGenerator3.h

@@ -117,7 +117,8 @@ public:
 
   // create a command that cds to the start dir then runs the commands
   void CreateCDCommand(std::vector<std::string>& commands,
-                       const char* targetDir, std::string const& relDir);
+                       std::string const& targetDir,
+                       std::string const& relDir);
 
   static std::string ConvertToQuotedOutputPath(const char* p,
                                                bool useWatcomQuote);

+ 1 - 2
Source/cmLocalVisualStudio7Generator.cxx

@@ -115,8 +115,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
 void cmLocalVisualStudio7Generator::WriteProjectFiles()
 {
   // If not an in source build, then create the output directory
-  if (strcmp(this->GetCurrentBinaryDirectory(), this->GetSourceDirectory()) !=
-      0) {
+  if (this->GetCurrentBinaryDirectory() != this->GetSourceDirectory()) {
     if (!cmSystemTools::MakeDirectory(this->GetCurrentBinaryDirectory())) {
       cmSystemTools::Error("Error creating directory ",
                            this->GetCurrentBinaryDirectory());

+ 2 - 2
Source/cmMakeDirectoryCommand.cxx

@@ -15,13 +15,13 @@ bool cmMakeDirectoryCommand::InitialPass(std::vector<std::string> const& args,
     this->SetError("called with incorrect number of arguments");
     return false;
   }
-  if (!this->Makefile->CanIWriteThisFile(args[0].c_str())) {
+  if (!this->Makefile->CanIWriteThisFile(args[0])) {
     std::string e = "attempted to create a directory: " + args[0] +
       " into a source directory.";
     this->SetError(e);
     cmSystemTools::SetFatalErrorOccured();
     return false;
   }
-  cmSystemTools::MakeDirectory(args[0].c_str());
+  cmSystemTools::MakeDirectory(args[0]);
   return true;
 }

+ 15 - 15
Source/cmMakefile.cxx

@@ -1104,9 +1104,9 @@ cmTarget* cmMakefile::AddUtilityCommand(
   return target;
 }
 
-void cmMakefile::AddDefineFlag(const char* flag)
+void cmMakefile::AddDefineFlag(std::string const& flag)
 {
-  if (!flag) {
+  if (flag.empty()) {
     return;
   }
 
@@ -1122,7 +1122,7 @@ void cmMakefile::AddDefineFlag(const char* flag)
   this->AddDefineFlag(flag, this->DefineFlags);
 }
 
-void cmMakefile::AddDefineFlag(const char* flag, std::string& dflags)
+void cmMakefile::AddDefineFlag(std::string const& flag, std::string& dflags)
 {
   // remove any \n\r
   std::string::size_type initSize = dflags.size();
@@ -1132,14 +1132,13 @@ void cmMakefile::AddDefineFlag(const char* flag, std::string& dflags)
   std::replace(flagStart, dflags.end(), '\r', ' ');
 }
 
-void cmMakefile::RemoveDefineFlag(const char* flag)
+void cmMakefile::RemoveDefineFlag(std::string const& flag)
 {
   // Check the length of the flag to remove.
-  std::string::size_type len = strlen(flag);
-  if (len < 1) {
+  if (flag.empty()) {
     return;
   }
-
+  std::string::size_type const len = flag.length();
   // Update the string used for the old DEFINITIONS property.
   this->RemoveDefineFlag(flag, len, this->DefineFlagsOrig);
 
@@ -1152,7 +1151,8 @@ void cmMakefile::RemoveDefineFlag(const char* flag)
   this->RemoveDefineFlag(flag, len, this->DefineFlags);
 }
 
-void cmMakefile::RemoveDefineFlag(const char* flag, std::string::size_type len,
+void cmMakefile::RemoveDefineFlag(std::string const& flag,
+                                  std::string::size_type len,
                                   std::string& dflags)
 {
   // Remove all instances of the flag that are surrounded by
@@ -1169,9 +1169,9 @@ void cmMakefile::RemoveDefineFlag(const char* flag, std::string::size_type len,
   }
 }
 
-void cmMakefile::AddCompileOption(const char* option)
+void cmMakefile::AddCompileOption(std::string const& option)
 {
-  this->AppendProperty("COMPILE_OPTIONS", option);
+  this->AppendProperty("COMPILE_OPTIONS", option.c_str());
 }
 
 bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
@@ -2292,7 +2292,7 @@ const char* cmMakefile::GetSONameFlag(const std::string& language) const
   return GetDefinition(name);
 }
 
-bool cmMakefile::CanIWriteThisFile(const char* fileName) const
+bool cmMakefile::CanIWriteThisFile(std::string const& fileName) const
 {
   if (!this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES")) {
     return true;
@@ -3105,19 +3105,19 @@ std::unique_ptr<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
   return std::unique_ptr<cmFunctionBlocker>();
 }
 
-const char* cmMakefile::GetHomeDirectory() const
+std::string const& cmMakefile::GetHomeDirectory() const
 {
   return this->GetCMakeInstance()->GetHomeDirectory();
 }
 
-const char* cmMakefile::GetHomeOutputDirectory() const
+std::string const& cmMakefile::GetHomeOutputDirectory() const
 {
   return this->GetCMakeInstance()->GetHomeOutputDirectory();
 }
 
-void cmMakefile::SetScriptModeFile(const char* scriptfile)
+void cmMakefile::SetScriptModeFile(std::string const& scriptfile)
 {
-  this->AddDefinition("CMAKE_SCRIPT_MODE_FILE", scriptfile);
+  this->AddDefinition("CMAKE_SCRIPT_MODE_FILE", scriptfile.c_str());
 }
 
 void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)

+ 10 - 9
Source/cmMakefile.h

@@ -166,9 +166,9 @@ public:
   /**
    * Add a define flag to the build.
    */
-  void AddDefineFlag(const char* definition);
-  void RemoveDefineFlag(const char* definition);
-  void AddCompileOption(const char* option);
+  void AddDefineFlag(std::string const& definition);
+  void RemoveDefineFlag(std::string const& definition);
+  void AddCompileOption(std::string const& option);
 
   /** Create a new imported target with the name and type given.  */
   cmTarget* AddImportedTarget(const std::string& name,
@@ -309,13 +309,13 @@ public:
 
   bool IgnoreErrorsCMP0061() const;
 
-  const char* GetHomeDirectory() const;
-  const char* GetHomeOutputDirectory() const;
+  std::string const& GetHomeDirectory() const;
+  std::string const& GetHomeOutputDirectory() const;
 
   /**
    * Set CMAKE_SCRIPT_MODE_FILE variable when running a -P script.
    */
-  void SetScriptModeFile(const char* scriptfile);
+  void SetScriptModeFile(std::string const& scriptfile);
 
   /**
    * Set CMAKE_ARGC, CMAKE_ARGV0 ... variables.
@@ -473,7 +473,7 @@ public:
   /**
    * Make sure CMake can write this file
    */
-  bool CanIWriteThisFile(const char* fileName) const;
+  bool CanIWriteThisFile(std::string const& fileName) const;
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   /**
@@ -878,8 +878,9 @@ protected:
   std::string DefineFlags;
 
   // Track the value of the computed DEFINITIONS property.
-  void AddDefineFlag(const char*, std::string&);
-  void RemoveDefineFlag(const char*, std::string::size_type, std::string&);
+  void AddDefineFlag(std::string const& flag, std::string&);
+  void RemoveDefineFlag(std::string const& flag, std::string::size_type,
+                        std::string&);
   std::string DefineFlagsOrig;
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)

+ 5 - 5
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -326,28 +326,28 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
     outpath = this->Makefile->GetCurrentBinaryDirectory();
     outpath += cmake::GetCMakeFilesDirectory();
     outpath += "/CMakeRelink.dir";
-    cmSystemTools::MakeDirectory(outpath.c_str());
+    cmSystemTools::MakeDirectory(outpath);
     outpath += "/";
     if (!targetNameImport.empty()) {
       outpathImp = outpath;
     }
   } else {
-    cmSystemTools::MakeDirectory(outpath.c_str());
+    cmSystemTools::MakeDirectory(outpath);
     if (!targetNameImport.empty()) {
       outpathImp = this->GeneratorTarget->GetDirectory(
         this->ConfigName, cmStateEnums::ImportLibraryArtifact);
-      cmSystemTools::MakeDirectory(outpathImp.c_str());
+      cmSystemTools::MakeDirectory(outpathImp);
       outpathImp += "/";
     }
   }
 
   std::string compilePdbOutputPath =
     this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName);
-  cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+  cmSystemTools::MakeDirectory(compilePdbOutputPath);
 
   std::string pdbOutputPath =
     this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
-  cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
+  cmSystemTools::MakeDirectory(pdbOutputPath);
   pdbOutputPath += "/";
 
   std::string targetFullPath = outpath + targetName;

+ 5 - 5
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -525,30 +525,30 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
     outpath = this->Makefile->GetCurrentBinaryDirectory();
     outpath += cmake::GetCMakeFilesDirectory();
     outpath += "/CMakeRelink.dir";
-    cmSystemTools::MakeDirectory(outpath.c_str());
+    cmSystemTools::MakeDirectory(outpath);
     outpath += "/";
     if (!targetNameImport.empty()) {
       outpathImp = outpath;
     }
   } else {
     outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
-    cmSystemTools::MakeDirectory(outpath.c_str());
+    cmSystemTools::MakeDirectory(outpath);
     outpath += "/";
     if (!targetNameImport.empty()) {
       outpathImp = this->GeneratorTarget->GetDirectory(
         this->ConfigName, cmStateEnums::ImportLibraryArtifact);
-      cmSystemTools::MakeDirectory(outpathImp.c_str());
+      cmSystemTools::MakeDirectory(outpathImp);
       outpathImp += "/";
     }
   }
 
   std::string compilePdbOutputPath =
     this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName);
-  cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+  cmSystemTools::MakeDirectory(compilePdbOutputPath);
 
   std::string pdbOutputPath =
     this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
-  cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
+  cmSystemTools::MakeDirectory(pdbOutputPath);
   pdbOutputPath += "/";
 
   std::string targetFullPath = outpath + targetName;

+ 10 - 18
Source/cmMakefileTargetGenerator.cxx

@@ -89,7 +89,7 @@ void cmMakefileTargetGenerator::CreateRuleFile()
     this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
   this->TargetBuildDirectoryFull =
     this->LocalGenerator->ConvertToFullPath(this->TargetBuildDirectory);
-  cmSystemTools::MakeDirectory(this->TargetBuildDirectoryFull.c_str());
+  cmSystemTools::MakeDirectory(this->TargetBuildDirectoryFull);
 
   // Construct the rule file name.
   this->BuildFileName = this->TargetBuildDirectory;
@@ -200,10 +200,8 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
     << "# Include any dependencies generated for this target.\n"
     << this->GlobalGenerator->IncludeDirective << " " << root
     << cmSystemTools::ConvertToOutputPath(
-         this->LocalGenerator
-           ->MaybeConvertToRelativePath(
-             this->LocalGenerator->GetBinaryDirectory(), dependFileNameFull)
-           .c_str())
+         this->LocalGenerator->MaybeConvertToRelativePath(
+           this->LocalGenerator->GetBinaryDirectory(), dependFileNameFull))
     << "\n\n";
 
   if (!this->NoRuleMessages) {
@@ -212,16 +210,14 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
       << "# Include the progress variables for this target.\n"
       << this->GlobalGenerator->IncludeDirective << " " << root
       << cmSystemTools::ConvertToOutputPath(
-           this->LocalGenerator
-             ->MaybeConvertToRelativePath(
-               this->LocalGenerator->GetBinaryDirectory(),
-               this->ProgressFileNameFull)
-             .c_str())
+           this->LocalGenerator->MaybeConvertToRelativePath(
+             this->LocalGenerator->GetBinaryDirectory(),
+             this->ProgressFileNameFull))
       << "\n\n";
   }
 
   // make sure the depend file exists
-  if (!cmSystemTools::FileExists(dependFileNameFull.c_str())) {
+  if (!cmSystemTools::FileExists(dependFileNameFull)) {
     // Write an empty dependency file.
     cmGeneratedFileStream depFileStream(
       dependFileNameFull.c_str(), false,
@@ -250,11 +246,8 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
     << "# Include the compile flags for this target's objects.\n"
     << this->GlobalGenerator->IncludeDirective << " " << root
     << cmSystemTools::ConvertToOutputPath(
-         this->LocalGenerator
-           ->MaybeConvertToRelativePath(
-             this->LocalGenerator->GetBinaryDirectory(),
-             this->FlagFileNameFull)
-           .c_str())
+         this->LocalGenerator->MaybeConvertToRelativePath(
+           this->LocalGenerator->GetBinaryDirectory(), this->FlagFileNameFull))
     << "\n\n";
 }
 
@@ -368,8 +361,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
   // Create the directory containing the object file.  This may be a
   // subdirectory under the target's directory.
   std::string dir = cmSystemTools::GetFilenamePath(obj);
-  cmSystemTools::MakeDirectory(
-    this->LocalGenerator->ConvertToFullPath(dir).c_str());
+  cmSystemTools::MakeDirectory(this->LocalGenerator->ConvertToFullPath(dir));
 
   // Save this in the target's list of object files.
   this->Objects.push_back(obj);

+ 3 - 5
Source/cmMakefileUtilityTargetGenerator.cxx

@@ -46,11 +46,9 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
       << "# Include the progress variables for this target.\n"
       << this->GlobalGenerator->IncludeDirective << " " << root
       << cmSystemTools::ConvertToOutputPath(
-           this->LocalGenerator
-             ->MaybeConvertToRelativePath(
-               this->LocalGenerator->GetBinaryDirectory(),
-               this->ProgressFileNameFull)
-             .c_str())
+           this->LocalGenerator->MaybeConvertToRelativePath(
+             this->LocalGenerator->GetBinaryDirectory(),
+             this->ProgressFileNameFull))
       << "\n\n";
   }
 

+ 4 - 4
Source/cmNinjaTargetGenerator.cxx

@@ -1083,7 +1083,7 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
 
   std::string escapedSourceFileName = sourceFileName;
 
-  if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(sourceFileName)) {
     escapedSourceFileName = cmSystemTools::CollapseFullPath(
       escapedSourceFileName, this->GetGlobalGenerator()
                                ->GetCMakeInstance()
@@ -1143,8 +1143,8 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
 void cmNinjaTargetGenerator::EnsureDirectoryExists(
   const std::string& path) const
 {
-  if (cmSystemTools::FileIsFullPath(path.c_str())) {
-    cmSystemTools::MakeDirectory(path.c_str());
+  if (cmSystemTools::FileIsFullPath(path)) {
+    cmSystemTools::MakeDirectory(path);
   } else {
     cmGlobalNinjaGenerator* gg = this->GetGlobalGenerator();
     std::string fullPath =
@@ -1152,7 +1152,7 @@ void cmNinjaTargetGenerator::EnsureDirectoryExists(
     // Also ensures their is a trailing slash.
     gg->StripNinjaOutputPathPrefixAsSuffix(fullPath);
     fullPath += path;
-    cmSystemTools::MakeDirectory(fullPath.c_str());
+    cmSystemTools::MakeDirectory(fullPath);
   }
 }
 

+ 5 - 5
Source/cmOSXBundleGenerator.cxx

@@ -43,7 +43,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
   out += "/";
   out += this->GT->GetAppBundleDirectory(this->ConfigName,
                                          cmGeneratorTarget::FullLevel);
-  cmSystemTools::MakeDirectory(out.c_str());
+  cmSystemTools::MakeDirectory(out);
   this->Makefile->AddCMakeOutputFile(out);
 
   // Configure the Info.plist file.  Note that it needs the executable name
@@ -105,10 +105,10 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
   // Make foo.framework/Versions
   std::string versions = contentdir;
   versions += "Versions";
-  cmSystemTools::MakeDirectory(versions.c_str());
+  cmSystemTools::MakeDirectory(versions);
 
   // Make foo.framework/Versions/version
-  cmSystemTools::MakeDirectory(newoutpath.c_str());
+  cmSystemTools::MakeDirectory(newoutpath);
 
   // Current -> version
   oldName = frameworkVersion;
@@ -173,7 +173,7 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
   out += "/";
   out += this->GT->GetCFBundleDirectory(this->ConfigName,
                                         cmGeneratorTarget::FullLevel);
-  cmSystemTools::MakeDirectory(out.c_str());
+  cmSystemTools::MakeDirectory(out);
   this->Makefile->AddCMakeOutputFile(out);
 
   // Configure the Info.plist file.  Note that it needs the executable name
@@ -213,7 +213,7 @@ std::string cmOSXBundleGenerator::InitMacOSXContentDirectory(
     this->ConfigName, cmStateEnums::RuntimeBinaryArtifact);
   macdir += "/";
   macdir += pkgloc;
-  cmSystemTools::MakeDirectory(macdir.c_str());
+  cmSystemTools::MakeDirectory(macdir);
 
   // Record use of this content location.  Only the first level
   // directory is needed.

+ 1 - 1
Source/cmOrderDirectories.cxx

@@ -118,7 +118,7 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir,
   std::string file = dir;
   file += "/";
   file += name;
-  if (cmSystemTools::FileExists(file.c_str(), true)) {
+  if (cmSystemTools::FileExists(file, true)) {
     // The file conflicts only if it is not the same as the original
     // file due to a symlink or hardlink.
     return !cmSystemTools::SameFile(this->FullPath, file);

+ 2 - 2
Source/cmOutputConverter.cxx

@@ -29,7 +29,7 @@ std::string cmOutputConverter::ConvertToOutputForExisting(
   // space.
   if (this->GetState()->UseWindowsShell() &&
       remote.find(' ') != std::string::npos &&
-      cmSystemTools::FileExists(remote.c_str())) {
+      cmSystemTools::FileExists(remote)) {
     std::string tmp;
     if (cmSystemTools::GetShortPath(remote, tmp)) {
       return this->ConvertToOutputFormat(tmp, format);
@@ -125,7 +125,7 @@ std::string cmOutputConverter::ForceToRelativePath(
   assert(local_path.empty() || local_path[local_path.size() - 1] != '/');
 
   // If the path is already relative then just return the path.
-  if (!cmSystemTools::FileIsFullPath(remote_path.c_str())) {
+  if (!cmSystemTools::FileIsFullPath(remote_path)) {
     return remote_path;
   }
 

+ 11 - 11
Source/cmOutputRequiredFilesCommand.cxx

@@ -173,7 +173,7 @@ protected:
 
     std::string line;
     while (cmSystemTools::GetLineFromStream(fin, line)) {
-      if (cmHasLiteralPrefix(line.c_str(), "#include")) {
+      if (cmHasLiteralPrefix(line, "#include")) {
         // if it is an include line then create a string class
         size_t qstart = line.find('\"', 8);
         size_t qend;
@@ -213,51 +213,51 @@ protected:
           cxxFile = root + ".cxx";
           bool found = false;
           // try jumping to .cxx .cpp and .c in order
-          if (cmSystemTools::FileExists(cxxFile.c_str())) {
+          if (cmSystemTools::FileExists(cxxFile)) {
             found = true;
           }
           for (std::string path : this->IncludeDirectories) {
             path = path + "/";
             path = path + cxxFile;
-            if (cmSystemTools::FileExists(path.c_str())) {
+            if (cmSystemTools::FileExists(path)) {
               found = true;
             }
           }
           if (!found) {
             cxxFile = root + ".cpp";
-            if (cmSystemTools::FileExists(cxxFile.c_str())) {
+            if (cmSystemTools::FileExists(cxxFile)) {
               found = true;
             }
             for (std::string path : this->IncludeDirectories) {
               path = path + "/";
               path = path + cxxFile;
-              if (cmSystemTools::FileExists(path.c_str())) {
+              if (cmSystemTools::FileExists(path)) {
                 found = true;
               }
             }
           }
           if (!found) {
             cxxFile = root + ".c";
-            if (cmSystemTools::FileExists(cxxFile.c_str())) {
+            if (cmSystemTools::FileExists(cxxFile)) {
               found = true;
             }
             for (std::string path : this->IncludeDirectories) {
               path = path + "/";
               path = path + cxxFile;
-              if (cmSystemTools::FileExists(path.c_str())) {
+              if (cmSystemTools::FileExists(path)) {
                 found = true;
               }
             }
           }
           if (!found) {
             cxxFile = root + ".txx";
-            if (cmSystemTools::FileExists(cxxFile.c_str())) {
+            if (cmSystemTools::FileExists(cxxFile)) {
               found = true;
             }
             for (std::string path : this->IncludeDirectories) {
               path = path + "/";
               path = path + cxxFile;
-              if (cmSystemTools::FileExists(path.c_str())) {
+              if (cmSystemTools::FileExists(path)) {
                 found = true;
               }
             }
@@ -426,7 +426,7 @@ protected:
         path = path + "/";
       }
       path = path + fname;
-      if (cmSystemTools::FileExists(path.c_str(), true) &&
+      if (cmSystemTools::FileExists(path, true) &&
           !cmSystemTools::FileIsDirectory(path)) {
         std::string fp = cmSystemTools::CollapseFullPath(path);
         this->DirectoryToFileToPathMap[extraPath ? extraPath : ""][fname] = fp;
@@ -440,7 +440,7 @@ protected:
         path = path + "/";
       }
       path = path + fname;
-      if (cmSystemTools::FileExists(path.c_str(), true) &&
+      if (cmSystemTools::FileExists(path, true) &&
           !cmSystemTools::FileIsDirectory(path)) {
         std::string fp = cmSystemTools::CollapseFullPath(path);
         this->DirectoryToFileToPathMap[extraPath][fname] = fp;

+ 1 - 1
Source/cmQTWrapCPPCommand.cxx

@@ -47,7 +47,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
 
       // Compute the name of the header from which to generate the file.
       std::string hname;
-      if (cmSystemTools::FileIsFullPath(j->c_str())) {
+      if (cmSystemTools::FileIsFullPath(*j)) {
         hname = *j;
       } else {
         if (curr && curr->GetPropertyAsBool("GENERATED")) {

+ 1 - 1
Source/cmQTWrapUICommand.cxx

@@ -55,7 +55,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
 
       // Compute the name of the ui file from which to generate others.
       std::string uiName;
-      if (cmSystemTools::FileIsFullPath(j->c_str())) {
+      if (cmSystemTools::FileIsFullPath(*j)) {
         uiName = *j;
       } else {
         if (curr && curr->GetPropertyAsBool("GENERATED")) {

+ 3 - 3
Source/cmQtAutoGenInitializer.cxx

@@ -169,9 +169,9 @@ static std::string FileProjectRelativePath(cmMakefile* makefile,
   std::string res;
   {
     std::string pSource = cmSystemTools::RelativePath(
-      makefile->GetCurrentSourceDirectory(), fileName.c_str());
+      makefile->GetCurrentSourceDirectory(), fileName);
     std::string pBinary = cmSystemTools::RelativePath(
-      makefile->GetCurrentBinaryDirectory(), fileName.c_str());
+      makefile->GetCurrentBinaryDirectory(), fileName);
     if (pSource.size() < pBinary.size()) {
       res = std::move(pSource);
     } else if (pBinary.size() < fileName.size()) {
@@ -1387,7 +1387,7 @@ bool cmQtAutoGenInitializer::RccListInputs(std::string const& fileName,
                                            std::vector<std::string>& files,
                                            std::string& error)
 {
-  if (!cmSystemTools::FileExists(fileName.c_str())) {
+  if (!cmSystemTools::FileExists(fileName)) {
     error = "rcc resource file does not exist:\n  ";
     error += Quoted(fileName);
     error += "\n";

Some files were not shown because too many files changed in this diff