mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
cmCommandArgumentParserHelper: use cmMakefile::MaybeWarnUninitialized
It removes logic duplication and need to have cached WarnUninitialized and CheckSystemVars
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -16,8 +15,6 @@ int cmCommandArgument_yyparse(yyscan_t yyscanner);
|
||||
//
|
||||
cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
|
||||
{
|
||||
this->WarnUninitialized = false;
|
||||
this->CheckSystemVars = false;
|
||||
this->FileLine = -1;
|
||||
this->FileName = nullptr;
|
||||
this->RemoveEmpty = true;
|
||||
@@ -96,21 +93,7 @@ const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
|
||||
}
|
||||
const char* value = this->Makefile->GetDefinition(var);
|
||||
if (!value && !this->RemoveEmpty) {
|
||||
// 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->WarnUninitialized && !this->Makefile->VariableInitialized(var)) {
|
||||
if (this->CheckSystemVars ||
|
||||
(this->FileName &&
|
||||
(cmSystemTools::IsSubDirectory(
|
||||
this->FileName, this->Makefile->GetHomeDirectory()) ||
|
||||
cmSystemTools::IsSubDirectory(
|
||||
this->FileName, this->Makefile->GetHomeOutputDirectory())))) {
|
||||
std::ostringstream msg;
|
||||
msg << "uninitialized variable \'" << var << "\'";
|
||||
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
|
||||
}
|
||||
}
|
||||
this->Makefile->MaybeWarnUninitialized(var, this->FileName);
|
||||
return nullptr;
|
||||
}
|
||||
if (this->EscapeQuotes && value) {
|
||||
@@ -286,8 +269,6 @@ void cmCommandArgumentParserHelper::Error(const char* str)
|
||||
void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
|
||||
{
|
||||
this->Makefile = mf;
|
||||
this->WarnUninitialized = mf->GetCMakeInstance()->GetWarnUninitialized();
|
||||
this->CheckSystemVars = mf->GetCMakeInstance()->GetCheckSystemVars();
|
||||
}
|
||||
|
||||
void cmCommandArgumentParserHelper::SetResult(const char* value)
|
||||
|
||||
Reference in New Issue
Block a user