Ver código fonte

Merge topic 'grd-stdstring'

4d89830d71 cmMakefile: Make GetRequiredDefinition return std::string

Acked-by: Kitware Robot <[email protected]>
Merge-request: !2347
Brad King 7 anos atrás
pai
commit
e1ebec55d4

+ 1 - 1
Source/cmFLTKWrapUICommand.cxx

@@ -23,7 +23,7 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
 
   // what is the current source dir
   std::string cdir = this->Makefile->GetCurrentSourceDirectory();
-  const char* fluid_exe =
+  std::string const& fluid_exe =
     this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE");
 
   // get parameter for the command

+ 2 - 2
Source/cmFindLibraryCommand.cxx

@@ -236,9 +236,9 @@ cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf)
   this->GG = this->Makefile->GetGlobalGenerator();
 
   // Collect the list of library name prefixes/suffixes to try.
-  const char* prefixes_list =
+  std::string const& prefixes_list =
     this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_PREFIXES");
-  const char* suffixes_list =
+  std::string const& suffixes_list =
     this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_SUFFIXES");
   cmSystemTools::ExpandListArgument(prefixes_list, this->Prefixes, true);
   cmSystemTools::ExpandListArgument(suffixes_list, this->Suffixes, true);

+ 1 - 1
Source/cmGlobalGenerator.cxx

@@ -205,7 +205,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang,
     }
     return;
   }
-  const char* name = mf->GetRequiredDefinition(langComp);
+  std::string const& name = mf->GetRequiredDefinition(langComp);
   std::string path;
   if (!cmSystemTools::FileIsFullPath(name)) {
     path = cmSystemTools::FindProgram(name);

+ 1 - 2
Source/cmLocalCommonGenerator.cxx

@@ -54,9 +54,8 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
       this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
   }
   if (!mod_dir.empty()) {
-    const char* moddir_flag =
+    std::string modflag =
       this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
-    std::string modflag = moddir_flag;
     modflag += mod_dir;
     this->AppendFlags(flags, modflag);
   }

+ 1 - 1
Source/cmLocalGenerator.cxx

@@ -1655,7 +1655,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
     std::string option_flag =
       "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION";
 
-    const char* opt =
+    std::string const& opt =
       target->Target->GetMakefile()->GetRequiredDefinition(option_flag);
     std::vector<std::string> optVec;
     cmSystemTools::ExpandListArgument(opt, optVec);

+ 3 - 4
Source/cmLocalVisualStudio7Generator.cxx

@@ -665,11 +665,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
       std::string baseFlagVar = "CMAKE_";
       baseFlagVar += langForClCompile;
       baseFlagVar += "_FLAGS";
-      flags = this->Makefile->GetRequiredDefinition(baseFlagVar.c_str());
+      flags = this->Makefile->GetRequiredDefinition(baseFlagVar);
       std::string flagVar =
         baseFlagVar + std::string("_") + cmSystemTools::UpperCase(configName);
       flags += " ";
-      flags += this->Makefile->GetRequiredDefinition(flagVar.c_str());
+      flags += this->Makefile->GetRequiredDefinition(flagVar);
     }
     // set the correct language
     if (linkLanguage == "C") {
@@ -931,8 +931,7 @@ std::string cmLocalVisualStudio7Generator::GetBuildTypeLinkerFlags(
     rootLinkerFlags + "_" + configTypeUpper;
 
   std::string extraLinkOptionsBuildType =
-    this->Makefile->GetRequiredDefinition(
-      extraLinkOptionsBuildTypeDef.c_str());
+    this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef);
 
   return extraLinkOptionsBuildType;
 }

+ 3 - 3
Source/cmMakefile.cxx

@@ -2354,16 +2354,16 @@ bool cmMakefile::CanIWriteThisFile(std::string const& fileName) const
     cmSystemTools::SameFile(fileName, this->GetHomeOutputDirectory());
 }
 
-const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
+std::string cmMakefile::GetRequiredDefinition(const std::string& name) const
 {
   const char* ret = this->GetDefinition(name);
   if (!ret) {
     cmSystemTools::Error("Error required internal CMake variable not "
                          "set, cmake may not be built correctly.\n",
                          "Missing variable is:\n", name.c_str());
-    return "";
+    return std::string();
   }
-  return ret;
+  return std::string(ret);
 }
 
 bool cmMakefile::IsDefinitionSet(const std::string& name) const

+ 1 - 1
Source/cmMakefile.h

@@ -423,7 +423,7 @@ public:
    */
   const char* GetDefinition(const std::string&) const;
   const char* GetSafeDefinition(const std::string&) const;
-  const char* GetRequiredDefinition(const std::string& name) const;
+  std::string GetRequiredDefinition(const std::string& name) const;
   bool IsDefinitionSet(const std::string&) const;
   /**
    * Get the list of all variables in the current space. If argument

+ 2 - 2
Source/cmNinjaNormalTargetGenerator.cxx

@@ -530,7 +530,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
         linkCmdVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable(
           linkCmdVar, this->TargetLinkLanguage, this->GetConfigName());
 
-        const char* linkCmd = mf->GetRequiredDefinition(linkCmdVar);
+        std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar);
         cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
       }
       {
@@ -541,7 +541,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
         linkCmdVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable(
           linkCmdVar, this->TargetLinkLanguage, this->GetConfigName());
 
-        const char* linkCmd = mf->GetRequiredDefinition(linkCmdVar);
+        std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar);
         cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
       }
       return linkCmds;

+ 1 - 1
Source/cmQTWrapCPPCommand.cxx

@@ -21,7 +21,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
   }
 
   // Get the moc executable to run in the custom command.
-  const char* moc_exe =
+  std::string const& moc_exe =
     this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
 
   // Get the variable holding the list of sources.

+ 2 - 2
Source/cmQTWrapUICommand.cxx

@@ -21,9 +21,9 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
   }
 
   // Get the uic and moc executables to run in the custom commands.
-  const char* uic_exe =
+  std::string const& uic_exe =
     this->Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE");
-  const char* moc_exe =
+  std::string const& moc_exe =
     this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
 
   // Get the variable holding the list of sources.

+ 2 - 2
Source/cmUtilitySourceCommand.cxx

@@ -28,7 +28,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
   // If it exists already and appears up to date then we are done.  If
   // the string contains "(IntDir)" but that is not the
   // CMAKE_CFG_INTDIR setting then the value is out of date.
-  const char* intDir =
+  std::string const& intDir =
     this->Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
 
   bool haveCacheValue = false;
@@ -46,7 +46,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
     cmState* state = this->Makefile->GetState();
     haveCacheValue = (cacheValue &&
                       (strstr(cacheValue, "(IntDir)") == nullptr ||
-                       (intDir && strcmp(intDir, "$(IntDir)") == 0)) &&
+                       (intDir == "$(IntDir)")) &&
                       (state->GetCacheMajorVersion() != 0 &&
                        state->GetCacheMinorVersion() != 0));
   }

+ 1 - 1
Source/cmVisualStudio10TargetGenerator.cxx

@@ -2471,7 +2471,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
     baseFlagVar += "_FLAGS";
     flags = this->Makefile->GetRequiredDefinition(baseFlagVar);
     std::string flagVar =
-      baseFlagVar + std::string("_") + cmSystemTools::UpperCase(configName);
+      baseFlagVar + "_" + cmSystemTools::UpperCase(configName);
     flags += " ";
     flags += this->Makefile->GetRequiredDefinition(flagVar);
     this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,