浏览代码

stringapi: Use strings in target name

Ben Boeckel 11 年之前
父节点
当前提交
fabf1fbabb
共有 58 个文件被更改,包括 287 次插入274 次删除
  1. 2 1
      Source/CTest/cmCTestBuildCommand.cxx
  2. 3 3
      Source/cmBuildCommand.cxx
  3. 5 4
      Source/cmComputeLinkDepends.cxx
  4. 2 1
      Source/cmComputeLinkDepends.h
  5. 1 1
      Source/cmComputeLinkInformation.cxx
  6. 8 7
      Source/cmComputeTargetDepends.cxx
  7. 5 3
      Source/cmComputeTargetDepends.h
  8. 6 5
      Source/cmCoreTryCompile.cxx
  9. 1 1
      Source/cmCoreTryCompile.h
  10. 3 2
      Source/cmExtraCodeBlocksGenerator.cxx
  11. 2 2
      Source/cmExtraCodeBlocksGenerator.h
  12. 3 2
      Source/cmExtraSublimeTextGenerator.cxx
  13. 2 2
      Source/cmExtraSublimeTextGenerator.h
  14. 2 2
      Source/cmGeneratorTarget.cxx
  15. 1 1
      Source/cmGeneratorTarget.h
  16. 1 1
      Source/cmGetPropertyCommand.cxx
  17. 12 12
      Source/cmGlobalGenerator.cxx
  18. 10 9
      Source/cmGlobalGenerator.h
  19. 3 3
      Source/cmGlobalNinjaGenerator.cxx
  20. 1 1
      Source/cmGlobalNinjaGenerator.h
  21. 5 7
      Source/cmGlobalUnixMakefileGenerator3.cxx
  22. 1 1
      Source/cmGlobalUnixMakefileGenerator3.h
  23. 7 6
      Source/cmGlobalVisualStudio10Generator.cxx
  24. 1 1
      Source/cmGlobalVisualStudio10Generator.h
  25. 6 5
      Source/cmGlobalVisualStudio6Generator.cxx
  26. 1 1
      Source/cmGlobalVisualStudio6Generator.h
  27. 7 6
      Source/cmGlobalVisualStudio7Generator.cxx
  28. 1 1
      Source/cmGlobalVisualStudio7Generator.h
  29. 1 1
      Source/cmGlobalVisualStudio8Generator.cxx
  30. 3 3
      Source/cmGlobalVisualStudioGenerator.cxx
  31. 2 2
      Source/cmGlobalVisualStudioGenerator.h
  32. 12 11
      Source/cmGlobalXCodeGenerator.cxx
  33. 2 2
      Source/cmGlobalXCodeGenerator.h
  34. 4 4
      Source/cmGraphVizWriter.cxx
  35. 4 4
      Source/cmGraphVizWriter.h
  36. 10 10
      Source/cmLocalGenerator.cxx
  37. 3 3
      Source/cmLocalGenerator.h
  38. 7 7
      Source/cmLocalUnixMakefileGenerator3.cxx
  39. 5 4
      Source/cmLocalUnixMakefileGenerator3.h
  40. 11 11
      Source/cmLocalVisualStudio6Generator.cxx
  41. 6 6
      Source/cmLocalVisualStudio6Generator.h
  42. 15 15
      Source/cmLocalVisualStudio7Generator.cxx
  43. 9 8
      Source/cmLocalVisualStudio7Generator.h
  44. 32 36
      Source/cmMakefile.cxx
  45. 15 14
      Source/cmMakefile.h
  46. 1 1
      Source/cmMakefileExecutableTargetGenerator.cxx
  47. 2 2
      Source/cmMakefileLibraryTargetGenerator.cxx
  48. 3 3
      Source/cmMakefileTargetGenerator.cxx
  49. 1 1
      Source/cmMakefileTargetGenerator.h
  50. 1 1
      Source/cmMakefileUtilityTargetGenerator.cxx
  51. 1 1
      Source/cmNinjaNormalTargetGenerator.cxx
  52. 7 7
      Source/cmQtAutoGenerators.cxx
  53. 1 1
      Source/cmSetPropertyCommand.cxx
  54. 1 1
      Source/cmSetTargetPropertiesCommand.cxx
  55. 1 1
      Source/cmSetTargetPropertiesCommand.h
  56. 15 13
      Source/cmTarget.cxx
  57. 9 9
      Source/cmTarget.h
  58. 1 1
      Source/cmXCodeObject.h

+ 2 - 1
Source/CTest/cmCTestBuildCommand.cxx

@@ -130,7 +130,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
       std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
       std::string buildCommand
         = this->GlobalGenerator->
-        GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration,
+        GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "",
+                                  cmakeBuildConfiguration,
                                   cmakeBuildAdditionalFlags, true);
       cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                  "SetMakeCommand:"

+ 3 - 3
Source/cmBuildCommand.cxx

@@ -44,7 +44,7 @@ bool cmBuildCommand
   // Parse remaining arguments.
   const char* configuration = 0;
   const char* project_name = 0;
-  const char* target = 0;
+  std::string target;
   enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget };
   Doing doing = DoingNone;
   for(unsigned int i=1; i < args.size(); ++i)
@@ -74,7 +74,7 @@ bool cmBuildCommand
     else if(doing == DoingTarget)
       {
       doing = DoingNone;
-      target = args[i].c_str();
+      target = args[i];
       }
     else
       {
@@ -136,7 +136,7 @@ bool cmBuildCommand
     }
 
   std::string makecommand = this->Makefile->GetLocalGenerator()
-    ->GetGlobalGenerator()->GenerateCMakeBuildCommand(0, configType.c_str(),
+    ->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType.c_str(),
                                                       0, true);
 
   if(cacheValue)

+ 5 - 4
Source/cmComputeLinkDepends.cxx

@@ -254,7 +254,8 @@ cmComputeLinkDepends::Compute()
             "---------------------------------------"
             "---------------------------------------\n");
     fprintf(stderr, "Link dependency analysis for target %s, config %s\n",
-            this->Target->GetName(), this->Config?this->Config:"noconfig");
+            this->Target->GetName().c_str(),
+            this->Config?this->Config:"noconfig");
     this->DisplayConstraintGraph();
     }
 
@@ -620,7 +621,7 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index,
 
 //----------------------------------------------------------------------------
 cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
-                                                 const char* name)
+                                                 const std::string& name)
 {
   // Look for a target in the scope of the depender.
   cmMakefile* mf = this->Makefile;
@@ -968,14 +969,14 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
 //----------------------------------------------------------------------------
 void cmComputeLinkDepends::DisplayFinalEntries()
 {
-  fprintf(stderr, "target [%s] links to:\n", this->Target->GetName());
+  fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str());
   for(std::vector<LinkEntry>::const_iterator lei =
         this->FinalLinkEntries.begin();
       lei != this->FinalLinkEntries.end(); ++lei)
     {
     if(lei->Target)
       {
-      fprintf(stderr, "  target [%s]\n", lei->Target->GetName());
+      fprintf(stderr, "  target [%s]\n", lei->Target->GetName().c_str());
       }
     else
       {

+ 2 - 1
Source/cmComputeLinkDepends.h

@@ -83,7 +83,8 @@ private:
   void AddDirectLinkEntries();
   void AddLinkEntries(int depender_index,
                       std::vector<std::string> const& libs);
-  cmTarget const* FindTargetToLink(int depender_index, const char* name);
+  cmTarget const* FindTargetToLink(int depender_index,
+                                   const std::string& name);
 
   // One entry for each unique item.
   std::vector<LinkEntry> EntryList;

+ 1 - 1
Source/cmComputeLinkInformation.cxx

@@ -500,7 +500,7 @@ bool cmComputeLinkInformation::Compute()
     {
     cmSystemTools::
       Error("CMake can not determine linker language for target: ",
-            this->Target->GetName());
+            this->Target->GetName().c_str());
     return false;
     }
 

+ 8 - 7
Source/cmComputeTargetDepends.cxx

@@ -298,7 +298,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
 
 //----------------------------------------------------------------------------
 void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
-                                             const char* dependee_name,
+                                             const std::string& dependee_name,
                                              bool linking,
                                              std::set<cmStdString> &emitted)
 {
@@ -333,7 +333,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
 
 //----------------------------------------------------------------------------
 void cmComputeTargetDepends::AddTargetDepend(int depender_index,
-                                             const char* dependee_name,
+                                             const std::string& dependee_name,
                                              bool linking)
 {
   // Get the depender.
@@ -434,22 +434,23 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
 
 //----------------------------------------------------------------------------
 void
-cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name)
+cmComputeTargetDepends::DisplayGraph(Graph const& graph,
+                                     const std::string& name)
 {
-  fprintf(stderr, "The %s target dependency graph is:\n", name);
+  fprintf(stderr, "The %s target dependency graph is:\n", name.c_str());
   int n = static_cast<int>(graph.size());
   for(int depender_index = 0; depender_index < n; ++depender_index)
     {
     EdgeList const& nl = graph[depender_index];
     cmTarget const* depender = this->Targets[depender_index];
     fprintf(stderr, "target %d is [%s]\n",
-            depender_index, depender->GetName());
+            depender_index, depender->GetName().c_str());
     for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
       {
       int dependee_index = *ni;
       cmTarget const* dependee = this->Targets[dependee_index];
       fprintf(stderr, "  depends on target %d [%s] (%s)\n", dependee_index,
-              dependee->GetName(), ni->IsStrong()? "strong" : "weak");
+              dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak");
       }
     }
   fprintf(stderr, "\n");
@@ -471,7 +472,7 @@ cmComputeTargetDepends
       {
       int i = *ni;
       fprintf(stderr, "  contains target %d [%s]\n",
-              i, this->Targets[i]->GetName());
+              i, this->Targets[i]->GetName().c_str());
       }
     }
   fprintf(stderr, "\n");

+ 5 - 3
Source/cmComputeTargetDepends.h

