summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2020-05-29 04:00:00 (GMT)
committerVitaly Stakhovsky <vvs31415@gitlab.org>2020-05-29 17:12:22 (GMT)
commit1e805f53f5520d8b13d306331fe1f0b34b5d9d7d (patch)
tree904b39e963db393fa5f982c39639361693d26b6e
parent1336d11d9ceabf070b75816b91c7ae9459f0817c (diff)
downloadCMake-1e805f53f5520d8b13d306331fe1f0b34b5d9d7d.zip
CMake-1e805f53f5520d8b13d306331fe1f0b34b5d9d7d.tar.gz
CMake-1e805f53f5520d8b13d306331fe1f0b34b5d9d7d.tar.bz2
GetDefinition: avoid duplicate calls
-rw-r--r--Source/CPack/cmCPackGenerator.cxx7
-rw-r--r--Source/cmForEachCommand.cxx8
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx4
-rw-r--r--Source/cmNinjaTargetGenerator.cxx6
-rw-r--r--Source/cmUtilitySourceCommand.cxx4
5 files changed, 14 insertions, 15 deletions
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 08fd2a2..288dc58 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -921,11 +921,11 @@ int cmCPackGenerator::InstallCMakeProject(
}
}
- if (nullptr != mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
+ if (auto d = mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
if (!absoluteDestFiles.empty()) {
absoluteDestFiles += ";";
}
- absoluteDestFiles += mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
+ absoluteDestFiles += d;
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Got some ABSOLUTE DESTINATION FILES: " << absoluteDestFiles
<< std::endl);
@@ -936,8 +936,7 @@ int cmCPackGenerator::InstallCMakeProject(
GetComponentInstallDirNameSuffix(component);
if (nullptr != this->GetOption(absoluteDestFileComponent)) {
std::string absoluteDestFilesListComponent =
- cmStrCat(this->GetOption(absoluteDestFileComponent), ';',
- mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
+ cmStrCat(this->GetOption(absoluteDestFileComponent), ';', d);
this->SetOption(absoluteDestFileComponent,
absoluteDestFilesListComponent.c_str());
} else {
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 32e7892..3b82e0a 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -113,8 +113,8 @@ bool cmForEachFunctionBlocker::ReplayItems(
// At end of for each execute recorded commands
// store the old value
std::string oldDef;
- if (mf.GetDefinition(this->Args.front())) {
- oldDef = mf.GetDefinition(this->Args.front());
+ if (auto d = mf.GetDefinition(this->Args.front())) {
+ oldDef = d;
}
auto restore = false;
@@ -186,8 +186,8 @@ bool cmForEachFunctionBlocker::ReplayZipLists(
// Store old values for iteration variables
std::map<std::string, std::string> oldDefs;
for (auto i = 0u; i < values.size(); ++i) {
- if (mf.GetDefinition(iterationVars[i])) {
- oldDefs.emplace(iterationVars[i], mf.GetDefinition(iterationVars[i]));
+ if (auto d = mf.GetDefinition(iterationVars[i])) {
+ oldDefs.emplace(iterationVars[i], d);
}
}
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index f87eba7..b9f6f8c 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -1027,8 +1027,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
gt->GetFullNameComponents(prefix, base, suffix, config);
std::string dbg_suffix = ".dbg";
// TODO: Where to document?
- if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) {
- dbg_suffix = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX");
+ if (auto d = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) {
+ dbg_suffix = d;
}
vars["TARGET_PDB"] = base + suffix + dbg_suffix;
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index c77a85b..4390790 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -749,9 +749,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
if (!mf->GetIsSourceFileTryCompile()) {
rule.DepType = "gcc";
rule.DepFile = "$DEP_FILE";
- const std::string cl = mf->GetDefinition("CMAKE_C_COMPILER")
- ? mf->GetSafeDefinition("CMAKE_C_COMPILER")
- : mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
+ auto d = mf->GetDefinition("CMAKE_C_COMPILER");
+ const std::string cl =
+ d ? d : mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
cldeps = cmStrCat('"', cmSystemTools::GetCMClDepsCommand(), "\" ", lang,
' ', vars.Source, " $DEP_FILE $out \"",
mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"),
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index 5865a19..6de78ff 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -84,8 +84,8 @@ bool cmUtilitySourceCommand(std::vector<std::string> const& args,
std::string utilityDirectory =
status.GetMakefile().GetCurrentBinaryDirectory();
std::string exePath;
- if (status.GetMakefile().GetDefinition("EXECUTABLE_OUTPUT_PATH")) {
- exePath = status.GetMakefile().GetDefinition("EXECUTABLE_OUTPUT_PATH");
+ if (auto d = status.GetMakefile().GetDefinition("EXECUTABLE_OUTPUT_PATH")) {
+ exePath = d;
}
if (!exePath.empty()) {
utilityDirectory = exePath;