diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2019-02-06 22:44:53 (GMT) |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2019-02-07 12:35:16 (GMT) |
commit | 00ba28ffd03a9a0cf00d78001573bc5cc045ee72 (patch) | |
tree | bb8c241b1938470badd41ecf2499a48317b11e1d /Source | |
parent | 0741eda2468e482baf1b5ff6a3a8d376143171e4 (diff) | |
download | CMake-00ba28ffd03a9a0cf00d78001573bc5cc045ee72.zip CMake-00ba28ffd03a9a0cf00d78001573bc5cc045ee72.tar.gz CMake-00ba28ffd03a9a0cf00d78001573bc5cc045ee72.tar.bz2 |
cmMakefile::GetRequiredDefinition: return const std::string&
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExtraCodeBlocksGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmExtraCodeLiteGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmExtraEclipseCDT4Generator.cxx | 7 | ||||
-rw-r--r-- | Source/cmExtraKateGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmExtraSublimeTextGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/cmGlobalMSYSMakefileGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmGlobalMinGWMakefileGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 11 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 12 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 15 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 28 | ||||
-rw-r--r-- | Source/cmUtilitySourceCommand.cxx | 2 |
16 files changed, 57 insertions, 55 deletions
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index e408de3..d9ae4eb 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -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); diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 0773edc..6fe8c14 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -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) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 30067b7..a6ce8b7 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -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()) { diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 23ba6b7..76de75d 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -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(); diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 739a177..59cfdca 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -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, diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 386a3f7..50d361e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -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; diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index 3c24556..606febe 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -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)); diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index c6d46e9..e218b4b 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -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"); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 59701a1..5cee9d3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -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; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 252aa4c..11ea930 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -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. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7019552..3946285 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -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"); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ab139c0..dcdaa13 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -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 diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 70a5689..fce90f2 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -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 diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index af34169..cfaa1fd9 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -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); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5d76dc2..b525dac 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -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); } diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 231bca4..b59a587 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -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; |