@@ -45,12 +45,14 @@ private:
   void CollectTargets();
   void CollectDepends();
   void CollectTargetDepends(int depender_index);
-  void AddTargetDepend(int depender_index, const char* dependee_name,
+  void AddTargetDepend(int depender_index,
+                       const std::string& dependee_name,
                        bool linking);
   void AddTargetDepend(int depender_index, cmTarget const* dependee,
                        bool linking);
   bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
-  void AddInterfaceDepends(int depender_index, const char* dependee_name,
+  void AddInterfaceDepends(int depender_index,
+                           const std::string& dependee_name,
                            bool linking, std::set<cmStdString> &emitted);
   void AddInterfaceDepends(int depender_index, cmTarget const* dependee,
                            const char *config,
@@ -71,7 +73,7 @@ private:
   typedef cmGraphAdjacencyList Graph;
   Graph InitialGraph;
   Graph FinalGraph;
-  void DisplayGraph(Graph const& graph, const char* name);
+  void DisplayGraph(Graph const& graph, const std::string& name);
 
   // Deal with connected components.
   void DisplayComponents(cmComputeComponentGraph const& ccg);

+ 6 - 5
Source/cmCoreTryCompile.cxx

@@ -28,7 +28,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
 
   const char* sourceDirectory = argv[2].c_str();
   const char* projectName = 0;
-  const char* targetName = 0;
+  std::string targetName;
   std::vector<std::string> cmakeFlags;
   std::vector<std::string> compileDefs;
   std::string outputVariable;
@@ -450,7 +450,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
     fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
             this->BinaryDirectory.c_str());
     /* Create the actual executable.  */
-    fprintf(fout, "add_executable(%s", targetName);
+    fprintf(fout, "add_executable(%s", targetName.c_str());
     for(std::vector<std::string>::iterator si = sources.begin();
         si != sources.end(); ++si)
       {
@@ -466,12 +466,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
     if (useOldLinkLibs)
       {
       fprintf(fout,
-              "target_link_libraries(%s ${LINK_LIBRARIES})\n",targetName);
+              "target_link_libraries(%s ${LINK_LIBRARIES})\n",
+              targetName.c_str());
       }
     else
       {
       fprintf(fout, "target_link_libraries(%s %s)\n",
-              targetName,
+              targetName.c_str(),
               libsToLink.c_str());
       }
     fclose(fout);
@@ -610,7 +611,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
     }
 }
 
-void cmCoreTryCompile::FindOutputFile(const char* targetName)
+void cmCoreTryCompile::FindOutputFile(const std::string& targetName)
 {
   this->FindErrorMessage = "";
   this->OutputFile = "";

+ 1 - 1
Source/cmCoreTryCompile.h

@@ -44,7 +44,7 @@ public:
   TryCompileCode. The result is stored in OutputFile. If nothing is found,
   the error message is stored in FindErrorMessage.
    */
-  void FindOutputFile(const char* targetName);
+  void FindOutputFile(const std::string& targetName);
 
 
   cmTypeMacro(cmCoreTryCompile, cmCommand);

+ 3 - 2
Source/cmExtraCodeBlocksGenerator.cxx

@@ -537,7 +537,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
 
 // Generate the xml code for one target.
 void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
-                                              const char* targetName,
+                                              const std::string& targetName,
                                               cmTarget* target,
                                               const char* make,
                                               const cmMakefile* makefile,
@@ -757,7 +757,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target)
 // Create the command line for building the given target using the selected
 // make
 std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
-             const std::string& make, const char* makefile, const char* target)
+             const std::string& make, const char* makefile,
+             const std::string& target)
 {
   std::string command = make;
   if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)

+ 2 - 2
Source/cmExtraCodeBlocksGenerator.h

@@ -49,9 +49,9 @@ private:
   std::string GetCBCompilerId(const cmMakefile* mf);
   int GetCBTargetType(cmTarget* target);
   std::string BuildMakeCommand(const std::string& make, const char* makefile,
-                               const char* target);
+                               const std::string& target);
   void AppendTarget(cmGeneratedFileStream& fout,
-                    const char* targetName,
+                    const std::string& targetName,
                     cmTarget* target,
                     const char* make,
                     const cmMakefile* makefile,

+ 3 - 2
Source/cmExtraSublimeTextGenerator.cxx

@@ -223,7 +223,7 @@ void cmExtraSublimeTextGenerator::
 
 void cmExtraSublimeTextGenerator::
   AppendTarget(cmGeneratedFileStream& fout,
-               const char* targetName,
+               const std::string& targetName,
                cmLocalGenerator* lg,
                cmTarget* target,
                const char* make,
@@ -315,7 +315,8 @@ void cmExtraSublimeTextGenerator::
 // Create the command line for building the given target using the selected
 // make
 std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
-             const std::string& make, const char* makefile, const char* target)
+             const std::string& make, const char* makefile,
+             const std::string& target)
 {
   std::string command = "\"";
   command += make + "\"";

+ 2 - 2
Source/cmExtraSublimeTextGenerator.h

@@ -60,12 +60,12 @@ private:
    *  specified target.
    */
   std::string BuildMakeCommand(const std::string& make, const char* makefile,
-                               const char* target);
+                               const std::string& target);
   /** Appends the specified target to the generated project file as a Sublime
    *  Text build system.
    */
   void AppendTarget(cmGeneratedFileStream& fout,
-                    const char* targetName,
+                    const std::string& targetName,
                     cmLocalGenerator* lg,
                     cmTarget* target,
                     const char* make,

+ 2 - 2
Source/cmGeneratorTarget.cxx

@@ -228,7 +228,7 @@ int cmGeneratorTarget::GetType() const
 }
 
 //----------------------------------------------------------------------------
-const char *cmGeneratorTarget::GetName() const
+std::string cmGeneratorTarget::GetName() const
 {
   return this->Target->GetName();
 }
