diff options
-rw-r--r-- | Source/cmMakefile.cxx | 30 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 |
2 files changed, 20 insertions, 12 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index bbbe300..256202c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1837,6 +1837,23 @@ bool cmMakefile::VariableInitialized(const std::string& var) const return this->StateSnapshot.IsInitialized(var); } +void cmMakefile::MaybeWarnUninitialized(std::string const& variable, + const char* sourceFilename) const +{ + // check to see if we need to print a warning + // if strict mode is on and the variable has + // not been "cleared"/initialized with a set(foo ) call + if (this->GetCMakeInstance()->GetWarnUninitialized() && + !this->VariableInitialized(variable)) { + if (this->CheckSystemVars || + (sourceFilename && this->IsProjectFile(sourceFilename))) { + std::ostringstream msg; + msg << "uninitialized variable \'" << variable << "\'"; + this->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); + } + } +} + void cmMakefile::LogUnused(const char* reason, const std::string& name) const { if (this->WarnUnused) { @@ -2767,18 +2784,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( varresult = value; } } else if (!removeEmpty && !this->SuppressSideEffects) { - // check to see if we need to print a warning - // if strict mode is on and the variable has - // not been "cleared"/initialized with a set(foo ) call - if (this->GetCMakeInstance()->GetWarnUninitialized() && - !this->VariableInitialized(lookup)) { - if (this->CheckSystemVars || - (filename && this->IsProjectFile(filename))) { - std::ostringstream msg; - msg << "uninitialized variable \'" << lookup << "\'"; - this->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); - } - } + this->MaybeWarnUninitialized(lookup, filename); } result.replace(var.loc, result.size() - var.loc, varresult); // Start looking from here on out. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index be1e6a1..1a2a0e7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -866,6 +866,8 @@ public: std::deque<std::vector<std::string>> FindPackageRootPathStack; void MaybeWarnCMP0074(std::string const& pkg); + void MaybeWarnUninitialized(std::string const& variable, + const char* sourceFilename) const; bool IsProjectFile(const char* filename) const; protected: |