mirror of
https://github.com/reactos/CMake.git
synced 2025-02-26 06:55:34 +00:00
cmMakefile::GetRequiredDefinition: return const std::string&
This commit is contained in:
parent
0741eda246
commit
00ba28ffd0
@ -247,8 +247,8 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
|
||||
|
||||
// figure out the compiler
|
||||
std::string compiler = this->GetCBCompilerId(mf);
|
||||
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string makeArgs =
|
||||
const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string& makeArgs =
|
||||
mf->GetSafeDefinition("CMAKE_CODEBLOCKS_MAKE_ARGUMENTS");
|
||||
|
||||
cmXMLWriter xml(fout);
|
||||
|
@ -628,8 +628,8 @@ std::string cmExtraCodeLiteGenerator::GetConfigurationName(
|
||||
std::string cmExtraCodeLiteGenerator::GetBuildCommand(
|
||||
const cmMakefile* mf, const std::string& targetName) const
|
||||
{
|
||||
std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
|
||||
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string& generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
|
||||
const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
std::string buildCommand = make; // Default
|
||||
std::ostringstream ss;
|
||||
if (generator == "NMake Makefiles" || generator == "Ninja") {
|
||||
@ -669,8 +669,8 @@ std::string cmExtraCodeLiteGenerator::GetSingleFileBuildCommand(
|
||||
const cmMakefile* mf) const
|
||||
{
|
||||
std::string buildCommand;
|
||||
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
|
||||
const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string& generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
|
||||
if (generator == "Unix Makefiles" || generator == "MinGW Makefiles") {
|
||||
std::ostringstream ss;
|
||||
#if defined(_WIN32)
|
||||
|
@ -878,8 +878,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
|
||||
xml.Attribute("moduleId", "org.eclipse.cdt.make.core.buildtargets");
|
||||
xml.StartElement("buildTargets");
|
||||
emmited.clear();
|
||||
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string makeArgs =
|
||||
const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string& makeArgs =
|
||||
mf->GetSafeDefinition("CMAKE_ECLIPSE_MAKE_ARGUMENTS");
|
||||
|
||||
cmGlobalGenerator* generator =
|
||||
@ -1074,7 +1074,8 @@ void cmExtraEclipseCDT4Generator::AppendStorageScanners(
|
||||
cmXMLWriter& xml, const cmMakefile& makefile)
|
||||
{
|
||||
// we need the "make" and the C (or C++) compiler which are used, Alex
|
||||
std::string make = makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string& make =
|
||||
makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
std::string compiler = makefile.GetSafeDefinition("CMAKE_C_COMPILER");
|
||||
std::string arg1 = makefile.GetSafeDefinition("CMAKE_C_COMPILER_ARG1");
|
||||
if (compiler.empty()) {
|
||||
|
@ -75,8 +75,8 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
|
||||
cmGeneratedFileStream& fout) const
|
||||
{
|
||||
cmMakefile const* mf = lg->GetMakefile();
|
||||
const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string makeArgs =
|
||||
const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string& makeArgs =
|
||||
mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS");
|
||||
std::string const& homeOutputDir = lg->GetBinaryDirectory();
|
||||
|
||||
|
@ -168,7 +168,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets(
|
||||
const std::vector<cmLocalGenerator*>& lgs, const cmMakefile* mf,
|
||||
cmGeneratedFileStream& fout, MapSourceFileFlags& sourceFileFlags)
|
||||
{
|
||||
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
std::string compiler;
|
||||
if (!lgs.empty()) {
|
||||
this->AppendTarget(fout, "all", lgs[0], nullptr, make.c_str(), mf,
|
||||
|
@ -680,8 +680,9 @@ void cmGlobalGenerator::EnableLanguage(
|
||||
std::string compilerEnv = "CMAKE_";
|
||||
compilerEnv += lang;
|
||||
compilerEnv += "_COMPILER_ENV_VAR";
|
||||
std::string envVar = mf->GetRequiredDefinition(compilerEnv);
|
||||
std::string envVarValue = mf->GetRequiredDefinition(compilerName);
|
||||
const std::string& envVar = mf->GetRequiredDefinition(compilerEnv);
|
||||
const std::string& envVarValue =
|
||||
mf->GetRequiredDefinition(compilerName);
|
||||
std::string env = envVar;
|
||||
env += "=";
|
||||
env += envVarValue;
|
||||
|
@ -45,7 +45,8 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage(
|
||||
std::vector<std::string> const& l, cmMakefile* mf, bool optional)
|
||||
{
|
||||
this->FindMakeProgram(mf);
|
||||
std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string& makeProgram =
|
||||
mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
std::vector<std::string> locations;
|
||||
std::string makeloc = cmSystemTools::GetProgramPath(makeProgram.c_str());
|
||||
locations.push_back(this->FindMinGW(makeloc));
|
||||
|
@ -23,7 +23,8 @@ void cmGlobalMinGWMakefileGenerator::EnableLanguage(
|
||||
std::vector<std::string> const& l, cmMakefile* mf, bool optional)
|
||||
{
|
||||
this->FindMakeProgram(mf);
|
||||
std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
const std::string& makeProgram =
|
||||
mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
|
||||
std::vector<std::string> locations;
|
||||
locations.push_back(cmSystemTools::GetProgramPath(makeProgram));
|
||||
locations.push_back("/mingw/bin");
|
||||
|
@ -825,7 +825,7 @@ void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, Indent indent,
|
||||
return;
|
||||
}
|
||||
|
||||
std::string ranlib =
|
||||
const std::string& ranlib =
|
||||
this->Target->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB");
|
||||
if (ranlib.empty()) {
|
||||
return;
|
||||
|
@ -1364,9 +1364,9 @@ void cmLocalGenerator::OutputLinkLibraries(
|
||||
|
||||
std::string linkLanguage = cli.GetLinkLanguage();
|
||||
|
||||
std::string libPathFlag =
|
||||
const std::string& libPathFlag =
|
||||
this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
|
||||
std::string libPathTerminator =
|
||||
const std::string& libPathTerminator =
|
||||
this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR");
|
||||
|
||||
// Add standard libraries for this language.
|
||||
|
@ -931,7 +931,7 @@ std::string cmLocalVisualStudio7Generator::GetBuildTypeLinkerFlags(
|
||||
std::string extraLinkOptionsBuildTypeDef =
|
||||
rootLinkerFlags + "_" + configTypeUpper;
|
||||
|
||||
std::string extraLinkOptionsBuildType =
|
||||
const std::string& extraLinkOptionsBuildType =
|
||||
this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef);
|
||||
|
||||
return extraLinkOptionsBuildType;
|
||||
@ -947,21 +947,18 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
|
||||
std::string extraLinkOptions;
|
||||
if (target->GetType() == cmStateEnums::EXECUTABLE) {
|
||||
extraLinkOptions =
|
||||
this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") +
|
||||
std::string(" ") +
|
||||
this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") + " " +
|
||||
GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName);
|
||||
}
|
||||
if (target->GetType() == cmStateEnums::SHARED_LIBRARY) {
|
||||
extraLinkOptions =
|
||||
this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS") +
|
||||
std::string(" ") +
|
||||
GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
|
||||
" " + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
|
||||
}
|
||||
if (target->GetType() == cmStateEnums::MODULE_LIBRARY) {
|
||||
extraLinkOptions =
|
||||
this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") +
|
||||
std::string(" ") +
|
||||
GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
|
||||
" " + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
|
||||
}
|
||||
|
||||
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
|
||||
|
@ -2425,16 +2425,18 @@ bool cmMakefile::CanIWriteThisFile(std::string const& fileName) const
|
||||
cmSystemTools::SameFile(fileName, this->GetHomeOutputDirectory());
|
||||
}
|
||||
|
||||
std::string cmMakefile::GetRequiredDefinition(const std::string& name) const
|
||||
const std::string& cmMakefile::GetRequiredDefinition(
|
||||
const std::string& name) const
|
||||
{
|
||||
const char* ret = this->GetDefinition(name);
|
||||
if (!ret) {
|
||||
static std::string const empty;
|
||||
const std::string* def = GetDef(name);
|
||||
if (!def) {
|
||||
cmSystemTools::Error("Error required internal CMake variable not "
|
||||
"set, cmake may not be built correctly.\n",
|
||||
"Missing variable is:\n", name.c_str());
|
||||
return std::string();
|
||||
return empty;
|
||||
}
|
||||
return std::string(ret);
|
||||
return *def;
|
||||
}
|
||||
|
||||
bool cmMakefile::IsDefinitionSet(const std::string& name) const
|
||||
|
@ -436,7 +436,7 @@ public:
|
||||
const char* GetDefinition(const std::string&) const;
|
||||
const std::string* GetDef(const std::string&) const;
|
||||
const std::string& GetSafeDefinition(const std::string&) const;
|
||||
std::string GetRequiredDefinition(const std::string& name) const;
|
||||
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
|
||||
|
@ -654,19 +654,20 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
|
||||
std::string cmdVar;
|
||||
if (this->GeneratorTarget->GetPropertyAsBool(
|
||||
"CUDA_SEPARABLE_COMPILATION")) {
|
||||
cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION");
|
||||
cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION";
|
||||
} else if (this->GeneratorTarget->GetPropertyAsBool(
|
||||
"CUDA_PTX_COMPILATION")) {
|
||||
cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION");
|
||||
cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION";
|
||||
} else {
|
||||
cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION");
|
||||
cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION";
|
||||
}
|
||||
std::string compileRule = this->Makefile->GetRequiredDefinition(cmdVar);
|
||||
const std::string& compileRule =
|
||||
this->Makefile->GetRequiredDefinition(cmdVar);
|
||||
cmSystemTools::ExpandListArgument(compileRule, compileCommands);
|
||||
} else {
|
||||
const std::string cmdVar =
|
||||
std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
|
||||
std::string compileRule = this->Makefile->GetRequiredDefinition(cmdVar);
|
||||
const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT";
|
||||
const std::string& compileRule =
|
||||
this->Makefile->GetRequiredDefinition(cmdVar);
|
||||
cmSystemTools::ExpandListArgument(compileRule, compileCommands);
|
||||
}
|
||||
|
||||
|
@ -493,7 +493,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
|
||||
if (explicitPP) {
|
||||
// Lookup the explicit preprocessing rule.
|
||||
std::string const ppVar = "CMAKE_" + lang + "_PREPROCESS_SOURCE";
|
||||
std::string const ppCmd =
|
||||
std::string const& ppCmd =
|
||||
this->GetMakefile()->GetRequiredDefinition(ppVar);
|
||||
|
||||
// Explicit preprocessing always uses a depfile.
|
||||
@ -671,19 +671,18 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
|
||||
std::string cmdVar;
|
||||
if (this->GeneratorTarget->GetPropertyAsBool(
|
||||
"CUDA_SEPARABLE_COMPILATION")) {
|
||||
cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION");
|
||||
cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION";
|
||||
} else if (this->GeneratorTarget->GetPropertyAsBool(
|
||||
"CUDA_PTX_COMPILATION")) {
|
||||
cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION");
|
||||
cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION";
|
||||
} else {
|
||||
cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION");
|
||||
cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION";
|
||||
}
|
||||
std::string compileCmd = mf->GetRequiredDefinition(cmdVar);
|
||||
const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar);
|
||||
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
|
||||
} else {
|
||||
const std::string cmdVar =
|
||||
std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
|
||||
std::string compileCmd = mf->GetRequiredDefinition(cmdVar);
|
||||
const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT";
|
||||
const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar);
|
||||
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
|
||||
}
|
||||
|
||||
@ -1213,20 +1212,19 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
|
||||
std::string cmdVar;
|
||||
if (this->GeneratorTarget->GetPropertyAsBool(
|
||||
"CUDA_SEPARABLE_COMPILATION")) {
|
||||
cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION");
|
||||
cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION";
|
||||
} else if (this->GeneratorTarget->GetPropertyAsBool(
|
||||
"CUDA_PTX_COMPILATION")) {
|
||||
cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION");
|
||||
cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION";
|
||||
} else {
|
||||
cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION");
|
||||
cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION";
|
||||
}
|
||||
std::string compileCmd =
|
||||
const std::string& compileCmd =
|
||||
this->GetMakefile()->GetRequiredDefinition(cmdVar);
|
||||
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
|
||||
} else {
|
||||
const std::string cmdVar =
|
||||
std::string("CMAKE_") + language + "_COMPILE_OBJECT";
|
||||
std::string compileCmd =
|
||||
const std::string cmdVar = "CMAKE_" + language + "_COMPILE_OBJECT";
|
||||
const std::string& compileCmd =
|
||||
this->GetMakefile()->GetRequiredDefinition(cmdVar);
|
||||
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
// The source exists.
|
||||
std::string cmakeCFGout =
|
||||
const std::string& cmakeCFGout =
|
||||
this->Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
|
||||
std::string utilityDirectory = this->Makefile->GetCurrentBinaryDirectory();
|
||||
std::string exePath;
|
||||
|
Loading…
x
Reference in New Issue
Block a user