Sfoglia il codice sorgente

Merge topic 'xcode-c_str'

2263949b cmGlobalXCodeGenerator: do not pass char* to cmSystemTools::CollapseFullPath()
2b25ce30 make cmGlobalXCodeGenerator::XCodeEscapePath() take a std::string&
ffedf352 make cmGlobalXCodeGenerator::BuildObjectListOrString::Add() take a string&
6100bdff cmGlobalXCodeGenerator: directly call CreateString() with std::string
Brad King 9 anni fa
parent
commit
eb87407068
2 ha cambiato i file con 54 aggiunte e 55 eliminazioni
  1. 53 54
      Source/cmGlobalXCodeGenerator.cxx
  2. 1 1
      Source/cmGlobalXCodeGenerator.h

+ 53 - 54
Source/cmGlobalXCodeGenerator.cxx

@@ -84,7 +84,7 @@ public:
 
 
   bool IsEmpty() const { return this->Empty; }
   bool IsEmpty() const { return this->Empty; }
 
 
-  void Add(const char *newString)
+  void Add(const std::string& newString)
     {
     {
     this->Empty = false;
     this->Empty = false;
 
 
@@ -109,7 +109,7 @@ public:
       }
       }
     else
     else
       {
       {
-      return this->Generator->CreateString(this->String.c_str());
+      return this->Generator->CreateString(this->String);
       }
       }
     }
     }
 };
 };
@@ -804,7 +804,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
 
 
   cmXCodeObject* settings =
   cmXCodeObject* settings =
     this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
     this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
-  settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags.c_str()));
+  settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags));
 
 
   // Is this a resource file in this target? Add it to the resources group...
   // Is this a resource file in this target? Add it to the resources group...
   //
   //
@@ -1011,8 +1011,8 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
   std::string name = cmSystemTools::GetFilenameName(path.c_str());
   std::string name = cmSystemTools::GetFilenameName(path.c_str());
   const char* sourceTree = (cmSystemTools::FileIsFullPath(path.c_str())?
   const char* sourceTree = (cmSystemTools::FileIsFullPath(path.c_str())?
                             "<absolute>" : "SOURCE_ROOT");
                             "<absolute>" : "SOURCE_ROOT");
-  fileRef->AddAttribute("name", this->CreateString(name.c_str()));
-  fileRef->AddAttribute("path", this->CreateString(path.c_str()));
+  fileRef->AddAttribute("name", this->CreateString(name));
+  fileRef->AddAttribute("path", this->CreateString(path));
   fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree));
   fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree));
   if(this->XcodeVersion == 15)
   if(this->XcodeVersion == 15)
     {
     {
@@ -1326,7 +1326,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
           ostr << "../" << mit->first.c_str();
           ostr << "../" << mit->first.c_str();
           }
           }
         copyFilesBuildPhase->AddAttribute("dstPath",
         copyFilesBuildPhase->AddAttribute("dstPath",
-          this->CreateString(ostr.str().c_str()));
+          this->CreateString(ostr.str()));
         copyFilesBuildPhase->AddAttribute(
         copyFilesBuildPhase->AddAttribute(
           "runOnlyForDeploymentPostprocessing", this->CreateString("0"));
           "runOnlyForDeploymentPostprocessing", this->CreateString("0"));
         buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
         buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
@@ -1752,7 +1752,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
                                           (makefile+"$CONFIGURATION").c_str());
                                           (makefile+"$CONFIGURATION").c_str());
   makecmd += " all";
   makecmd += " all";
   buildphase->AddAttribute("shellScript",
   buildphase->AddAttribute("shellScript",
-                           this->CreateString(makecmd.c_str()));
+                           this->CreateString(makecmd));
   buildphase->AddAttribute("showEnvVarsInLog",
   buildphase->AddAttribute("showEnvVarsInLog",
                            this->CreateString("0"));
                            this->CreateString("0"));
 }
 }
