mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 22:30:07 -05:00
cmMakefile: Make GetRequiredDefinition return std::string
In all cases the return value is converted to std::string anyway. Also remove unnecessary `c_str()` calls in arguments to `GetRequiredDefinition`.
This commit is contained in:
committed by
Brad King
parent
612975c665
commit
4d89830d71
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -2468,7 +2468,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,
|
||||
|
||||
Reference in New Issue
Block a user