Add flags to detect unused variables

This commit is contained in:
Ben Boeckel 2010-08-24 16:49:49 -04:00
parent f332e14ff2
commit d3e8eb5041
3 changed files with 24 additions and 0 deletions

View File

@ -141,6 +141,8 @@ cmake::cmake()
{
this->Trace = false;
this->StrictMode = false;
this->FindUnused = false;
this->DefaultToUsed = false;
this->SuppressDevWarnings = false;
this->DoSuppressDevWarnings = false;
this->DebugOutput = false;
@ -619,6 +621,18 @@ void cmake::SetArgs(const std::vector<std::string>& args)
std::cout << "Running in strict mode.\n";
this->SetStrictMode(true);
}
else if(arg.find("--find-unused",0) == 0)
{
std::cout << "Finding unused command line variables.\n";
this->SetFindUnused(true);
this->SetDefaultToUsed(true);
}
else if(arg.find("--find-unused-all",0) == 0)
{
std::cout << "Finding unused variables.\n";
this->SetFindUnused(true);
this->SetDefaultToUsed(false);
}
else if(arg.find("-G",0) == 0)
{
std::string value = arg.substr(2);

View File

@ -308,6 +308,10 @@ class cmake
void SetTrace(bool b) { this->Trace = b;}
bool GetStrictMode() { return this->StrictMode;}
void SetStrictMode(bool b) { this->StrictMode = b;}
bool GetFindUnused() { return this->FindUnused;}
void SetFindUnused(bool b) { this->FindUnused = b;}
bool GetDefaultToUsed() { return this->DefaultToUsed;}
void SetDefaultToUsed(bool b) { this->DefaultToUsed = b;}
// Define a property
void DefineProperty(const char *name, cmProperty::ScopeType scope,
const char *ShortDescription,
@ -446,6 +450,8 @@ private:
bool DebugOutput;
bool Trace;
bool StrictMode;
bool FindUnused;
bool DefaultToUsed;
std::string CMakeEditCommand;
std::string CMakeCommand;
std::string CXXEnvironment;

View File

@ -123,6 +123,10 @@ static const char * cmDocumentationOptions[][3] =
{"--strict-mode", "Put cmake in strict mode.",
"In strict mode cmake will print a warning when an uninitialized variable "
"is used."},
{"--find-unused", "Find unused variables.",
"Find variables that are declared on the command line, but not used."},
{"--find-unused-all", "Find all unused variables.",
"Find variables that are declared, but not used."},
{"--help-command cmd [file]", "Print help for a single command and exit.",
"Full documentation specific to the given command is displayed. "
"If a file is specified, the documentation is written into and the output "