@@ -2021,7 +2021,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
     if(archs.size() == 1)
     if(archs.size() == 1)
       {
       {
       buildSettings->AddAttribute("ARCHS",
       buildSettings->AddAttribute("ARCHS",
-                                  this->CreateString(archs[0].c_str()));
+                                  this->CreateString(archs[0]));
       }
       }
     else
     else
       {
       {
@@ -2030,7 +2030,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       for(std::vector<std::string>::iterator i = archs.begin();
       for(std::vector<std::string>::iterator i = archs.begin();
           i != archs.end(); i++)
           i != archs.end(); i++)
         {
         {
-        archObjects->AddObject(this->CreateString((*i).c_str()));
+        archObjects->AddObject(this->CreateString(*i));
         }
         }
       buildSettings->AddAttribute("ARCHS", archObjects);
       buildSettings->AddAttribute("ARCHS", archObjects);
       }
       }
@@ -2081,13 +2081,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
         {
         {
         std::string pncdir = gtgt->GetDirectory(configName);
         std::string pncdir = gtgt->GetDirectory(configName);
         buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
         buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
-                                    this->CreateString(pncdir.c_str()));
+                                    this->CreateString(pncdir));
         }
         }
       }
       }
     else
     else
       {
       {
       buildSettings->AddAttribute("OBJROOT",
       buildSettings->AddAttribute("OBJROOT",
-                                  this->CreateString(pndir.c_str()));
+                                  this->CreateString(pndir));
       pndir = gtgt->GetDirectory(configName);
       pndir = gtgt->GetDirectory(configName);
       }
       }
 
 
@@ -2097,9 +2097,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       }
       }
 
 
     buildSettings->AddAttribute("EXECUTABLE_PREFIX",
     buildSettings->AddAttribute("EXECUTABLE_PREFIX",
-                                this->CreateString(pnprefix.c_str()));
+                                this->CreateString(pnprefix));
     buildSettings->AddAttribute("EXECUTABLE_SUFFIX",
     buildSettings->AddAttribute("EXECUTABLE_SUFFIX",
-                                this->CreateString(pnsuffix.c_str()));
+                                this->CreateString(pnsuffix));
     }
     }
   else if(gtgt->GetType() == cmState::OBJECT_LIBRARY)
   else if(gtgt->GetType() == cmState::OBJECT_LIBRARY)
     {
     {
@@ -2112,12 +2112,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       std::string pncdir = this->GetObjectsNormalDirectory(
       std::string pncdir = this->GetObjectsNormalDirectory(
         this->CurrentProject, configName, gtgt);
         this->CurrentProject, configName, gtgt);
       buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
       buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
-                                  this->CreateString(pncdir.c_str()));
+                                  this->CreateString(pncdir));
       }
       }
     else
     else
       {
       {
       buildSettings->AddAttribute("OBJROOT",
       buildSettings->AddAttribute("OBJROOT",
-                                  this->CreateString(pndir.c_str()));
+                                  this->CreateString(pndir));
       pndir = this->GetObjectsNormalDirectory(
       pndir = this->GetObjectsNormalDirectory(
         this->CurrentProject, configName, gtgt);
         this->CurrentProject, configName, gtgt);
       }
       }
@@ -2125,9 +2125,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
 
 
   // Store the product name for all target types.
   // Store the product name for all target types.
   buildSettings->AddAttribute("PRODUCT_NAME",
   buildSettings->AddAttribute("PRODUCT_NAME",
-                              this->CreateString(realName.c_str()));
+                              this->CreateString(realName));
   buildSettings->AddAttribute("SYMROOT",
   buildSettings->AddAttribute("SYMROOT",
-                              this->CreateString(pndir.c_str()));
+                              this->CreateString(pndir));
 
 
   // Handle settings for each target type.
   // Handle settings for each target type.
   switch(gtgt->GetType())
   switch(gtgt->GetType())
@@ -2203,7 +2203,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       {
       {
       std::string fw_version = gtgt->GetFrameworkVersion();
       std::string fw_version = gtgt->GetFrameworkVersion();
       buildSettings->AddAttribute("FRAMEWORK_VERSION",
       buildSettings->AddAttribute("FRAMEWORK_VERSION",
-                                  this->CreateString(fw_version.c_str()));
+                                  this->CreateString(fw_version));
 
 
       std::string plist = this->ComputeInfoPListLocation(gtgt);
       std::string plist = this->ComputeInfoPListLocation(gtgt);
       // Xcode will create the final version of Info.plist at build time,
       // Xcode will create the final version of Info.plist at build time,
@@ -2282,17 +2282,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       {
       {
       std::string frameworkDir = *i;
       std::string frameworkDir = *i;
       frameworkDir += "/../";
       frameworkDir += "/../";
-      frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
+      frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
       if(emitted.insert(frameworkDir).second)
       if(emitted.insert(frameworkDir).second)
         {
         {
-        fdirs.Add(this->XCodeEscapePath(frameworkDir.c_str()).c_str());
+        fdirs.Add(this->XCodeEscapePath(frameworkDir));
         }
         }
       }
       }
     else
     else
       {
       {
       std::string incpath =
       std::string incpath =
-        this->XCodeEscapePath(i->c_str());
-      dirs.Add(incpath.c_str());
+        this->XCodeEscapePath(*i);
+      dirs.Add(incpath);
       }
       }
     }
     }
   // Add framework search paths needed for linking.
   // Add framework search paths needed for linking.