@@ -988,7 +988,7 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const
 bool cmStrictTargetComparison::operator()(cmTarget const* t1,
                                           cmTarget const* t2) const
 {
-  int nameResult = strcmp(t1->GetName(), t2->GetName());
+  int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
   if (nameResult == 0)
     {
     return strcmp(t1->GetMakefile()->GetStartOutputDirectory(),

+ 1 - 1
Source/cmGeneratorTarget.h

@@ -27,7 +27,7 @@ public:
   cmGeneratorTarget(cmTarget*);
 
   int GetType() const;
-  const char *GetName() const;
+  std::string GetName() const;
   const char *GetProperty(const std::string& prop) const;
   bool GetPropertyAsBool(const std::string& prop) const;
   void GetSourceFiles(std::vector<cmSourceFile*>& files) const;

+ 1 - 1
Source/cmGetPropertyCommand.cxx

@@ -295,7 +295,7 @@ bool cmGetPropertyCommand::HandleTargetMode()
       if(cmTarget* target =
                           this->Makefile->FindTargetToUse(this->Name))
         {
-        return this->StoreResult(target->GetName());
+        return this->StoreResult(target->GetName().c_str());
         }
       }
     return this->StoreResult((this->Variable + "-NOTFOUND").c_str());

+ 12 - 12
Source/cmGlobalGenerator.cxx

@@ -1616,7 +1616,7 @@ void cmGlobalGenerator::CheckLocalGenerators()
 
 int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
                                   const char *projectName,
-                                  const char *target, bool fast,
+                                  const std::string& target, bool fast,
                                   std::string *output, cmMakefile *mf)
 {
   // if this is not set, then this is a first time configure
@@ -1640,7 +1640,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
     }
 
   std::string newTarget;
-  if (target && strlen(target))
+  if (!target.empty())
     {
     newTarget += target;
 #if 0
@@ -1664,7 +1664,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
 
 void cmGlobalGenerator::GenerateBuildCommand(
   std::vector<std::string>& makeCommand, const char*, const char*, const char*,
-  const char*, const char*, bool, std::vector<std::string> const&)
+  const std::string&, const char*, bool, std::vector<std::string> const&)
 {
   makeCommand.push_back(
     "cmGlobalGenerator::GenerateBuildCommand not implemented");
@@ -1672,7 +1672,7 @@ void cmGlobalGenerator::GenerateBuildCommand(
 
 int cmGlobalGenerator::Build(
   const char *, const char *bindir,
-  const char *projectName, const char *target,
+  const char *projectName, const std::string& target,
   std::string *output,
   const char *makeCommandCSTR,
   const char *config,
@@ -1787,7 +1787,7 @@ int cmGlobalGenerator::Build(
 
 //----------------------------------------------------------------------------
 std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
-  const char* target, const char* config, const char* native,
+  const std::string& target, const char* config, const char* native,
   bool ignoreErrors)
 {
   std::string makeCommand = cmSystemTools::GetCMakeCommand();
@@ -1799,7 +1799,7 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
     makeCommand += config;
     makeCommand += "\"";
     }
-  if(target && *target)
+  if(!target.empty())
     {
     makeCommand += " --target \"";
     makeCommand += target;
@@ -2041,7 +2041,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
 
 ///! Find a local generator by its startdirectory
 cmLocalGenerator*
-cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const
+cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
 {
   for(std::vector<cmLocalGenerator*>::const_iterator it =
       this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it)
@@ -2056,20 +2056,20 @@ cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const
 }
 
 //----------------------------------------------------------------------------
-void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt)
+void cmGlobalGenerator::AddAlias(const std::string& name, cmTarget *tgt)
 {
   this->AliasTargets[name] = tgt;
 }
 
 //----------------------------------------------------------------------------
-bool cmGlobalGenerator::IsAlias(const char *name) const
+bool cmGlobalGenerator::IsAlias(const std::string& name) const
 {
   return this->AliasTargets.find(name) != this->AliasTargets.end();
 }
 
 //----------------------------------------------------------------------------
 cmTarget*
-cmGlobalGenerator::FindTarget(const char* project, const char* name,
+cmGlobalGenerator::FindTarget(const char* project, const std::string& name,
                               bool excludeAliases) const
 {
   // if project specific
@@ -2481,7 +2481,7 @@ void cmGlobalGenerator::EnableMinGWLanguage(cmMakefile *mf)
 
 //----------------------------------------------------------------------------
 cmTarget cmGlobalGenerator::CreateGlobalTarget(
-  const char* name, const char* message,
+  const std::string& name, const char* message,
   const cmCustomCommandLines* commandLines,
   std::vector<std::string> depends,
   const char* workingDirectory)
@@ -2672,7 +2672,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets,
 bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const
 {
   return (target->GetType() == cmTarget::GLOBAL_TARGET ||
-          strcmp(target->GetName(), this->GetAllTargetName()) == 0);
+          target->GetName() == this->GetAllTargetName());
 }
 
 //----------------------------------------------------------------------------

+ 10 - 9
Source/cmGlobalGenerator.h

@@ -106,7 +106,8 @@ public:
    * loaded commands, not as part of the usual build process.
    */
   virtual int TryCompile(const char *srcdir, const char *bindir,
-                         const char *projectName, const char *targetName,
+                         const char *projectName,
+                         const std::string& targetName,
                          bool fast, std::string *output, cmMakefile* mf);
 
 
@@ -117,7 +118,7 @@ public:
    * done first.
    */
   int Build(const char *srcdir, const char *bindir,
-            const char *projectName, const char *targetName,
+            const char *projectName, const std::string& targetName,
             std::string *output,
             const char *makeProgram, const char *config,
             bool clean, bool fast,
@@ -130,12 +131,12 @@ public:
     std::vector<std::string>& makeCommand,
     const char* makeProgram,
     const char *projectName, const char *projectDir,
-    const char *targetName, const char* config, bool fast,
+    const std::string& targetName, const char* config, bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
     );
 
   /** Generate a "cmake --build" call for a given target and config.  */
-  std::string GenerateCMakeBuildCommand(const char* target,
+  std::string GenerateCMakeBuildCommand(const std::string& target,
                                         const char* config,
                                         const char* native,
                                         bool ignoreErrors);
@@ -210,11 +211,11 @@ public:
   virtual void FindMakeProgram(cmMakefile*);
 
   ///! Find a target by name by searching the local generators.
-  cmTarget* FindTarget(const char* project, const char* name,
+  cmTarget* FindTarget(const char* project, const std::string& name,
                        bool excludeAliases = false) const;
 
-  void AddAlias(const char *name, cmTarget *tgt);
-  bool IsAlias(const char *name) const;
+  void AddAlias(const std::string& name, cmTarget *tgt);
+  bool IsAlias(const std::string& name) const;
 
   /** Determine if a name resolves to a framework on disk or a built target
       that is a framework. */
@@ -224,7 +225,7 @@ public:
       target in the project */
   bool IsDependedOn(const char* project, cmTarget const* target);
   ///! Find a local generator by its startdirectory
-  cmLocalGenerator* FindLocalGenerator(const char* start_dir) const;
+  cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const;
 
   /** Append the subdirectory for the given configuration.  If anything is
       appended the given prefix and suffix will be appended around it, which
@@ -355,7 +356,7 @@ protected:
   bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const;
   void FillLocalGeneratorToTargetMap();
   void CreateDefaultGlobalTargets(cmTargets* targets);
-  cmTarget CreateGlobalTarget(const char* name, const char* message,
+  cmTarget CreateGlobalTarget(const std::string& name, const char* message,
     const cmCustomCommandLines* commandLines,
     std::vector<std::string> depends, const char* workingDir);
 

+ 3 - 3
Source/cmGlobalNinjaGenerator.cxx

@@ -554,7 +554,7 @@ void cmGlobalNinjaGenerator
                        const char* makeProgram,
                        const char* /*projectName*/,
                        const char* /*projectDir*/,
-                       const char* targetName,
+                       const std::string& targetName,
                        const char* /*config*/,
                        bool /*fast*/,
                        std::vector<std::string> const& makeOptions)
@@ -565,9 +565,9 @@ void cmGlobalNinjaGenerator
 
   makeCommand.insert(makeCommand.end(),
                      makeOptions.begin(), makeOptions.end());
-  if(targetName && *targetName)
+  if(!targetName.empty())
     {
-    if(strcmp(targetName, "clean") == 0)
+    if(targetName == "clean")
       {
       makeCommand.push_back("-t");
       makeCommand.push_back("clean");

+ 1 - 1
Source/cmGlobalNinjaGenerator.h

@@ -196,7 +196,7 @@ public:
     const char* makeProgram,
     const char* projectName,
     const char* projectDir,
-    const char* targetName,
+    const std::string& targetName,
     const char* config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()

+ 5 - 7
Source/cmGlobalUnixMakefileGenerator3.cxx

@@ -568,7 +568,7 @@ void cmGlobalUnixMakefileGenerator3
                        const char* makeProgram,
                        const char* /*projectName*/,
                        const char* /*projectDir*/,
-                       const char* targetName,
+                       const std::string& targetName,
                        const char* /*config*/,
                        bool fast,
                        std::vector<std::string> const& makeOptions)
@@ -585,7 +585,7 @@ void cmGlobalUnixMakefileGenerator3
     }
   makeCommand.insert(makeCommand.end(),
                      makeOptions.begin(), makeOptions.end());
-  if ( targetName && strlen(targetName))
+  if (!targetName.empty())
     {
     cmLocalUnixMakefileGenerator3 *lg;
     if (this->LocalGenerators.size())
@@ -649,8 +649,7 @@ cmGlobalUnixMakefileGenerator3
         }
       // Don't emit the same rule twice (e.g. two targets with the same
       // simple name)
-      if(t->second->GetName() &&
-         strlen(t->second->GetName()) &&
+      if(!t->second->GetName().empty() &&
          emitted.insert(t->second->GetName()).second &&
          // Handle user targets here.  Global targets are handled in
          // the local generator on a per-directory basis.
@@ -746,8 +745,7 @@ cmGlobalUnixMakefileGenerator3
       {
       continue;
       }
-    if (t->second->GetName()
-     && strlen(t->second->GetName())
+    if (!t->second->GetName().empty()
      && ((t->second->GetType() == cmTarget::EXECUTABLE)
         || (t->second->GetType() == cmTarget::STATIC_LIBRARY)
         || (t->second->GetType() == cmTarget::SHARED_LIBRARY)
@@ -975,7 +973,7 @@ cmGlobalUnixMakefileGenerator3::ProgressMapCompare
 ::operator()(cmTarget const* l, cmTarget const* r) const
 {
   // Order by target name.
-  if(int c = strcmp(l->GetName(), r->GetName()))
+  if(int c = strcmp(l->GetName().c_str(), r->GetName().c_str()))
     {
     return c < 0;
     }

+ 1 - 1
Source/cmGlobalUnixMakefileGenerator3.h

@@ -112,7 +112,7 @@ public:
     const char* makeProgram,
     const char* projectName,
     const char* projectDir,
-    const char* targetName,
+    const std::string& targetName,
     const char* config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()

+ 7 - 6
Source/cmGlobalVisualStudio10Generator.cxx

@@ -313,7 +313,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
   const char* makeProgram,
   const char* projectName,
   const char* projectDir,
-  const char* targetName,
+  const std::string& targetName,
   const char* config,
   bool fast,
   std::vector<std::string> const& makeOptions)
@@ -369,25 +369,26 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
 
   makeCommand.push_back(makeProgramSelected);
 
+  std::string realTarget = targetName;
   // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
-  if(!targetName || strlen(targetName) == 0)
+  if(realTarget.empty())
     {
-    targetName = "ALL_BUILD";
+    realTarget = "ALL_BUILD";
     }
-  if ( targetName && strcmp(targetName, "clean") == 0 )
+  if ( realTarget == "clean" )
     {
     makeCommand.push_back(std::string(projectName)+".sln");
     makeCommand.push_back("/t:Clean");
     }
   else
     {
-    std::string targetProject(targetName);
+    std::string targetProject(realTarget);
     targetProject += ".vcxproj";
     if (targetProject.find('/') == std::string::npos)
       {
       // it might be in a subdir
       if (cmSlnProjectEntry const* proj =
-          slnData.GetProjectByName(targetName))
+          slnData.GetProjectByName(realTarget))
         {
         targetProject = proj->GetRelativePath();
         cmSystemTools::ConvertToUnixSlashes(targetProject);

+ 1 - 1
Source/cmGlobalVisualStudio10Generator.h

@@ -37,7 +37,7 @@ public:
     const char* makeProgram,
     const char* projectName,
     const char* projectDir,
-    const char* targetName,
+    const std::string& targetName,
     const char* config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()

+ 6 - 5
Source/cmGlobalVisualStudio6Generator.cxx

@@ -119,7 +119,7 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
   const char* makeProgram,
   const char* projectName,
   const char* /*projectDir*/,
-  const char* targetName,
+  const std::string& targetName,
   const char* config,
   bool /*fast*/,
   std::vector<std::string> const& makeOptions
@@ -134,14 +134,15 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
   makeCommand.push_back("/MAKE");
   std::string targetArg;
   bool clean = false;
-  if ( targetName && strcmp(targetName, "clean") == 0 )
+  std::string realTarget = targetName;
+  if ( realTarget == "clean" )
     {
     clean = true;
-    targetName = "ALL_BUILD";
+    realTarget = "ALL_BUILD";
     }
-  if (targetName && strlen(targetName))
+  if (!realTarget.empty())
     {
-    targetArg += targetName;
+    targetArg += realTarget;
     }
   else
     {

+ 1 - 1
Source/cmGlobalVisualStudio6Generator.h

@@ -57,7 +57,7 @@ public:
     const char* makeProgram,
     const char* projectName,
     const char* projectDir,
-    const char* targetName,
+    const std::string& targetName,
     const char* config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()

+ 7 - 6
Source/cmGlobalVisualStudio7Generator.cxx

@@ -186,7 +186,7 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
   const char* makeProgram,
   const char* projectName,
   const char* /*projectDir*/,
-  const char* targetName,
+  const std::string& targetName,
   const char* config,
   bool /*fast*/,
   std::vector<std::string> const& makeOptions)
@@ -208,11 +208,12 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
   makeCommand.push_back(makeProgramSelected);
 
   makeCommand.push_back(std::string(projectName) + ".sln");
+  std::string realTarget = targetName;
   bool clean = false;
-  if ( targetName && strcmp(targetName, "clean") == 0 )
+  if ( realTarget == "clean" )
     {
     clean = true;
-    targetName = "ALL_BUILD";
+    realTarget = "ALL_BUILD";
     }
   if(clean)
     {
@@ -233,9 +234,9 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
     }
   makeCommand.push_back("/project");
 
-  if (targetName && strlen(targetName))
+  if (!realTarget.empty())
     {
-    makeCommand.push_back(targetName);
+    makeCommand.push_back(realTarget);
     }
   else
     {
@@ -381,7 +382,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
       std::set<std::string> allConfigurations(this->Configurations.begin(),
                                               this->Configurations.end());
       this->WriteProjectConfigurations(
-        fout, target->GetName(), target->GetType(),
+        fout, target->GetName().c_str(), target->GetType(),
         allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING"));
       }
     else

+ 1 - 1
Source/cmGlobalVisualStudio7Generator.h

@@ -65,7 +65,7 @@ public:
     const char* makeProgram,
     const char* projectName,
     const char* projectDir,
-    const char* targetName,
+    const std::string& targetName,
     const char* config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()

+ 1 - 1
Source/cmGlobalVisualStudio8Generator.cxx

@@ -426,7 +426,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
       {
       continue;
       }
-    std::string guid = this->GetGUID((*i)->GetName());
+    std::string guid = this->GetGUID((*i)->GetName().c_str());
     fout << "\t\t{" << guid << "} = {" << guid << "}\n";
     }
 }

+ 3 - 3
Source/cmGlobalVisualStudioGenerator.cxx

@@ -870,15 +870,15 @@ cmGlobalVisualStudioGenerator::TargetCompare
 ::operator()(cmTarget const* l, cmTarget const* r) const
 {
   // Make sure ALL_BUILD is first so it is the default active project.
-  if(strcmp(r->GetName(), "ALL_BUILD") == 0)
+  if(r->GetName() == "ALL_BUILD")
     {
     return false;
     }
-  if(strcmp(l->GetName(), "ALL_BUILD") == 0)
+  if(l->GetName() == "ALL_BUILD")
     {
     return true;
     }
-  return strcmp(l->GetName(), r->GetName()) < 0;
+  return strcmp(l->GetName().c_str(), r->GetName().c_str()) < 0;
 }
 
 //----------------------------------------------------------------------------

+ 2 - 2
Source/cmGlobalVisualStudioGenerator.h

@@ -104,8 +104,8 @@ protected:
   VSDependMap VSTargetDepends;
   void ComputeVSTargetDepends(cmTarget&);
 
-  bool CheckTargetLinks(cmTarget& target, const char* name);
-  std::string GetUtilityForTarget(cmTarget& target, const char*);
+  bool CheckTargetLinks(cmTarget& target, const std::string& name);
+  std::string GetUtilityForTarget(cmTarget& target, const std::string&);
   virtual std::string WriteUtilityDepend(cmTarget const*) = 0;
   std::string GetUtilityDepend(cmTarget const* target);
   typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap;

+ 12 - 11
Source/cmGlobalXCodeGenerator.cxx

@@ -263,7 +263,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
   const char* makeProgram,
   const char* projectName,
   const char* /*projectDir*/,
-  const char* targetName,
+  const std::string& targetName,
   const char* config,
   bool /*fast*/,
   std::vector<std::string> const& makeOptions)
@@ -283,10 +283,11 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
   makeCommand.push_back(projectArg);
 
   bool clean = false;
-  if ( targetName && strcmp(targetName, "clean") == 0 )
+  std::string realTarget = targetName;
+  if ( realTarget == "clean" )
     {
     clean = true;
-    targetName = "ALL_BUILD";
+    realTarget = "ALL_BUILD";
     }
   if(clean)
     {
@@ -302,9 +303,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
     {
     config = 0;
     }
-  if (targetName && strlen(targetName))
+  if (!realTarget.empty())
     {
-    makeCommand.push_back(targetName);
+    makeCommand.push_back(realTarget);
     }
   else
     {
@@ -1737,7 +1738,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
   {
     cmSystemTools::Error
       ("CMake can not determine linker language for target: ",
-       target.GetName());
+       target.GetName().c_str());
     return;
   }
 
@@ -2420,7 +2421,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
 
   cmXCodeObject* target =
     this->CreateObject(cmXCodeObject::PBXAggregateTarget);
-  target->SetComment(cmtarget.GetName());
+  target->SetComment(cmtarget.GetName().c_str());
   cmXCodeObject* buildPhases =
     this->CreateObject(cmXCodeObject::OBJECT_LIST);
   std::vector<cmXCodeObject*> emptyContentVector;
@@ -2621,7 +2622,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
   fileRef->AddAttribute("refType", this->CreateString("0"));
   fileRef->AddAttribute("sourceTree",
                         this->CreateString("BUILT_PRODUCTS_DIR"));
-  fileRef->SetComment(cmtarget.GetName());
+  fileRef->SetComment(cmtarget.GetName().c_str());
   target->AddAttribute("productReference",
                        this->CreateObjectReference(fileRef));
   if(const char* productType = this->GetTargetProductType(cmtarget))
@@ -2654,8 +2655,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
 }
 
 //----------------------------------------------------------------------------
-std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name,
-                                                  const char* id)
+std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
+                                                  const std::string& id)
 {
   std::string guidStoreName = name;
   guidStoreName += "_GUID_CMAKE";
@@ -2668,7 +2669,7 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name,
     }
 
   this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
-    id, "Stored Xcode object GUID", cmCacheManager::INTERNAL);
+    id.c_str(), "Stored Xcode object GUID", cmCacheManager::INTERNAL);
 
   return id;
 }

+ 2 - 2
Source/cmGlobalXCodeGenerator.h

@@ -58,7 +58,7 @@ public:
     const char* makeProgram,
     const char* projectName,
     const char* projectDir,
-    const char* targetName,
+    const std::string& targetName,
     const char* config,
     bool fast,
     std::vector<std::string> const& makeOptions = std::vector<std::string>()
@@ -129,7 +129,7 @@ private:
                                 );
 
   cmXCodeObject* FindXCodeTarget(cmTarget const*);
-  std::string GetOrCreateId(const char* name, const char* id);
+  std::string GetOrCreateId(const std::string& name, const std::string& id);
 
   // create cmXCodeObject from these functions so that memory can be managed
   // correctly.  All objects created are stored in this->XCodeObjects.

+ 4 - 4
Source/cmGraphVizWriter.cxx

@@ -300,7 +300,7 @@ void cmGraphVizWriter::WriteFooter(cmGeneratedFileStream& str) const
 }
 
 
-void cmGraphVizWriter::WriteConnections(const char* targetName,
+void cmGraphVizWriter::WriteConnections(const std::string& targetName,
                                     std::set<std::string>& insertedNodes,
                                     std::set<std::string>& insertedConnections,
                                     cmGeneratedFileStream& str) const
@@ -359,7 +359,7 @@ void cmGraphVizWriter::WriteConnections(const char* targetName,
 }
 
 
-void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
+void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName,
                                     std::set<std::string>& insertedNodes,
                                     std::set<std::string>& insertedConnections,
                                     cmGeneratedFileStream& str) const
@@ -444,7 +444,7 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
 }
 
 
-void cmGraphVizWriter::WriteNode(const char* targetName,
+void cmGraphVizWriter::WriteNode(const std::string& targetName,
                                  const cmTarget* target,
                                  std::set<std::string>& insertedNodes,
                                  cmGeneratedFileStream& str) const
@@ -558,7 +558,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
 }
 
 
-bool cmGraphVizWriter::IgnoreThisTarget(const char* name)
+bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name)
 {
   for(std::vector<cmsys::RegularExpression>::iterator itvIt
                                           = this->TargetsToIgnoreRegex.begin();

+ 4 - 4
Source/cmGraphVizWriter.h

@@ -44,23 +44,23 @@ protected:
 
   void WriteHeader(cmGeneratedFileStream& str) const;
 
-  void WriteConnections(const char* targetName,
+  void WriteConnections(const std::string& targetName,
                         std::set<std::string>& insertedNodes,
                         std::set<std::string>& insertedConnections,
                         cmGeneratedFileStream& str) const;
 
-  void WriteDependerConnections(const char* targetName,
+  void WriteDependerConnections(const std::string& targetName,
                                 std::set<std::string>& insertedNodes,
                                 std::set<std::string>& insertedConnections,
                                 cmGeneratedFileStream& str) const;
 
-  void WriteNode(const char* targetName, const cmTarget* target,
+  void WriteNode(const std::string& targetName, const cmTarget* target,
                  std::set<std::string>& insertedNodes,
                  cmGeneratedFileStream& str) const;
 
   void WriteFooter(cmGeneratedFileStream& str) const;
 
-  bool IgnoreThisTarget(const char* name);
+  bool IgnoreThisTarget(const std::string& name);
 
   bool GenerateForTargetType(cmTarget::TargetType targetType) const;
 

+ 10 - 10
Source/cmLocalGenerator.cxx

@@ -781,7 +781,7 @@ void cmLocalGenerator
           {
           cmSystemTools::Error
             ("CMake can not determine linker language for target: ",
-             target.Target->GetName());
+             target.Target->GetName().c_str());
           return;
           }
         // if the language is not in the set lang then create custom
@@ -1695,7 +1695,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
         {
         cmSystemTools::Error
           ("CMake can not determine linker language for target: ",
-           target->Target->GetName());
+           target->Target->GetName().c_str());
         return;
         }
       this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
@@ -2012,7 +2012,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
 }
 
 //----------------------------------------------------------------------------
-bool cmLocalGenerator::GetRealDependency(const char* inName,
+bool cmLocalGenerator::GetRealDependency(const std::string& inName,
                                          const char* config,
                                          std::string& dep)
 {
@@ -2040,7 +2040,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
     {
     // make sure it is not just a coincidence that the target name
     // found is part of the inName
-    if(cmSystemTools::FileIsFullPath(inName))
+    if(cmSystemTools::FileIsFullPath(inName.c_str()))
       {
       std::string tLocation;
       if(target->GetType() >= cmTarget::EXECUTABLE &&
@@ -2088,7 +2088,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
     }
 
   // The name was not that of a CMake target.  It must name a file.
-  if(cmSystemTools::FileIsFullPath(inName))
+  if(cmSystemTools::FileIsFullPath(inName.c_str()))
     {
     // This is a full path.  Return it as given.
     dep = inName;
@@ -3474,7 +3474,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmTarget* target,
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
-                                              const char* targetName,
+                                              const std::string& targetName,
                                               const char* fname)
 {
   // Find the Info.plist template.
@@ -3503,7 +3503,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
   // back to the directory-level values set by the user.
   cmMakefile* mf = this->Makefile;
   mf->PushScope();
-  mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName);
+  mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName.c_str());
   cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING");
   cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE");
   cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER");
@@ -3518,8 +3518,8 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
 
 //----------------------------------------------------------------------------
 void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
-                                                  const char* targetName,
-                                                  const char* fname)
+                                                const std::string& targetName,
+                                                const char* fname)
 {
   // Find the Info.plist template.
   const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
@@ -3547,7 +3547,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
   // back to the directory-level values set by the user.
   cmMakefile* mf = this->Makefile;
   mf->PushScope();
-  mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName);
+  mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName.c_str());
   cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE");
   cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER");
   cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING");

+ 3 - 3
Source/cmLocalGenerator.h

@@ -195,7 +195,7 @@ public:
    *   the source directory of this generator.  This should only be
    *   used for dependencies of custom commands.
    */
-  bool GetRealDependency(const char* name, const char* config,
+  bool GetRealDependency(const std::string& name, const char* config,
                          std::string& dep);
 
   ///! for existing files convert to output path and short path if spaces
@@ -339,14 +339,14 @@ public:
   /**
    * Generate a Mac OS X application bundle Info.plist file.
    */
-  void GenerateAppleInfoPList(cmTarget* target, const char* targetName,
+  void GenerateAppleInfoPList(cmTarget* target, const std::string& targetName,
                               const char* fname);
 
   /**
    * Generate a Mac OS X framework Info.plist file.
    */
   void GenerateFrameworkInfoPList(cmTarget* target,
-                                  const char* targetName,
+                                  const std::string& targetName,
                                   const char* fname);
   /** Construct a comment for a custom command.  */
   std::string ConstructComment(const cmCustomCommand& cc,

+ 7 - 7
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -550,14 +550,14 @@ void
 cmLocalUnixMakefileGenerator3
 ::WriteMakeRule(std::ostream& os,
                 const char* comment,
-                const char* target,
+                const std::string& target,
                 const std::vector<std::string>& depends,
                 const std::vector<std::string>& commands,
                 bool symbolic,
                 bool in_help)
 {
   // Make sure there is a target.
-  if(!target || !*target)
+  if(target.empty())
     {
     cmSystemTools::Error("No target for WriteMakeRule! called with comment: ",
                          comment);
@@ -859,11 +859,11 @@ void cmLocalUnixMakefileGenerator3
 void
 cmLocalUnixMakefileGenerator3
 ::WriteConvenienceRule(std::ostream& ruleFileStream,
-                       const char* realTarget,
-                       const char* helpTarget)
+                       const std::string& realTarget,
+                       const std::string& helpTarget)
 {
   // A rule is only needed if the names are different.
-  if(strcmp(realTarget, helpTarget) != 0)
+  if(realTarget != helpTarget)
     {
     // The helper target depends on the real target.
     std::vector<std::string> depends;
@@ -2034,7 +2034,7 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os)
 //----------------------------------------------------------------------------
 std::string
 cmLocalUnixMakefileGenerator3
-::GetRecursiveMakeCall(const char *makefile, const char* tgt)
+::GetRecursiveMakeCall(const char *makefile, const std::string& tgt)
 {
   // Call make on the given file.
   std::string cmd;
@@ -2059,7 +2059,7 @@ cmLocalUnixMakefileGenerator3
     }
 
   // Add the target.
-  if (tgt && tgt[0] != '\0')
+  if (!tgt.empty())
     {
     // The make target is always relative to the top of the build tree.
     std::string tgt2 = this->Convert(tgt, HOME_OUTPUT);

+ 5 - 4
Source/cmLocalUnixMakefileGenerator3.h

@@ -55,7 +55,7 @@ public:
   // Write out a make rule
   void WriteMakeRule(std::ostream& os,
                      const char* comment,
-                     const char* target,
+                     const std::string& target,
                      const std::vector<std::string>& depends,
                      const std::vector<std::string>& commands,
                      bool symbolic,
@@ -168,7 +168,8 @@ public:
   void WriteDivider(std::ostream& os);
 
   /** used to create a recursive make call */
-  std::string GetRecursiveMakeCall(const char *makefile, const char* tgt);
+  std::string GetRecursiveMakeCall(const char *makefile,
+                                   const std::string& tgt);
 
   // append flags to a string
   virtual void AppendFlags(std::string& flags, const char* newFlags);
@@ -273,8 +274,8 @@ protected:
 
 
   void WriteConvenienceRule(std::ostream& ruleFileStream,
-                            const char* realTarget,
-                            const char* helpTarget);
+                            const std::string& realTarget,
+                            const std::string& helpTarget);
 
   void WriteTargetDependRule(std::ostream& ruleFileStream,
                              cmTarget& target);

+ 11 - 11
Source/cmLocalVisualStudio6Generator.cxx

@@ -186,7 +186,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
 //
 extern std::string GetVS6TargetName(const std::string& targetName);
 
-void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname,
+void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname,
                                                     cmTarget &target)
 {
   // add to the list of projects
@@ -263,7 +263,7 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
 
 
 void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
-                                                 const char *libName,
+                                                 const std::string& libName,
                                                  cmTarget &target)
 {
   // For utility targets need custom command since pre- and post-
@@ -372,7 +372,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
 
 void cmLocalVisualStudio6Generator
 ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
-             std::ostream &fout, const char *libName)
+             std::ostream &fout, const std::string& libName)
 {
   cmGeneratorTarget* gt =
     this->GlobalGenerator->GetGeneratorTarget(&target);
@@ -572,9 +572,9 @@ cmLocalVisualStudio6Generator
 {
   // Create a fake output that forces the rule to run.
   char* output = new char[(strlen(this->Makefile->GetStartOutputDirectory()) +
-                           strlen(target.GetName()) + 30)];
+                           target.GetName().size() + 30)];
   sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(),
-          target.GetName(), count);
+          target.GetName().c_str(), count);
   std::string comment = this->ConstructComment(origCommand, "<hack>");
 
   // Add the rule with the given dependencies and commands.
@@ -699,7 +699,7 @@ void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout)
 
 
 void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
-                                                 const char* libName,
+                                                 const std::string& libName,
                                                  cmTarget& target)
 {
   std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
@@ -813,8 +813,8 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
 // look for custom rules on a target and collect them together
 std::string
 cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
-                                                 const char* configName,
-                                                 const char * /* libName */)
+                                              const char* configName,
+                                              const std::string& /* libName */)
 {
   if (target.GetType() >= cmTarget::UTILITY )
     {
@@ -926,7 +926,7 @@ cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target,
 
 void cmLocalVisualStudio6Generator
 ::WriteDSPHeader(std::ostream& fout,
-                 const char *libName, cmTarget &target,
+                 const std::string& libName, cmTarget &target,
                  std::vector<cmSourceGroup> &)
 {
   bool targetBuilds = (target.GetType() >= cmTarget::EXECUTABLE &&
@@ -1257,7 +1257,7 @@ void cmLocalVisualStudio6Generator
       {
       cmSystemTools::Error
         ("CMake can not determine linker language for target: ",
-         target.GetName());
+         target.GetName().c_str());
       return;
       }
 
@@ -1679,7 +1679,7 @@ void cmLocalVisualStudio6Generator
         {
         cmSystemTools::Error
           ("CMake can not determine linker language for target: ",
-           target.GetName());
+           target.GetName().c_str());
         return;
         }
       // if CXX is on and the target contains cxx code then add the cxx flags

+ 6 - 6
Source/cmLocalVisualStudio6Generator.h

@@ -48,7 +48,7 @@ public:
   /**
    * Specify the type of the build: static, dll, or executable.
    */
-  void SetBuildType(BuildType, const char* libName, cmTarget&);
+  void SetBuildType(BuildType, const std::string& libName, cmTarget&);
 
   virtual std::string GetTargetDirectory(cmTarget const& target) const;
   virtual std::string ComputeLongestObjectDirectory(cmTarget&) const;
@@ -56,15 +56,15 @@ private:
   std::string DSPHeaderTemplate;
   std::string DSPFooterTemplate;
 
-  void CreateSingleDSP(const char *lname, cmTarget &tgt);
-  void WriteDSPFile(std::ostream& fout, const char *libName,
+  void CreateSingleDSP(const std::string& lname, cmTarget &tgt);
+  void WriteDSPFile(std::ostream& fout, const std::string& libName,
                     cmTarget &tgt);
   void WriteDSPBeginGroup(std::ostream& fout,
                           const char* group,
                           const char* filter);
   void WriteDSPEndGroup(std::ostream& fout);
 
-  void WriteDSPHeader(std::ostream& fout, const char *libName,
+  void WriteDSPHeader(std::ostream& fout, const std::string& libName,
                       cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
 
   void WriteDSPFooter(std::ostream& fout);
@@ -77,14 +77,14 @@ private:
                              std::vector<std::string>& depends,
                              const cmCustomCommand& origCommand);
   void WriteGroup(const cmSourceGroup *sg, cmTarget& target,
-                  std::ostream &fout, const char *libName);
+                  std::ostream &fout, const std::string& libName);
   class EventWriter;
   friend class EventWriter;
   cmsys::auto_ptr<cmCustomCommand>
   MaybeCreateOutputDir(cmTarget& target, const char* config);
   std::string CreateTargetRules(cmTarget &target,
                                 const char* configName,
-                                const char *libName);
+                                const std::string& libName);
   void ComputeLinkOptions(cmTarget& target, const char* configName,
                           const std::string extraOptions,
                           std::string& options);

+ 15 - 15
Source/cmLocalVisualStudio7Generator.cxx

@@ -83,7 +83,7 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
     if(path)
       {
       this->ReadAndStoreExternalGUID(
-        l->second.GetName(), path);
+        l->second.GetName().c_str(), path);
       }
     else
       {
@@ -334,8 +334,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
 }
 
 void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
-                                                        const char *libName,
-                                                        cmTarget &target)
+                                                   const std::string& libName,
+                                                   cmTarget &target)
 {
   std::vector<std::string> *configs =
     static_cast<cmGlobalVisualStudio7Generator *>
@@ -637,9 +637,9 @@ private:
 
 //----------------------------------------------------------------------------
 void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
-                                                       const char* configName,
-                                                       const char *libName,
-                                                       cmTarget &target)
+                                                const char* configName,
+                                                const std::string& libName,
+                                                cmTarget &target)
 {
   const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
   if(!mfcFlag)
@@ -694,7 +694,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
       {
       cmSystemTools::Error
         ("CMake can not determine linker language for target: ",
-         target.GetName());
+         target.GetName().c_str());
       return;
       }
     if(linkLanguage == "C" || linkLanguage == "CXX"
@@ -1380,7 +1380,7 @@ cmLocalVisualStudio7Generator
 }
 
 void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
-                                                    const char *libName,
+                                                    const std::string& libName,
                                                     cmTarget &target)
 {
   // get the configurations
@@ -1627,7 +1627,7 @@ cmLocalVisualStudio7Generator
 
 bool cmLocalVisualStudio7Generator
 ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
-             std::ostream &fout, const char *libName,
+             std::ostream &fout, const std::string& libName,
              std::vector<std::string> *configs)
 {
   const std::vector<const cmSourceFile *> &sourceFiles =
@@ -1906,7 +1906,7 @@ void cmLocalVisualStudio7Generator
 ::OutputTargetRules(std::ostream& fout,
                     const char* configName,
                     cmTarget &target,
-                    const char * /*libName*/)
+                    const std::string& /*libName*/)
 {
   if (target.GetType() > cmTarget::GLOBAL_TARGET)
     {
@@ -1966,7 +1966,7 @@ void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout,
 void
 cmLocalVisualStudio7Generator
 ::WriteProjectStartFortran(std::ostream& fout,
-                           const char *libName,
+                           const std::string& libName,
                            cmTarget & target)
 {
 
@@ -2017,7 +2017,7 @@ cmLocalVisualStudio7Generator
     }
   this->WriteProjectSCC(fout, target);
   fout<< "\tKeyword=\"" << keyword << "\">\n"
-       << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n"
+       << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n"
        << "\t<Platforms>\n"
        << "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n"
        << "\t</Platforms>\n";
@@ -2026,7 +2026,7 @@ cmLocalVisualStudio7Generator
 
 void
 cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
-                                                 const char *libName,
+                                                 const std::string& libName,
                                                  cmTarget & target,
                                                  std::vector<cmSourceGroup> &)
 {
@@ -2049,7 +2049,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
   const char* projLabel = target.GetProperty("PROJECT_LABEL");
   if(!projLabel)
     {
-    projLabel = libName;
+    projLabel = libName.c_str();
     }
   const char* keyword = target.GetProperty("VS_KEYWORD");
   if(!keyword)
@@ -2061,7 +2061,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
   fout << "\tName=\"" << projLabel << "\"\n";
   if(this->Version >= VS8)
     {
-    fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n";
+    fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n";
     }
   this->WriteProjectSCC(fout, target);
   if(const char* targetFrameworkVersion =

+ 9 - 8
Source/cmLocalVisualStudio7Generator.h

@@ -74,29 +74,29 @@ private:
                                       const char* configName);
   void FixGlobalTargets();
   void WriteProjectFiles();
-  void WriteVCProjHeader(std::ostream& fout, const char *libName,
+  void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
                          cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
   void WriteVCProjFooter(std::ostream& fout, cmTarget &target);
-  void WriteVCProjFile(std::ostream& fout, const char *libName,
+  void WriteVCProjFile(std::ostream& fout, const std::string& libName,
                        cmTarget &tgt);
   void WriteConfigurations(std::ostream& fout,
-                           const char *libName, cmTarget &tgt);
+                           const std::string& libName, cmTarget &tgt);
   void WriteConfiguration(std::ostream& fout,
                           const char* configName,
-                          const char* libName, cmTarget &tgt);
+                          const std::string& libName, cmTarget &tgt);
   std::string EscapeForXML(const char* s);
   std::string ConvertToXMLOutputPath(const char* path);
   std::string ConvertToXMLOutputPathSingle(const char* path);
   void OutputTargetRules(std::ostream& fout, const char* configName,
-                         cmTarget &target, const char *libName);
+                         cmTarget &target, const std::string& libName);
   void OutputBuildTool(std::ostream& fout, const char* configName,
                        cmTarget& t, const Options& targetOptions);
   void OutputLibraryDirectories(std::ostream& fout,
                                 std::vector<std::string> const& dirs);
   void WriteProjectSCC(std::ostream& fout, cmTarget& target);
-  void WriteProjectStart(std::ostream& fout, const char *libName,
+  void WriteProjectStart(std::ostream& fout, const std::string& libName,
                          cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
-  void WriteProjectStartFortran(std::ostream& fout, const char *libName,
+  void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
                                 cmTarget &tgt);
   void WriteVCProjBeginGroup(std::ostream& fout,
                           const char* group,
@@ -111,7 +111,8 @@ private:
 
   bool WriteGroup(const cmSourceGroup *sg,
                   cmTarget& target, std::ostream &fout,
-                  const char *libName, std::vector<std::string> *configs);
+                  const std::string& libName,
+                  std::vector<std::string> *configs);
 
   friend class cmLocalVisualStudio7GeneratorFCInfo;
   friend class cmLocalVisualStudio7GeneratorInternals;

+ 32 - 36
Source/cmMakefile.cxx

@@ -878,7 +878,7 @@ void cmMakefile::ConfigureFinalPass()
 
 //----------------------------------------------------------------------------
 void
-cmMakefile::AddCustomCommandToTarget(const char* target,
+cmMakefile::AddCustomCommandToTarget(const std::string& target,
                                      const std::vector<std::string>& depends,
                                      const cmCustomCommandLines& commandLines,
                                      cmTarget::CustomCommandType type,
@@ -1120,7 +1120,7 @@ cmMakefile::AddCustomCommandToOutput(const char* output,
 
 //----------------------------------------------------------------------------
 void
-cmMakefile::AddCustomCommandOldStyle(const char* target,
+cmMakefile::AddCustomCommandOldStyle(const std::string& target,
                                      const std::vector<std::string>& outputs,
                                      const std::vector<std::string>& depends,
                                      const char* source,
@@ -1129,7 +1129,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
 {
   // Translate the old-style signature to one of the new-style
   // signatures.
-  if(strcmp(source, target) == 0)
+  if(source == target)
     {
     // In the old-style signature if the source and target were the
     // same then it added a post-build rule to the target.  Preserve
@@ -1179,7 +1179,8 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
       else
         {
         cmSystemTools::Error("Attempt to add a custom rule to a target "
-                             "that does not exist yet for target ", target);
+                             "that does not exist yet for target ",
+                             target.c_str());
         return;
         }
       }
@@ -1453,7 +1454,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
   return true;
 }
 
-void cmMakefile::AddLinkLibrary(const char* lib,
+void cmMakefile::AddLinkLibrary(const std::string& lib,
                                 cmTarget::LinkLibraryType llt)
 {
   cmTarget::LibraryID tmp;
@@ -1462,8 +1463,8 @@ void cmMakefile::AddLinkLibrary(const char* lib,
   this->LinkLibraries.push_back(tmp);
 }
 
-void cmMakefile::AddLinkLibraryForTarget(const char *target,
-                                         const char* lib,
+void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
+                                         const std::string& lib,
                                          cmTarget::LinkLibraryType llt)
 {
   cmTargets::iterator i = this->Targets.find(target);
@@ -1500,8 +1501,8 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
     }
 }
 
-void cmMakefile::AddLinkDirectoryForTarget(const char *target,
-                                           const char* d)
+void cmMakefile::AddLinkDirectoryForTarget(const std::string& target,
+                                           const std::string& d)
 {
   cmTargets::iterator i = this->Targets.find(target);
   if ( i != this->Targets.end())
@@ -1520,46 +1521,37 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target,
     {
     cmSystemTools::Error
       ("Attempt to add link directories to non-existent target: ",
-       target, " for directory ", d);
+       target.c_str(), " for directory ", d.c_str());
     }
 }
 
-void cmMakefile::AddLinkLibrary(const char* lib)
+void cmMakefile::AddLinkLibrary(const std::string& lib)
 {
   this->AddLinkLibrary(lib,cmTarget::GENERAL);
 }
 
-void cmMakefile::AddLinkDirectory(const char* dir)
+void cmMakefile::AddLinkDirectory(const std::string& dir)
 {
   // Don't add a link directory that is already present.  Yes, this
   // linear search results in n^2 behavior, but n won't be getting
   // much bigger than 20.  We cannot use a set because of order
   // dependency of the link search path.
 
-  if(!dir)
+  if(dir.empty())
     {
     return;
     }
+  std::string newdir = dir;
   // remove trailing slashes
-  if(dir[strlen(dir)-1] == '/')
+  if(*dir.rbegin() == '/')
     {
-    std::string newdir = dir;
-    newdir = newdir.substr(0, newdir.size()-1);
-    if(std::find(this->LinkDirectories.begin(),
-                 this->LinkDirectories.end(),
-                 newdir.c_str()) == this->LinkDirectories.end())
-      {
-      this->LinkDirectories.push_back(newdir);
-      }
+    newdir = dir.substr(0, dir.size()-1);
     }
-  else
+  if(std::find(this->LinkDirectories.begin(),
+               this->LinkDirectories.end(), newdir)
+      == this->LinkDirectories.end())
     {
-    if(std::find(this->LinkDirectories.begin(),
-                 this->LinkDirectories.end(), dir)
-       == this->LinkDirectories.end())
-      {
-      this->LinkDirectories.push_back(dir);
-      }
+    this->LinkDirectories.push_back(dir);
     }
 }
 
@@ -1975,7 +1967,8 @@ void cmMakefile::SetProjectName(const char* p)
 }
 
 
-void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
+void cmMakefile::AddGlobalLinkInformation(const std::string& name,
+                                          cmTarget& target)
 {
   // for these targets do not add anything
   switch(target.GetType())
@@ -1996,13 +1989,14 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
 }
 
 
-void cmMakefile::AddAlias(const char* lname, cmTarget *tgt)
+void cmMakefile::AddAlias(const std::string& lname, cmTarget *tgt)
 {
   this->AliasTargets[lname] = tgt;
   this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt);
 }
 
-cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type,
+cmTarget* cmMakefile::AddLibrary(const std::string& lname,
+                            cmTarget::TargetType type,
                             const std::vector<std::string> &srcs,
                             bool excludeFromAll)
 {
@@ -2048,7 +2042,7 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName,
 
 //----------------------------------------------------------------------------
 cmTarget*
-cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name)
+cmMakefile::AddNewTarget(cmTarget::TargetType type, const std::string& name)
 {
   cmTargets::iterator it =
     this->Targets.insert(cmTargets::value_type(name, cmTarget())).first;
@@ -3066,7 +3060,8 @@ void cmMakefile::ExpandSourceListArguments(
 }
 
 int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
-                           const char *projectName, const char *targetName,
+                           const char *projectName,
+                           const std::string& targetName,
                            bool fast,
                            const std::vector<std::string> *cmakeArgs,
                            std::string *output)
@@ -4030,7 +4025,8 @@ void cmMakefile::DefineProperties(cmake *cm)
 
 //----------------------------------------------------------------------------
 cmTarget*
-cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
+cmMakefile::AddImportedTarget(const std::string& name,
+                              cmTarget::TargetType type,
                               bool global)
 {
   // Create the target.
@@ -4087,7 +4083,7 @@ bool cmMakefile::IsAlias(const std::string& name) const
 
 //----------------------------------------------------------------------------
 cmGeneratorTarget*
-cmMakefile::FindGeneratorTargetToUse(const char* name) const
+cmMakefile::FindGeneratorTargetToUse(const std::string& name) const
 {
   if (cmTarget *t = this->FindTargetToUse(name))
     {

+ 15 - 14
Source/cmMakefile.h

@@ -127,7 +127,7 @@ public:
    * loaded commands, not as part of the usual build process.
    */
   int TryCompile(const char *srcdir, const char *bindir,
-                 const char *projectName, const char *targetName,
+                 const char *projectName, const std::string& targetName,
                  bool fast,
                  const std::vector<std::string> *cmakeArgs,
                  std::string *output);
@@ -168,7 +168,7 @@ public:
   void Print() const;
 
   /** Add a custom command to the build.  */
-  void AddCustomCommandToTarget(const char* target,
+  void AddCustomCommandToTarget(const std::string& target,
                                 const std::vector<std::string>& depends,
                                 const cmCustomCommandLines& commandLines,
                                 cmTarget::CustomCommandType type,
@@ -190,7 +190,7 @@ public:
     const char* comment, const char* workingDir,
     bool replace = false,
     bool escapeOldStyle = true);
-  void AddCustomCommandOldStyle(const char* target,
+  void AddCustomCommandOldStyle(const std::string& target,
                                 const std::vector<std::string>& outputs,
                                 const std::vector<std::string>& depends,
                                 const char* source,
@@ -205,10 +205,11 @@ public:
   void AddCompileOption(const char* option);
 
   /** Create a new imported target with the name and type given.  */
-  cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type,
+  cmTarget* AddImportedTarget(const std::string& name,
+                              cmTarget::TargetType type,
                               bool global);
 
-  cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name);
+  cmTarget* AddNewTarget(cmTarget::TargetType type, const std::string& name);
 
   /**
    * Add an executable to the build.
@@ -239,16 +240,16 @@ public:
   /**
    * Add a link library to the build.
    */
-  void AddLinkLibrary(const char*);
-  void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type);
-  void AddLinkLibraryForTarget(const char *tgt, const char*,
+  void AddLinkLibrary(const std::string&);
+  void AddLinkLibrary(const std::string&, cmTarget::LinkLibraryType type);
+  void AddLinkLibraryForTarget(const std::string& tgt, const std::string&,
                                cmTarget::LinkLibraryType type);
-  void AddLinkDirectoryForTarget(const char *tgt, const char* d);
+  void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d);
 
   /**
    * Add a link directory to the build.
    */
-  void AddLinkDirectory(const char*);
+  void AddLinkDirectory(const std::string&);
 
   const std::vector<std::string>& GetLinkDirectories() const
     {
@@ -323,10 +324,10 @@ public:
   /**
    * Set the name of the library.
    */
-  cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type,
+  cmTarget* AddLibrary(const std::string& libname, cmTarget::TargetType type,
                   const std::vector<std::string> &srcs,
                   bool excludeFromAll = false);
-  void AddAlias(const char *libname, cmTarget *tgt);
+  void AddAlias(const std::string& libname, cmTarget *tgt);
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   /**
@@ -534,7 +535,7 @@ public:
   cmTarget* FindTargetToUse(const std::string& name,
                             bool excludeAliases = false) const;
   bool IsAlias(const std::string& name) const;
-  cmGeneratorTarget* FindGeneratorTargetToUse(const char* name) const;
+  cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
 
   /**
    * Mark include directories as system directories.
@@ -878,7 +879,7 @@ public:
 
 protected:
   // add link libraries and directories to the target
-  void AddGlobalLinkInformation(const char* name, cmTarget& target);
+  void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
 
   // Check for a an unused variable
   void CheckForUnused(const char* reason, const std::string& name) const;

+ 1 - 1
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -167,7 +167,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
   if(linkLanguage.empty())
     {
     cmSystemTools::Error("Cannot determine link language for target \"",
-                         this->Target->GetName(), "\".");
+                         this->Target->GetName().c_str(), "\".");
     return;
     }
 

+ 2 - 2
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -125,7 +125,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
                                       depends, commands, true);
 
   // Write the main driver rule to build everything in this target.
-  this->WriteTargetDriverRule(this->Target->GetName(), false);
+  this->WriteTargetDriverRule(this->Target->GetName().c_str(), false);
 }
 
 //----------------------------------------------------------------------------
@@ -243,7 +243,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
   if(linkLanguage.empty())
     {
     cmSystemTools::Error("Cannot determine link language for target \"",
-                         this->Target->GetName(), "\".");
+                         this->Target->GetName().c_str(), "\".");
     return;
     }
 

+ 3 - 3
Source/cmMakefileTargetGenerator.cxx

@@ -1347,7 +1347,7 @@ cmMakefileTargetGenerator
   // Write a make variable assignment that lists all objects for the
   // target.
   variableName =
-    this->LocalGenerator->CreateMakeVariable(this->Target->GetName(),
+    this->LocalGenerator->CreateMakeVariable(this->Target->GetName().c_str(),
                                              "_OBJECTS");
   *this->BuildFileStream
     << "# Object files for target " << this->Target->GetName() << "\n"
@@ -1382,7 +1382,7 @@ cmMakefileTargetGenerator
   // Write a make variable assignment that lists all external objects
   // for the target.
   variableNameExternal =
-    this->LocalGenerator->CreateMakeVariable(this->Target->GetName(),
+    this->LocalGenerator->CreateMakeVariable(this->Target->GetName().c_str(),
                                              "_EXTERNAL_OBJECTS");
   *this->BuildFileStream
     << "\n"
@@ -1683,7 +1683,7 @@ void cmMakefileTargetGenerator
 
 //----------------------------------------------------------------------------
 std::string cmMakefileTargetGenerator::GetLinkRule(
-                                              const cmStdString& linkRuleVar)
+                                              const std::string& linkRuleVar)
 {
   std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
   if(this->Target->HasImplibGNUtoMS())

+ 1 - 1
Source/cmMakefileTargetGenerator.h

@@ -138,7 +138,7 @@ protected:
   void AppendLinkDepends(std::vector<std::string>& depends);
 
   // Lookup the link rule for this target.
-  std::string GetLinkRule(const cmStdString& linkRuleVar);
+  std::string GetLinkRule(const std::string& linkRuleVar);
 
   /** In order to support parallel builds for custom commands with
       multiple outputs the outputs are given a serial order, and only

+ 1 - 1
Source/cmMakefileUtilityTargetGenerator.cxx

@@ -105,7 +105,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
                                       depends, commands, true);
 
   // Write the main driver rule to build everything in this target.
-  this->WriteTargetDriverRule(this->Target->GetName(), false);
+  this->WriteTargetDriverRule(this->Target->GetName().c_str(), false);
 
   // Write clean target
   this->WriteTargetCleanRules();

+ 1 - 1
Source/cmNinjaNormalTargetGenerator.cxx

@@ -75,7 +75,7 @@ void cmNinjaNormalTargetGenerator::Generate()
   if (this->TargetLinkLanguage.empty()) {
     cmSystemTools::Error("CMake can not determine linker language for "
                          "target: ",
-                         this->GetTarget()->GetName());
+                         this->GetTarget()->GetName().c_str());
     return;
   }
 

+ 7 - 7
Source/cmQtAutoGenerators.cxx

@@ -772,7 +772,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
   makefile->AddDefinition("_qt_uic_options_options",
             cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str());
 
-  const char* targetName = target->GetName();
+  std::string targetName = target->GetName();
   if (strcmp(qtVersion, "5") == 0)
     {
     cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic");
@@ -791,7 +791,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
     if (!qt4Uic)
       {
       cmSystemTools::Error("Qt4::uic target not found ",
-                          targetName);
+                          targetName.c_str());
       return;
       }
     makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0));
@@ -799,7 +799,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
   else
     {
     cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and "
-                        "Qt 5 ", targetName);
+                        "Qt 5 ", targetName.c_str());
     }
 }
 
@@ -921,14 +921,14 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
   makefile->AddDefinition("_qt_rcc_options_options",
             cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str());
 
-  const char* targetName = target->GetName();
+  std::string targetName = target->GetName();
   if (strcmp(qtVersion, "5") == 0)
     {
     cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc");
     if (!qt5Rcc)
       {
       cmSystemTools::Error("Qt5::rcc target not found ",
-                          targetName);
+                          targetName.c_str());
       return;
       }
     makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0));
@@ -939,7 +939,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
     if (!qt4Rcc)
       {
       cmSystemTools::Error("Qt4::rcc target not found ",
-                          targetName);
+                          targetName.c_str());
       return;
       }
     makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0));
@@ -947,7 +947,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
   else
     {
     cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
-                        "Qt 5 ", targetName);
+                        "Qt 5 ", targetName.c_str());
     }
 }
 

+ 1 - 1
Source/cmSetPropertyCommand.cxx

@@ -203,7 +203,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
     // Lookup the generator.
     if(cmLocalGenerator* lg =
        (this->Makefile->GetLocalGenerator()
-        ->GetGlobalGenerator()->FindLocalGenerator(dir.c_str())))
+        ->GetGlobalGenerator()->FindLocalGenerator(dir)))
       {
       // Use the makefile for the directory found.
       mf = lg->GetMakefile();

+ 1 - 1
Source/cmSetTargetPropertiesCommand.cxx

@@ -91,7 +91,7 @@ bool cmSetTargetPropertiesCommand
 }
 
 bool cmSetTargetPropertiesCommand
-::SetOneTarget(const char *tname,
+::SetOneTarget(const std::string& tname,
                std::vector<std::string> &propertyPairs,
                cmMakefile *mf)
 {

+ 1 - 1
Source/cmSetTargetPropertiesCommand.h

@@ -37,7 +37,7 @@ public:
   /**
    *  Used by this command and cmSetPropertiesCommand
    */
-  static bool SetOneTarget(const char *tname,
+  static bool SetOneTarget(const std::string& tname,
                            std::vector<std::string> &propertyPairs,
                            cmMakefile *mf);
 

+ 15 - 13
Source/cmTarget.cxx

@@ -234,7 +234,7 @@ void cmTarget::DefineProperties(cmake *cm)
      "", "", true);
 }
 
-void cmTarget::SetType(TargetType type, const char* name)
+void cmTarget::SetType(TargetType type, const std::string& name)
 {
   this->Name = name;
   // only add dependency information for library targets
@@ -415,7 +415,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::AddUtility(const char *u, cmMakefile *makefile)
+void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
 {
   this->Utilities.insert(u);
   if(makefile)
@@ -425,7 +425,8 @@ void cmTarget::AddUtility(const char *u, cmMakefile *makefile)
 }
 
 //----------------------------------------------------------------------------
-cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(const char *u) const
+cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
+    const std::string& u) const
 {
   std::map<cmStdString, cmListFileBacktrace>::const_iterator i =
     this->UtilityBacktraces.find(u);
@@ -657,7 +658,7 @@ void cmTarget::ProcessSourceExpression(std::string const& expr)
 
 //----------------------------------------------------------------------------
 void cmTarget::MergeLinkLibraries( cmMakefile& mf,
-                                   const char *selfname,
+                                   const std::string& selfname,
                                    const LinkLibraryVectorType& libs )
 {
   // Only add on libraries we haven't added on before.
@@ -675,7 +676,7 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf,
 }
 
 //----------------------------------------------------------------------------
-void cmTarget::AddLinkDirectory(const char* d)
+void cmTarget::AddLinkDirectory(const std::string& d)
 {
   // Make sure we don't add unnecessary search directories.
   if(this->LinkDirectoriesEmmitted.insert(d).second)
@@ -720,7 +721,7 @@ cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const
 
 //----------------------------------------------------------------------------
 void cmTarget::ClearDependencyInformation( cmMakefile& mf,
-                                           const char* target )
+                                           const std::string& target )
 {
   // Clear the dependencies. The cache variable must exist iff we are
   // recording dependency information for this target.
@@ -844,9 +845,9 @@ std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value,
 }
 
 //----------------------------------------------------------------------------
-static std::string targetNameGenex(const char *lib)
+static std::string targetNameGenex(const std::string& lib)
 {
-  return std::string("$<TARGET_NAME:") + lib + ">";
+  return "$<TARGET_NAME:" + lib + ">";
 }
 
 //----------------------------------------------------------------------------
@@ -908,7 +909,8 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s,
 
 //----------------------------------------------------------------------------
 void cmTarget::AddLinkLibrary(cmMakefile& mf,
-                              const char *target, const char* lib,
+                              const std::string& target,
+                              const std::string& lib,
                               LinkLibraryType llt)
 {
   cmTarget *tgt = this->Makefile->FindTargetToUse(lib);
@@ -917,7 +919,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
 
   const std::string libName = (isNonImportedTarget && llt != GENERAL)
                                                         ? targetNameGenex(lib)
-                                                        : std::string(lib);
+                                                        : lib;
   this->AppendProperty("LINK_LIBRARIES",
                        this->GetDebugGeneratorExpressions(libName,
                                                           llt).c_str());
@@ -925,7 +927,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
 
   if (cmGeneratorExpression::Find(lib) != std::string::npos
       || (tgt && tgt->GetType() == INTERFACE_LIBRARY)
-      || (strcmp( target, lib ) == 0))
+      || (target == lib ))
     {
     return;
     }
@@ -1469,7 +1471,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
 }
 
 //----------------------------------------------------------------------------
-const char* cmTarget::GetExportName() const
+std::string cmTarget::GetExportName() const
 {
   const char *exportName = this->GetProperty("EXPORT_NAME");
 
@@ -2630,7 +2632,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
 
   if (prop == "NAME")
     {
-    return this->GetName();
+    return this->GetName().c_str();
     }
 
   // Watch for special "computed" properties that are dependent on

+ 9 - 9
Source/cmTarget.h

@@ -93,13 +93,13 @@ public:
   /**
    * Set the target type
    */
-  void SetType(TargetType f, const char* name);
+  void SetType(TargetType f, const std::string& name);
 
   void MarkAsImported();
 
   ///! Set/Get the name of the target
-  const char* GetName() const {return this->Name.c_str();}
-  const char* GetExportName() const;
+  const std::string& GetName() const {return this->Name;}
+  std::string GetExportName() const;
 
   ///! Set the cmMakefile that owns this target
   void SetMakefile(cmMakefile *mf);
@@ -168,12 +168,12 @@ public:
   /**
    * Clear the dependency information recorded for this target, if any.
    */
-  void ClearDependencyInformation(cmMakefile& mf, const char* target);
+  void ClearDependencyInformation(cmMakefile& mf, const std::string& target);
 
   // Check to see if a library is a framework and treat it different on Mac
   bool NameResolvesToFramework(const std::string& libname) const;
   void AddLinkLibrary(cmMakefile& mf,
-                      const char *target, const char* lib,
+                      const std::string& target, const std::string& lib,
                       LinkLibraryType llt);
   enum TLLSignature {
     KeywordTLLSignature,
@@ -182,12 +182,12 @@ public:
   bool PushTLLCommandTrace(TLLSignature signature);
   void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const;
 
-  void MergeLinkLibraries( cmMakefile& mf, const char* selfname,
+  void MergeLinkLibraries( cmMakefile& mf, const std::string& selfname,
                            const LinkLibraryVectorType& libs );
 
   const std::vector<std::string>& GetLinkDirectories() const;
 
-  void AddLinkDirectory(const char* d);
+  void AddLinkDirectory(const std::string& d);
 
   /**
    * Set the path where this target should be installed. This is relative to
@@ -214,10 +214,10 @@ public:
    * name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
    * commands. It is not a full path nor does it have an extension.
    */
-  void AddUtility(const char* u, cmMakefile *makefile = 0);
+  void AddUtility(const std::string& u, cmMakefile *makefile = 0);
   ///! Get the utilities used by this target
   std::set<cmStdString>const& GetUtilities() const { return this->Utilities; }
-  cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const;
+  cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
 
   /** Finalize the target at the end of the Configure step.  */
   void FinishConfigure();

+ 1 - 1
Source/cmXCodeObject.h

@@ -136,7 +136,7 @@ public:
       return this->DependLibraries;
     }
   void AddDependTarget(const char* configName,
-                       const char* tName)
+                       const std::string& tName)
     {
       if(!configName)
         {