summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2010-09-01 14:22:08 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2010-09-01 17:09:08 (GMT)
commitfff9f6d6f74aa92d0bc4adf3a80a25b1b662458d (patch)
treecd9736d600c9a8606ed40493c33c825a1d0f3f30
parent786e2695cb68402d44357002b438c95229c4fb19 (diff)
downloadCMake-fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d.zip
CMake-fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d.tar.gz
CMake-fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d.tar.bz2
Rename flags again and use variablewatch for cli
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx8
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h1
-rw-r--r--Source/QtDialog/QCMake.cxx7
-rw-r--r--Source/QtDialog/QCMake.h2
-rw-r--r--Source/cmMakefile.cxx7
-rw-r--r--Source/cmMakefile.h1
-rw-r--r--Source/cmake.cxx43
-rw-r--r--Source/cmake.h10
-rw-r--r--Source/cmakemain.cxx6
9 files changed, 47 insertions, 38 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index a09504d..663753e 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -121,11 +121,8 @@ CMakeSetupDialog::CMakeSetupDialog()
OptionsMenu->addAction(tr("&Warn Uninitialized (--warn-uninitialized)"));
this->WarnUninitializedAction->setCheckable(true);
this->WarnUnusedAction =
- OptionsMenu->addAction(tr("&Warn Unused (--warn-unused)"));
+ OptionsMenu->addAction(tr("&Warn Unused (--warn-unused-vars)"));
this->WarnUnusedAction->setCheckable(true);
- this->WarnUnusedAllAction =
- OptionsMenu->addAction(tr("&Warn Unused All (--warn-unused-all)"));
- this->WarnUnusedAllAction->setCheckable(true);
QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
debugAction->setCheckable(true);
@@ -256,9 +253,6 @@ void CMakeSetupDialog::initialize()
QObject::connect(this->WarnUnusedAction, SIGNAL(triggered(bool)),
this->CMakeThread->cmakeInstance(),
SLOT(setWarnUnusedMode(bool)));
- QObject::connect(this->WarnUnusedAllAction, SIGNAL(triggered(bool)),
- this->CMakeThread->cmakeInstance(),
- SLOT(setWarnUnusedAllMode(bool)));
if(!this->SourceDirectory->text().isEmpty() ||
!this->BinaryDirectory->lineEdit()->text().isEmpty())
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index f937248..c4d029a 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -95,7 +95,6 @@ protected:
QAction* SuppressDevWarningsAction;
QAction* WarnUninitializedAction;
QAction* WarnUnusedAction;
- QAction* WarnUnusedAllAction;
QAction* InstallForCommandLineAction;
State CurrentState;
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 1f9fa3d..c319cb4 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -30,7 +30,6 @@ QCMake::QCMake(QObject* p)
this->SuppressDevWarnings = false;
this->WarnUninitializedMode = false;
this->WarnUnusedMode = false;
- this->WarnUnusedAllMode = false;
qRegisterMetaType<QCMakeProperty>();
qRegisterMetaType<QCMakePropertyList>();
@@ -170,7 +169,6 @@ void QCMake::configure()
std::cerr << "set warn uninitialized " << this->WarnUninitializedMode << "\n";
this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
this->CMakeInstance->SetWarnUnused(this->WarnUnusedMode);
- this->CMakeInstance->SetDefaultToUsed(!this->WarnUnusedAllMode);
this->CMakeInstance->PreLoadCMakeFiles();
cmSystemTools::ResetErrorOccuredFlag();
@@ -434,8 +432,3 @@ void QCMake::setWarnUnusedMode(bool value)
{
this->WarnUnusedMode = value;
}
-
-void QCMake::setWarnUnusedAllMode(bool value)
-{
- this->WarnUnusedAllMode = value;
-}
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index 6056a8c..0d10823 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -92,8 +92,6 @@ public slots:
void setWarnUninitializedMode(bool value);
/// set whether to run cmake with warnings about unused variables
void setWarnUnusedMode(bool value);
- /// set whether to run cmake with warnings about all unused variables
- void setWarnUnusedAllMode(bool value);
public:
/// get the list of cache properties
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 406062d..242900e 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -93,7 +93,6 @@ cmMakefile::cmMakefile(): Internal(new Internals)
this->Initialize();
this->PreOrder = false;
this->WarnUnused = false;
- this->DefaultToUsed = true;
}
cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
@@ -137,7 +136,6 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
this->Properties = mf.Properties;
this->PreOrder = mf.PreOrder;
this->WarnUnused = mf.WarnUnused;
- this->DefaultToUsed = mf.DefaultToUsed;
this->ListFileStack = mf.ListFileStack;
this->Initialize();
}
@@ -767,7 +765,6 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg)
const cmDefinitions& defs = cmDefinitions();
const std::set<cmStdString> globalKeys = defs.LocalKeys();
this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
- this->DefaultToUsed = this->GetCMakeInstance()->GetDefaultToUsed();
if (this->WarnUnused)
{
this->Internal->VarUsageStack.push(globalKeys);
@@ -1710,10 +1707,6 @@ void cmMakefile::AddDefinition(const char* name, bool value)
{
this->Internal->VarStack.top().Set(name, value? "ON" : "OFF");
this->Internal->VarInitStack.top().insert(name);
- if (this->WarnUnused && this->DefaultToUsed)
- {
- this->Internal->VarUsageStack.top().insert(name);
- }
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
if ( vv )
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 7141747..4ce3b9b 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -935,7 +935,6 @@ private:
// Unused variable flags
bool WarnUnused;
- bool DefaultToUsed;
// stack of list files being read
std::deque<cmStdString> ListFileStack;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index cd9d10d..93ca9e3 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -137,12 +137,19 @@ void cmNeedBackwardsCompatibility(const std::string& variable,
#endif
}
+void cmWarnUnusedCliWarning(const std::string& variable,
+ int, void* ctx, const char*, const cmMakefile*)
+{
+ cmake* cm = reinterpret_cast<cmake*>(ctx);
+ cm->MarkCliAsUsed(variable);
+}
+
cmake::cmake()
{
this->Trace = false;
this->WarnUninitialized = false;
this->WarnUnused = false;
- this->DefaultToUsed = true;
+ this->WarnUnusedCli = true;
this->SuppressDevWarnings = false;
this->DoSuppressDevWarnings = false;
this->DebugOutput = false;
@@ -193,6 +200,19 @@ cmake::cmake()
cmake::~cmake()
{
+ if(this->WarnUnusedCli)
+ {
+ std::map<std::string, bool>::const_iterator it;
+ for(it = this->UsedCliVariables.begin(); it != this->UsedCliVariables.end(); ++it)
+ {
+ if(!it->second)
+ {
+ std::string message = "The variable, \"" + it->first + "\", given "
+ "on the command line was not used within the build.";
+ cmSystemTools::Message(message.c_str());
+ }
+ }
+ }
delete this->CacheManager;
delete this->Policies;
if (this->GlobalGenerator)
@@ -370,6 +390,11 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
{
this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
"No help, variable specified on the command line.", type);
+ if(this->WarnUnusedCli)
+ {
+ this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
+ this->UsedCliVariables[var] = false;
+ }
}
else
{
@@ -621,16 +646,15 @@ void cmake::SetArgs(const std::vector<std::string>& args)
std::cout << "Warn about uninitialized values.\n";
this->SetWarnUninitialized(true);
}
- else if(arg.find("--warn-unused",0) == 0)
+ else if(arg.find("--warn-unused-vars",0) == 0)
{
- std::cout << "Finding unused command line variables.\n";
+ std::cout << "Finding unused variables.\n";
this->SetWarnUnused(true);
}
- else if(arg.find("--warn-unused-all",0) == 0)
+ else if(arg.find("--warn-unused-cli",0) == 0)
{
- std::cout << "Finding unused variables.\n";
- this->SetWarnUnused(true);
- this->SetDefaultToUsed(false);
+ std::cout << "Finding unused variables given on the command line.\n";
+ this->SetWarnUnusedCli(true);
}
else if(arg.find("-G",0) == 0)
{
@@ -2836,6 +2860,11 @@ const char* cmake::GetCPackCommand()
return this->CPackCommand.c_str();
}
+void cmake::MarkCliAsUsed(const std::string& variable)
+{
+ this->UsedCliVariables[variable] = true;
+}
+
void cmake::GenerateGraphViz(const char* fileName) const
{
cmGeneratedFileStream str(fileName);
diff --git a/Source/cmake.h b/Source/cmake.h
index 7304d94..7f7546a 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -310,8 +310,11 @@ class cmake
void SetWarnUninitialized(bool b) { this->WarnUninitialized = b;}
bool GetWarnUnused() { return this->WarnUnused;}
void SetWarnUnused(bool b) { this->WarnUnused = b;}
- bool GetDefaultToUsed() { return this->DefaultToUsed;}
- void SetDefaultToUsed(bool b) { this->DefaultToUsed = b;}
+ bool GetWarnUnusedCli() { return this->WarnUnusedCli;}
+ void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b;}
+
+ void MarkCliAsUsed(const std::string& variable);
+
// Define a property
void DefineProperty(const char *name, cmProperty::ScopeType scope,
const char *ShortDescription,
@@ -451,7 +454,8 @@ private:
bool Trace;
bool WarnUninitialized;
bool WarnUnused;
- bool DefaultToUsed;
+ bool WarnUnusedCli;
+ std::map<std::string, bool> UsedCliVariables;
std::string CMakeEditCommand;
std::string CMakeCommand;
std::string CXXEnvironment;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 8d4c334..cb3fcb0 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -122,10 +122,10 @@ static const char * cmDocumentationOptions[][3] =
"message(send_error ) calls."},
{"--warn-uninitialized", "Warn about uninitialized values.",
"Print a warning when an uninitialized variable is used."},
- {"--warn-unused", "Warn about unused variables.",
+ {"--warn-unused-all", "Warn about unused variables.",
+ "Find variables that are declared or set, but not used."},
+ {"--warn-unused-cli", "Warn about command line options.",
"Find variables that are declared on the command line, but not used."},
- {"--warn-unused-all", "Warn about 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 "