@@ -2304,7 +2304,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       {
       {
       if(emitted.insert(*fdi).second)
       if(emitted.insert(*fdi).second)
         {
         {
-        fdirs.Add(this->XCodeEscapePath(fdi->c_str()).c_str());
+        fdirs.Add(this->XCodeEscapePath(*fdi));
         }
         }
       }
       }
     }
     }
@@ -2390,17 +2390,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
     if (*li == "CXX")
     if (*li == "CXX")
       {
       {
       buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS",
       buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS",
-                                  this->CreateString(flags.c_str()));
+                                  this->CreateString(flags));
       }
       }
     else if (*li == "Fortran")
     else if (*li == "Fortran")
       {
       {
       buildSettings->AddAttribute("IFORT_OTHER_FLAGS",
       buildSettings->AddAttribute("IFORT_OTHER_FLAGS",
-                                  this->CreateString(flags.c_str()));
+                                  this->CreateString(flags));
       }
       }
     else if (*li == "C")
     else if (*li == "C")
       {
       {
       buildSettings->AddAttribute("OTHER_CFLAGS",
       buildSettings->AddAttribute("OTHER_CFLAGS",
-                                  this->CreateString(flags.c_str()));
+                                  this->CreateString(flags));
       }
       }
     }
     }
 
 
@@ -2444,11 +2444,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       {
       {
       install_name_dir = "";
       install_name_dir = "";
       extraLinkOptions += " -install_name ";
       extraLinkOptions += " -install_name ";
-      extraLinkOptions += XCodeEscapePath(install_name.c_str());
+      extraLinkOptions += XCodeEscapePath(install_name);
       }
       }
     }
     }
   buildSettings->AddAttribute("INSTALL_PATH",
   buildSettings->AddAttribute("INSTALL_PATH",
-                              this->CreateString(install_name_dir.c_str()));
+                              this->CreateString(install_name_dir));
 
 
   // Create the LD_RUNPATH_SEARCH_PATHS
   // Create the LD_RUNPATH_SEARCH_PATHS
   cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName);
   cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName);
@@ -2473,18 +2473,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
           {
           {
           search_paths += " ";
           search_paths += " ";
           }
           }
-        search_paths += this->XCodeEscapePath(runpath.c_str());
+        search_paths += this->XCodeEscapePath(runpath);
         }
         }
       }
       }
     if(!search_paths.empty())
     if(!search_paths.empty())
       {
       {
       buildSettings->AddAttribute("LD_RUNPATH_SEARCH_PATHS",
       buildSettings->AddAttribute("LD_RUNPATH_SEARCH_PATHS",
-                                  this->CreateString(search_paths.c_str()));
+                                  this->CreateString(search_paths));
       }
       }
     }
     }
 
 
   buildSettings->AddAttribute(this->GetTargetLinkFlagsVar(gtgt),
   buildSettings->AddAttribute(this->GetTargetLinkFlagsVar(gtgt),
-                              this->CreateString(extraLinkOptions.c_str()));
+                              this->CreateString(extraLinkOptions));
   buildSettings->AddAttribute("OTHER_REZFLAGS",
   buildSettings->AddAttribute("OTHER_REZFLAGS",
                               this->CreateString(""));
                               this->CreateString(""));
   buildSettings->AddAttribute("SECTORDER_FLAGS",
   buildSettings->AddAttribute("SECTORDER_FLAGS",
@@ -2525,7 +2525,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       v << major << "." << minor << "." << patch;
       v << major << "." << minor << "." << patch;
       }
       }
     buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
     buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
-                                this->CreateString(v.str().c_str()));
+                                this->CreateString(v.str()));
 
 
     // SOVERSION -> compatibility_version
     // SOVERSION -> compatibility_version
     gtgt->GetTargetVersion(true, major, minor, patch);
     gtgt->GetTargetVersion(true, major, minor, patch);
@@ -2537,7 +2537,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       vso << major << "." << minor << "." << patch;
       vso << major << "." << minor << "." << patch;
       }
       }
     buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
     buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
-                                this->CreateString(vso.str().c_str()));
+                                this->CreateString(vso.str()));
     }
     }
   // put this last so it can override existing settings
   // put this last so it can override existing settings
   // Convert "XCODE_ATTRIBUTE_*" properties directly.
   // Convert "XCODE_ATTRIBUTE_*" properties directly.
@@ -2674,14 +2674,14 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
       this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
       this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
     this->CreateBuildSettings(gtgt, buildSettings,
     this->CreateBuildSettings(gtgt, buildSettings,
                               configVector[i].c_str());
                               configVector[i].c_str());
-    config->AddAttribute("name", this->CreateString(configVector[i].c_str()));
+    config->AddAttribute("name", this->CreateString(configVector[i]));
     config->SetComment(configVector[i].c_str());
     config->SetComment(configVector[i].c_str());
     config->AddAttribute("buildSettings", buildSettings);
     config->AddAttribute("buildSettings", buildSettings);
     }
     }
   if(!configVector.empty())
   if(!configVector.empty())
     {
     {
     configlist->AddAttribute("defaultConfigurationName",
     configlist->AddAttribute("defaultConfigurationName",
-                             this->CreateString(configVector[0].c_str()));
+                             this->CreateString(configVector[0]));
     configlist->AddAttribute("defaultConfigurationIsVisible",
     configlist->AddAttribute("defaultConfigurationIsVisible",
                              this->CreateString("0"));
                              this->CreateString("0"));
     return configVector[0];
     return configVector[0];
@@ -2813,7 +2813,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmGeneratorTarget* gtgt,
     {
     {
     fullName = gtgt->GetFullName(defConfig.c_str());
     fullName = gtgt->GetFullName(defConfig.c_str());
     }
     }
-  fileRef->AddAttribute("path", this->CreateString(fullName.c_str()));
+  fileRef->AddAttribute("path", this->CreateString(fullName));
   if(this->XcodeVersion == 15)
   if(this->XcodeVersion == 15)
     {
     {
     fileRef->AddAttribute("refType", this->CreateString("0"));
     fileRef->AddAttribute("refType", this->CreateString("0"));
@@ -3021,7 +3021,7 @@ void cmGlobalXCodeGenerator
         {
         {
         linkObjs += sep;
         linkObjs += sep;
         sep = " ";
         sep = " ";
-        linkObjs += this->XCodeEscapePath(oi->c_str());
+        linkObjs += this->XCodeEscapePath(*oi);
         }
         }
       this->AppendBuildSettingAttribute(
       this->AppendBuildSettingAttribute(
         target, this->GetTargetLinkFlagsVar(gt),
         target, this->GetTargetLinkFlagsVar(gt),
@@ -3068,10 +3068,10 @@ void cmGlobalXCodeGenerator
           // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
           // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
           linkDirs += " ";
           linkDirs += " ";
           linkDirs += this->XCodeEscapePath(
           linkDirs += this->XCodeEscapePath(
-            (*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)").c_str());
+            *libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)");
           }
           }
         linkDirs += " ";
         linkDirs += " ";
-        linkDirs += this->XCodeEscapePath(libDir->c_str());
+        linkDirs += this->XCodeEscapePath(*libDir);
         }
         }
       }
       }
     this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
     this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
@@ -3091,7 +3091,7 @@ void cmGlobalXCodeGenerator
       sep = " ";
       sep = " ";
       if(li->IsPath)
       if(li->IsPath)
         {
         {
-        linkLibs += this->XCodeEscapePath(li->Value.c_str());
+        linkLibs += this->XCodeEscapePath(li->Value);
         }
         }
       else if (!li->Target
       else if (!li->Target
           || li->Target->GetType() != cmState::INTERFACE_LIBRARY)
           || li->Target->GetType() != cmState::INTERFACE_LIBRARY)
@@ -3200,7 +3200,7 @@ cmXCodeObject *cmGlobalXCodeGenerator
   cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
   cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
   cmXCodeObject* groupChildren =
   cmXCodeObject* groupChildren =
   this->CreateObject(cmXCodeObject::OBJECT_LIST);
   this->CreateObject(cmXCodeObject::OBJECT_LIST);
-  group->AddAttribute("name", this->CreateString(name.c_str()));
+  group->AddAttribute("name", this->CreateString(name));
   group->AddAttribute("children", groupChildren);
   group->AddAttribute("children", groupChildren);
   if(this->XcodeVersion == 15)
   if(this->XcodeVersion == 15)
   {
   {
@@ -3447,7 +3447,7 @@ bool cmGlobalXCodeGenerator
   std::string pdir =
   std::string pdir =
     this->RelativeToBinary(root->GetCurrentSourceDirectory());
     this->RelativeToBinary(root->GetCurrentSourceDirectory());
   this->RootObject->AddAttribute("projectDirPath",
   this->RootObject->AddAttribute("projectDirPath",
-                                 this->CreateString(pdir.c_str()));
+                                 this->CreateString(pdir));
   this->RootObject->AddAttribute("projectRoot", this->CreateString(""));
   this->RootObject->AddAttribute("projectRoot", this->CreateString(""));
   }
   }
   cmXCodeObject* configlist =
   cmXCodeObject* configlist =
@@ -3528,7 +3528,7 @@ bool cmGlobalXCodeGenerator
   else
   else
     {
     {
     // Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO).
     // Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO).
-    buildSettings->AddAttribute("ARCHS", this->CreateString(archs.c_str()));
+    buildSettings->AddAttribute("ARCHS", this->CreateString(archs));
     }
     }
   if(deploymentTarget && *deploymentTarget)
   if(deploymentTarget && *deploymentTarget)
     {
     {
@@ -3538,12 +3538,12 @@ bool cmGlobalXCodeGenerator
   if(!this->GeneratorToolset.empty())
   if(!this->GeneratorToolset.empty())
     {
     {
     buildSettings->AddAttribute("GCC_VERSION",
     buildSettings->AddAttribute("GCC_VERSION",
-      this->CreateString(this->GeneratorToolset.c_str()));
+      this->CreateString(this->GeneratorToolset));
     }
     }
 
 
   std::string symroot = root->GetCurrentBinaryDirectory();
   std::string symroot = root->GetCurrentBinaryDirectory();
   symroot += "/build";
   symroot += "/build";
-  buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot.c_str()));
+  buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot));
 
 
   for(Configs::iterator i = configs.begin(); i != configs.end(); ++i)
   for(Configs::iterator i = configs.begin(); i != configs.end(); ++i)
     {
     {
@@ -3932,17 +3932,16 @@ std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p)
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
-std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p)
+std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p)
 {
 {
-  std::string ret = p;
-  if(ret.find(' ') != ret.npos)
+  if(p.find(' ') != p.npos)
     {
     {
-    std::string t = ret;
-    ret = "\"";
-    ret += t;
-    ret += "\"";
+    std::string t = "\"";
+    t += p;
+    t += "\"";
+    return t;
     }
     }
-  return ret;
+  return p;
 }
 }
 
 
 //----------------------------------------------------------------------------
 //----------------------------------------------------------------------------
@@ -4025,7 +4024,7 @@ cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs,
     // Append the flag with needed escapes.
     // Append the flag with needed escapes.
     std::string tmp;
     std::string tmp;
     this->AppendFlag(tmp, def);
     this->AppendFlag(tmp, def);
-    defs.Add(tmp.c_str());
+    defs.Add(tmp);
     }
     }
 }
 }
 
 

+ 1 - 1
Source/cmGlobalXCodeGenerator.h

@@ -96,7 +96,7 @@ private:
   bool CreateGroups(cmLocalGenerator* root,
   bool CreateGroups(cmLocalGenerator* root,
                     std::vector<cmLocalGenerator*>&
                     std::vector<cmLocalGenerator*>&
                     generators);
                     generators);
-  std::string XCodeEscapePath(const char* p);
+  std::string XCodeEscapePath(const std::string& p);
   std::string RelativeToSource(const char* p);
   std::string RelativeToSource(const char* p);
   std::string RelativeToBinary(const char* p);
   std::string RelativeToBinary(const char* p);
   std::string ConvertToRelativeForMake(const char* p);
   std::string ConvertToRelativeForMake(const char* p);