[Cmake-commits] CMake branch, next, updated. v2.8.2-647-g5191d66

Ben Boeckel ben.boeckel at kitware.com
Wed Sep 1 13:10:46 EDT 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  5191d66ba7adf57257435dc437338c5d3fc45145 (commit)
       via  2e78224509d6d0bbb7fdf28841f40a6b41c565b3 (commit)
       via  74997000c89ee3a82d68e4107d4a4264e7e57229 (commit)
       via  fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d (commit)
       via  786e2695cb68402d44357002b438c95229c4fb19 (commit)
       via  636e6c4ef7e79113802714dbc7ade77d4f04e809 (commit)
       via  4ff03402fc137bf5624d4a71c1ad3b177e5ceb53 (commit)
       via  d7999e9b294f93f68b5ec9e3efd8017fad3f05d9 (commit)
       via  e141bc950a1970c6bc96fa5f55fd60c6aedbb2d0 (commit)
       via  d3e8eb504137dde90a73f1b46f97f889af46db18 (commit)
       via  f332e14ff2035e33bced0915373296a1f4cf0876 (commit)
       via  52f9637174242752721dfb322908adb40c8244c2 (commit)
       via  f794d589a44918c905911eb7688d69350922c6b3 (commit)
       via  48b5b855934be341c02139c0bed88c35c1b40d8f (commit)
       via  cd626ea66ed114736ddf5d6a4c989ef6c9b8d248 (commit)
      from  e42618b86d809c459b1f7c7161e143f422a298a5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5191d66ba7adf57257435dc437338c5d3fc45145
commit 5191d66ba7adf57257435dc437338c5d3fc45145
Merge: e42618b 2e78224
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Sep 1 13:10:42 2010 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Sep 1 13:10:42 2010 -0400

    Merge topic 'dev/strict-mode' into next
    
    2e78224 Add a missing comma to the warning message
    7499700 Add a flag to warn about system files
    fff9f6d Rename flags again and use variablewatch for cli
    786e269 Add warn-unused to the Qt interface
    636e6c4 Default to marking things as used
    4ff0340 Rename find-unused to warn-unused
    d7999e9 Rename strict-mode to warn-uninitialized
    e141bc9 Detect unused variables
    d3e8eb5 Add flags to detect unused variables
    f332e14 Complete strict-mode checks for uninitialized vars
    52f9637 Add method to get the local scope variables
    f794d58 Make --strict-mode option, and integrate with cmake-gui
    48b5b85 Add a warning when variables are used uninitialized.
    cd626ea For macros make sure the FilePath points to a valid pointer in the args.


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2e78224509d6d0bbb7fdf28841f40a6b41c565b3
commit 2e78224509d6d0bbb7fdf28841f40a6b41c565b3
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Sep 1 11:26:58 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:09:08 2010 -0400

    Add a missing comma to the warning message

diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 27bfbee..d4cabdb 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -208,8 +208,8 @@ cmake::~cmake()
       {
       if(!it->second)
         {
-        std::string message = "The variable, \"" + it->first + "\", given "
-          "on the command line was not used within the build.";
+        std::string message = "warning: The variable, \"" + it->first + "\", given "
+          "on the command line, was not used within the build.";
         cmSystemTools::Message(message.c_str());
         }
       }

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=74997000c89ee3a82d68e4107d4a4264e7e57229
commit 74997000c89ee3a82d68e4107d4a4264e7e57229
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Sep 1 11:24:20 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:09:08 2010 -0400

    Add a flag to warn about system files

diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 1460e5d..e9381d4 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -21,6 +21,7 @@ int cmCommandArgument_yyparse( yyscan_t yyscanner );
 cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
 {
   this->WarnUninitialized = false;
+  this->CheckSystemVars = false;
   this->FileLine = -1;
   this->FileName = 0;
   this->RemoveEmpty = true;
@@ -129,10 +130,14 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
     // not been "cleared"/initialized with a set(foo ) call
     if(this->WarnUninitialized && !this->Makefile->VariableInitialized(var))
       {
-      cmOStringStream msg;
-      msg << this->FileName << ":" << this->FileLine << ":" <<
-        " warning: uninitialized variable \'" << var << "\'";
-      cmSystemTools::Message(msg.str().c_str());
+      const char* root = this->Makefile->GetDefinition("CMAKE_ROOT");
+      if (this->CheckSystemVars || strstr(this->FileName, root) != this->FileName)
+        {
+        cmOStringStream msg;
+        msg << this->FileName << ":" << this->FileLine << ":" <<
+          " warning: uninitialized variable \'" << var << "\'";
+        cmSystemTools::Message(msg.str().c_str());
+        }
       }
     return 0;
     }
@@ -331,6 +336,7 @@ 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)
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index 1df0042..a211e95 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -97,6 +97,7 @@ private:
   std::string Result;
   const char* FileName;
   bool WarnUninitialized;
+  bool CheckSystemVars;
   long FileLine;
   bool EscapeQuotes;
   std::string ErrorString;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 242900e..3a23590 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -93,6 +93,7 @@ cmMakefile::cmMakefile(): Internal(new Internals)
   this->Initialize();
   this->PreOrder = false;
   this->WarnUnused = false;
+  this->CheckSystemVars = false;
 }
 
 cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
@@ -136,6 +137,7 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
   this->Properties = mf.Properties;
   this->PreOrder = mf.PreOrder;
   this->WarnUnused = mf.WarnUnused;
+  this->CheckSystemVars = mf.CheckSystemVars;
   this->ListFileStack = mf.ListFileStack;
   this->Initialize();
 }
@@ -774,6 +776,7 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg)
       this->Internal->VarUsageStack.push(std::set<cmStdString>());
       }
     }
+    this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
 }
 
 bool cmMakefile::NeedBackwardsCompatibility(unsigned int major,
@@ -3386,9 +3389,14 @@ void cmMakefile::PopScope()
     init.erase(*it);
     if (this->WarnUnused && usage.find(*it) == usage.end())
       {
-      cmOStringStream m;
-      m << "unused variable \'" << *it << "\'";
-      this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
+      const char* cdir = this->ListFileStack.back().c_str();
+      const char* root = this->GetDefinition("CMAKE_ROOT");
+      if (this->CheckSystemVars || strstr(cdir, root) != cdir)
+        {
+        cmOStringStream m;
+        m << "unused variable \'" << *it << "\'";
+        this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
+        }
       }
     else
       {
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 4ce3b9b..f1ad54d 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -935,6 +935,7 @@ private:
 
   // Unused variable flags
   bool WarnUnused;
+  bool CheckSystemVars;
 
   // stack of list files being read 
   std::deque<cmStdString> ListFileStack;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 93ca9e3..27bfbee 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -150,6 +150,7 @@ cmake::cmake()
   this->WarnUninitialized = false;
   this->WarnUnused = false;
   this->WarnUnusedCli = true;
+  this->CheckSystemVars = false;
   this->SuppressDevWarnings = false;
   this->DoSuppressDevWarnings = false;
   this->DebugOutput = false;
@@ -656,6 +657,11 @@ void cmake::SetArgs(const std::vector<std::string>& args)
       std::cout << "Finding unused variables given on the command line.\n";
       this->SetWarnUnusedCli(true);
       }
+    else if(arg.find("--check-system-vars",0) == 0)
+      {
+      std::cout << "Also check system files when warning about unused and uninitialized variables.\n";
+      this->SetCheckSystemVars(true);
+      }
     else if(arg.find("-G",0) == 0)
       {
       std::string value = arg.substr(2);
diff --git a/Source/cmake.h b/Source/cmake.h
index 7f7546a..403809f 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -312,6 +312,8 @@ class cmake
   void SetWarnUnused(bool b) {  this->WarnUnused = b;}
   bool GetWarnUnusedCli() { return this->WarnUnusedCli;}
   void SetWarnUnusedCli(bool b) {  this->WarnUnusedCli = b;}
+  bool GetCheckSystemVars() { return this->CheckSystemVars;}
+  void SetCheckSystemVars(bool b) {  this->CheckSystemVars = b;}
 
   void MarkCliAsUsed(const std::string& variable);
 
@@ -455,6 +457,7 @@ private:
   bool WarnUninitialized;
   bool WarnUnused;
   bool WarnUnusedCli;
+  bool CheckSystemVars;
   std::map<std::string, bool> UsedCliVariables;
   std::string CMakeEditCommand;
   std::string CMakeCommand;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d
commit fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Sep 1 10:22:08 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:09:08 2010 -0400

    Rename flags again and use variablewatch for cli

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 "

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=786e2695cb68402d44357002b438c95229c4fb19
commit 786e2695cb68402d44357002b438c95229c4fb19
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Aug 25 12:43:02 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:15 2010 -0400

    Add warn-unused to the Qt interface

diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index a5510af..a09504d 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -120,6 +120,12 @@ CMakeSetupDialog::CMakeSetupDialog()
   this->WarnUninitializedAction =
     OptionsMenu->addAction(tr("&Warn Uninitialized (--warn-uninitialized)"));
   this->WarnUninitializedAction->setCheckable(true);
+  this->WarnUnusedAction =
+    OptionsMenu->addAction(tr("&Warn Unused (--warn-unused)"));
+  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);
@@ -247,6 +253,12 @@ void CMakeSetupDialog::initialize()
   QObject::connect(this->WarnUninitializedAction, SIGNAL(triggered(bool)),
                    this->CMakeThread->cmakeInstance(),
                    SLOT(setWarnUninitializedMode(bool)));
+  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 4c161d9..f937248 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -94,6 +94,8 @@ protected:
   QAction* GenerateAction;
   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 8d24c1c..1f9fa3d 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -29,6 +29,8 @@ QCMake::QCMake(QObject* p)
 {
   this->SuppressDevWarnings = false;
   this->WarnUninitializedMode = false;
+  this->WarnUnusedMode = false;
+  this->WarnUnusedAllMode = false;
   qRegisterMetaType<QCMakeProperty>();
   qRegisterMetaType<QCMakePropertyList>();
   
@@ -167,6 +169,8 @@ void QCMake::configure()
   this->CMakeInstance->SetSuppressDevWarnings(this->SuppressDevWarnings);
   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();
@@ -425,3 +429,13 @@ void QCMake::setWarnUninitializedMode(bool value)
 {
   this->WarnUninitializedMode = value;
 }
+
+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 6d2b2ff..6056a8c 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -90,6 +90,10 @@ public slots:
   void setSuppressDevWarnings(bool value);
   /// set whether to run cmake with warnings about uninitialized variables
   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
@@ -136,6 +140,8 @@ protected:
                             bool&, void* cd);
   bool SuppressDevWarnings;
   bool WarnUninitializedMode;
+  bool WarnUnusedMode;
+  bool WarnUnusedAllMode;
   QString SourceDirectory;
   QString BinaryDirectory;
   QString Generator;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=636e6c4ef7e79113802714dbc7ade77d4f04e809
commit 636e6c4ef7e79113802714dbc7ade77d4f04e809
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Aug 25 12:42:03 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:15 2010 -0400

    Default to marking things as used
    
    If we don't then:
    
        cmake --warn-unused --warn-unused-all
    
    acts differently than:
    
        cmake --warn-unused-all --warn-unused

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 214c8be..406062d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -93,7 +93,7 @@ cmMakefile::cmMakefile(): Internal(new Internals)
   this->Initialize();
   this->PreOrder = false;
   this->WarnUnused = false;
-  this->DefaultToUsed = false;
+  this->DefaultToUsed = true;
 }
 
 cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index e68f58d..cd9d10d 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -142,7 +142,7 @@ cmake::cmake()
   this->Trace = false;
   this->WarnUninitialized = false;
   this->WarnUnused = false;
-  this->DefaultToUsed = false;
+  this->DefaultToUsed = true;
   this->SuppressDevWarnings = false;
   this->DoSuppressDevWarnings = false;
   this->DebugOutput = false;
@@ -625,7 +625,6 @@ void cmake::SetArgs(const std::vector<std::string>& args)
       {
       std::cout << "Finding unused command line variables.\n";
       this->SetWarnUnused(true);
-      this->SetDefaultToUsed(true);
       }
     else if(arg.find("--warn-unused-all",0) == 0)
       {

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ff03402fc137bf5624d4a71c1ad3b177e5ceb53
commit 4ff03402fc137bf5624d4a71c1ad3b177e5ceb53
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Aug 25 12:36:21 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:14 2010 -0400

    Rename find-unused to warn-unused

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index e4973cb..214c8be 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -92,7 +92,7 @@ cmMakefile::cmMakefile(): Internal(new Internals)
   this->AddDefaultDefinitions();
   this->Initialize();
   this->PreOrder = false;
-  this->FindUnused = false;
+  this->WarnUnused = false;
   this->DefaultToUsed = false;
 }
 
@@ -136,7 +136,7 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
   this->SubDirectoryOrder = mf.SubDirectoryOrder;
   this->Properties = mf.Properties;
   this->PreOrder = mf.PreOrder;
-  this->FindUnused = mf.FindUnused;
+  this->WarnUnused = mf.WarnUnused;
   this->DefaultToUsed = mf.DefaultToUsed;
   this->ListFileStack = mf.ListFileStack;
   this->Initialize();
@@ -766,9 +766,9 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg)
     {
     const cmDefinitions& defs = cmDefinitions();
     const std::set<cmStdString> globalKeys = defs.LocalKeys();
-    this->FindUnused = this->GetCMakeInstance()->GetFindUnused();
+    this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
     this->DefaultToUsed = this->GetCMakeInstance()->GetDefaultToUsed();
-    if (this->FindUnused)
+    if (this->WarnUnused)
       {
       this->Internal->VarUsageStack.push(globalKeys);
       }
@@ -1710,7 +1710,7 @@ 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->FindUnused && this->DefaultToUsed)
+  if (this->WarnUnused && this->DefaultToUsed)
     {
     this->Internal->VarUsageStack.top().insert(name);
     }
@@ -1756,7 +1756,7 @@ void cmMakefile::RemoveDefinition(const char* name)
   this->Internal->VarStack.top().Set(name, 0);
   this->Internal->VarRemoved.insert(name);
   this->Internal->VarInitStack.top().insert(name);
-  if (this->FindUnused)
+  if (this->WarnUnused)
     {
     this->Internal->VarUsageStack.top().insert(name);
     }
@@ -2138,7 +2138,7 @@ const char* cmMakefile::GetDefinition(const char* name) const
       RecordPropertyAccess(name,cmProperty::VARIABLE);
     }
 #endif
-  if (this->FindUnused)
+  if (this->WarnUnused)
     {
     this->Internal->VarUsageStack.top().insert(name);
     }
@@ -3391,7 +3391,7 @@ void cmMakefile::PopScope()
   for (; it != locals.end(); ++it)
     {
     init.erase(*it);
-    if (this->FindUnused && usage.find(*it) == usage.end())
+    if (this->WarnUnused && usage.find(*it) == usage.end())
       {
       cmOStringStream m;
       m << "unused variable \'" << *it << "\'";
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 184253a..7141747 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -934,7 +934,7 @@ private:
   bool PreOrder;
 
   // Unused variable flags
-  bool FindUnused;
+  bool WarnUnused;
   bool DefaultToUsed;
 
   // stack of list files being read 
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index f68ab3e..e68f58d 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -141,7 +141,7 @@ cmake::cmake()
 {
   this->Trace = false;
   this->WarnUninitialized = false;
-  this->FindUnused = false;
+  this->WarnUnused = false;
   this->DefaultToUsed = false;
   this->SuppressDevWarnings = false;
   this->DoSuppressDevWarnings = false;
@@ -621,16 +621,16 @@ void cmake::SetArgs(const std::vector<std::string>& args)
       std::cout << "Warn about uninitialized values.\n";
       this->SetWarnUninitialized(true);
       }
-    else if(arg.find("--find-unused",0) == 0)
+    else if(arg.find("--warn-unused",0) == 0)
       {
       std::cout << "Finding unused command line variables.\n";
-      this->SetFindUnused(true);
+      this->SetWarnUnused(true);
       this->SetDefaultToUsed(true);
       }
-    else if(arg.find("--find-unused-all",0) == 0)
+    else if(arg.find("--warn-unused-all",0) == 0)
       {
       std::cout << "Finding unused variables.\n";
-      this->SetFindUnused(true);
+      this->SetWarnUnused(true);
       this->SetDefaultToUsed(false);
       }
     else if(arg.find("-G",0) == 0)
diff --git a/Source/cmake.h b/Source/cmake.h
index 3a53d48..7304d94 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -308,8 +308,8 @@ class cmake
   void SetTrace(bool b) {  this->Trace = b;}
   bool GetWarnUninitialized() { return this->WarnUninitialized;}
   void SetWarnUninitialized(bool b) {  this->WarnUninitialized = b;}
-  bool GetFindUnused() { return this->FindUnused;}
-  void SetFindUnused(bool b) {  this->FindUnused = 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;}
   // Define a property
@@ -450,7 +450,7 @@ private:
   bool DebugOutput;
   bool Trace;
   bool WarnUninitialized;
-  bool FindUnused;
+  bool WarnUnused;
   bool DefaultToUsed;
   std::string CMakeEditCommand;
   std::string CMakeCommand;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index af92200..8d4c334 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -122,9 +122,9 @@ static const char * cmDocumentationOptions[][3] =
    "message(send_error ) calls."},
   {"--warn-uninitialized", "Warn about uninitialized values.",
    "Print a warning when an uninitialized variable is used."},
-  {"--find-unused", "Find unused variables.",
+  {"--warn-unused", "Warn about unused variables.",
    "Find variables that are declared on the command line, but not used."},
-  {"--find-unused-all", "Find all unused variables.",
+  {"--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. "

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d7999e9b294f93f68b5ec9e3efd8017fad3f05d9
commit d7999e9b294f93f68b5ec9e3efd8017fad3f05d9
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Aug 25 12:35:40 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:14 2010 -0400

    Rename strict-mode to warn-uninitialized

diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 7600897..a5510af 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -117,9 +117,9 @@ CMakeSetupDialog::CMakeSetupDialog()
   this->SuppressDevWarningsAction =
     OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)"));
   this->SuppressDevWarningsAction->setCheckable(true);
-  this->StrictModeAction =
-    OptionsMenu->addAction(tr("&Strict Mode (--strict-mode)"));
-  this->StrictModeAction->setCheckable(true);
+  this->WarnUninitializedAction =
+    OptionsMenu->addAction(tr("&Warn Uninitialized (--warn-uninitialized)"));
+  this->WarnUninitializedAction->setCheckable(true);
 
   QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
   debugAction->setCheckable(true);
@@ -244,9 +244,9 @@ void CMakeSetupDialog::initialize()
 
   QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)), 
                    this->CMakeThread->cmakeInstance(), SLOT(setSuppressDevWarnings(bool)));
-  QObject::connect(this->StrictModeAction, SIGNAL(triggered(bool)),
+  QObject::connect(this->WarnUninitializedAction, SIGNAL(triggered(bool)),
                    this->CMakeThread->cmakeInstance(),
-                   SLOT(setStrictMode(bool)));
+                   SLOT(setWarnUninitializedMode(bool)));
   
   if(!this->SourceDirectory->text().isEmpty() ||
      !this->BinaryDirectory->lineEdit()->text().isEmpty())
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index cd2be6e..4c161d9 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -93,7 +93,7 @@ protected:
   QAction* ConfigureAction;
   QAction* GenerateAction;
   QAction* SuppressDevWarningsAction;
-  QAction* StrictModeAction;
+  QAction* WarnUninitializedAction;
   QAction* InstallForCommandLineAction;
   State CurrentState;
 
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 31daf3c..8d24c1c 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -28,7 +28,7 @@ QCMake::QCMake(QObject* p)
   : QObject(p)
 {
   this->SuppressDevWarnings = false;
-  this->StrictMode = false;
+  this->WarnUninitializedMode = false;
   qRegisterMetaType<QCMakeProperty>();
   qRegisterMetaType<QCMakePropertyList>();
   
@@ -165,8 +165,8 @@ void QCMake::configure()
     this->CMakeInstance->CreateGlobalGenerator(this->Generator.toAscii().data()));
   this->CMakeInstance->LoadCache();
   this->CMakeInstance->SetSuppressDevWarnings(this->SuppressDevWarnings);
-  std::cerr << "set strict " << this->StrictMode << "\n";
-  this->CMakeInstance->SetStrictMode(this->StrictMode);
+  std::cerr << "set warn uninitialized " << this->WarnUninitializedMode << "\n";
+  this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
   this->CMakeInstance->PreLoadCMakeFiles();
 
   cmSystemTools::ResetErrorOccuredFlag();
@@ -421,7 +421,7 @@ void QCMake::setSuppressDevWarnings(bool value)
   this->SuppressDevWarnings = value;
 }
 
-void QCMake::setStrictMode(bool value)
+void QCMake::setWarnUninitializedMode(bool value)
 {
-  this->StrictMode = value;
+  this->WarnUninitializedMode = value;
 }
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index f20893f..6d2b2ff 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -88,8 +88,8 @@ public slots:
   void setDebugOutput(bool);
   /// set whether to do suppress dev warnings
   void setSuppressDevWarnings(bool value);
-  /// set whether to run cmake in strict mode
-  void setStrictMode(bool value);
+  /// set whether to run cmake with warnings about uninitialized variables
+  void setWarnUninitializedMode(bool value);
 
 public:
   /// get the list of cache properties
@@ -135,7 +135,7 @@ protected:
   static void errorCallback(const char* msg, const char* title, 
                             bool&, void* cd);
   bool SuppressDevWarnings;
-  bool StrictMode;
+  bool WarnUninitializedMode;
   QString SourceDirectory;
   QString BinaryDirectory;
   QString Generator;
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index d955ff7..1460e5d 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -20,7 +20,7 @@ int cmCommandArgument_yyparse( yyscan_t yyscanner );
 //
 cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
 {
-  this->StrictMode = false;
+  this->WarnUninitialized = false;
   this->FileLine = -1;
   this->FileName = 0;
   this->RemoveEmpty = true;
@@ -127,7 +127,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
     // 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->StrictMode && !this->Makefile->VariableInitialized(var))
+    if(this->WarnUninitialized && !this->Makefile->VariableInitialized(var))
       {
       cmOStringStream msg;
       msg << this->FileName << ":" << this->FileLine << ":" <<
@@ -330,7 +330,7 @@ void cmCommandArgumentParserHelper::Error(const char* str)
 void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
 {
   this->Makefile = mf;
-  this->StrictMode = mf->GetCMakeInstance()->GetStrictMode();
+  this->WarnUninitialized = mf->GetCMakeInstance()->GetWarnUninitialized();
 }
 
 void cmCommandArgumentParserHelper::SetResult(const char* value)
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index d7206ee..1df0042 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -96,7 +96,7 @@ private:
   const cmMakefile* Makefile;
   std::string Result;
   const char* FileName;
-  bool StrictMode;
+  bool WarnUninitialized;
   long FileLine;
   bool EscapeQuotes;
   std::string ErrorString;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 41f2775..f68ab3e 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -140,7 +140,7 @@ void cmNeedBackwardsCompatibility(const std::string& variable,
 cmake::cmake()
 {
   this->Trace = false;
-  this->StrictMode = false;
+  this->WarnUninitialized = false;
   this->FindUnused = false;
   this->DefaultToUsed = false;
   this->SuppressDevWarnings = false;
@@ -616,10 +616,10 @@ void cmake::SetArgs(const std::vector<std::string>& args)
       std::cout << "Running with trace output on.\n";
       this->SetTrace(true);
       }
-    else if(arg.find("--strict-mode",0) == 0)
+    else if(arg.find("--warn-uninitialized",0) == 0)
       {
-      std::cout << "Running in strict mode.\n";
-      this->SetStrictMode(true);
+      std::cout << "Warn about uninitialized values.\n";
+      this->SetWarnUninitialized(true);
       }
     else if(arg.find("--find-unused",0) == 0)
       {
diff --git a/Source/cmake.h b/Source/cmake.h
index 7b612ea..3a53d48 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -306,8 +306,8 @@ class cmake
   // Do we want trace output during the cmake run.
   bool GetTrace() { return this->Trace;}
   void SetTrace(bool b) {  this->Trace = b;}
-  bool GetStrictMode() { return this->StrictMode;}
-  void SetStrictMode(bool b) {  this->StrictMode = b;}
+  bool GetWarnUninitialized() { return this->WarnUninitialized;}
+  void SetWarnUninitialized(bool b) {  this->WarnUninitialized = b;}
   bool GetFindUnused() { return this->FindUnused;}
   void SetFindUnused(bool b) {  this->FindUnused = b;}
   bool GetDefaultToUsed() { return this->DefaultToUsed;}
@@ -449,7 +449,7 @@ private:
   bool ScriptMode;
   bool DebugOutput;
   bool Trace;
-  bool StrictMode;
+  bool WarnUninitialized;
   bool FindUnused;
   bool DefaultToUsed;
   std::string CMakeEditCommand;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 235aaf5..af92200 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -120,9 +120,8 @@ static const char * cmDocumentationOptions[][3] =
   {"--trace", "Put cmake in trace mode.",
    "Print a trace of all calls made and from where with "
    "message(send_error ) calls."},
-  {"--strict-mode", "Put cmake in strict mode.",
-   "In strict mode cmake will print a warning when an uninitialized variable "
-   "is used."},
+  {"--warn-uninitialized", "Warn about uninitialized values.",
+   "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.",

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e141bc950a1970c6bc96fa5f55fd60c6aedbb2d0
commit e141bc950a1970c6bc96fa5f55fd60c6aedbb2d0
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Aug 24 16:50:15 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:14 2010 -0400

    Detect unused variables

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index d89168d..e4973cb 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -44,6 +44,7 @@ class cmMakefile::Internals
 public:
   std::stack<cmDefinitions, std::list<cmDefinitions> > VarStack;
   std::stack<std::set<cmStdString> > VarInitStack;
+  std::stack<std::set<cmStdString> > VarUsageStack;
   std::set<cmStdString> VarRemoved;
 };
 
@@ -91,6 +92,8 @@ cmMakefile::cmMakefile(): Internal(new Internals)
   this->AddDefaultDefinitions();
   this->Initialize();
   this->PreOrder = false;
+  this->FindUnused = false;
+  this->DefaultToUsed = false;
 }
 
 cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
@@ -133,6 +136,8 @@ cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals)
   this->SubDirectoryOrder = mf.SubDirectoryOrder;
   this->Properties = mf.Properties;
   this->PreOrder = mf.PreOrder;
+  this->FindUnused = mf.FindUnused;
+  this->DefaultToUsed = mf.DefaultToUsed;
   this->ListFileStack = mf.ListFileStack;
   this->Initialize();
 }
@@ -757,6 +762,21 @@ void cmMakefile::SetLocalGenerator(cmLocalGenerator* lg)
   this->AddSourceGroup("Resources", "\\.plist$");
 #endif
 
+  if (this->Internal->VarUsageStack.empty())
+    {
+    const cmDefinitions& defs = cmDefinitions();
+    const std::set<cmStdString> globalKeys = defs.LocalKeys();
+    this->FindUnused = this->GetCMakeInstance()->GetFindUnused();
+    this->DefaultToUsed = this->GetCMakeInstance()->GetDefaultToUsed();
+    if (this->FindUnused)
+      {
+      this->Internal->VarUsageStack.push(globalKeys);
+      }
+    else
+      {
+      this->Internal->VarUsageStack.push(std::set<cmStdString>());
+      }
+    }
 }
 
 bool cmMakefile::NeedBackwardsCompatibility(unsigned int major,
@@ -1690,6 +1710,10 @@ 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->FindUnused && this->DefaultToUsed)
+    {
+    this->Internal->VarUsageStack.top().insert(name);
+    }
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
   if ( vv )
@@ -1709,6 +1733,15 @@ bool cmMakefile::VariableInitialized(const char* var) const
   return false;
 }
 
+bool cmMakefile::VariableUsed(const char* var) const
+{
+  if(this->Internal->VarUsageStack.top().find(var) != this->Internal->VarUsageStack.top().end())
+    {
+    return true;
+    }
+  return false;
+}
+
 bool cmMakefile::VariableCleared(const char* var) const
 {
   if(this->Internal->VarRemoved.find(var) != this->Internal->VarRemoved.end())
@@ -1723,6 +1756,10 @@ void cmMakefile::RemoveDefinition(const char* name)
   this->Internal->VarStack.top().Set(name, 0);
   this->Internal->VarRemoved.insert(name);
   this->Internal->VarInitStack.top().insert(name);
+  if (this->FindUnused)
+    {
+    this->Internal->VarUsageStack.top().insert(name);
+    }
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
   if ( vv )
@@ -2101,6 +2138,10 @@ const char* cmMakefile::GetDefinition(const char* name) const
       RecordPropertyAccess(name,cmProperty::VARIABLE);
     }
 #endif
+  if (this->FindUnused)
+    {
+    this->Internal->VarUsageStack.top().insert(name);
+    }
   const char* def = this->Internal->VarStack.top().Get(name);
   if(!def)
     {
@@ -3332,29 +3373,49 @@ void cmMakefile::PushScope()
 {
   cmDefinitions* parent = &this->Internal->VarStack.top();
   const std::set<cmStdString>& init = this->Internal->VarInitStack.top();
+  const std::set<cmStdString>& usage = this->Internal->VarUsageStack.top();
   this->Internal->VarStack.push(cmDefinitions(parent));
   this->Internal->VarInitStack.push(init);
+  this->Internal->VarUsageStack.push(usage);
 }
 
 void cmMakefile::PopScope()
 {
   cmDefinitions* current = &this->Internal->VarStack.top();
   std::set<cmStdString> init = this->Internal->VarInitStack.top();
+  std::set<cmStdString> usage = this->Internal->VarUsageStack.top();
   const std::set<cmStdString>& locals = current->LocalKeys();
-  // Remove initialization information for variables in the local scope.
+  // Remove initialization and usage information for variables in the local
+  // scope.
   std::set<cmStdString>::const_iterator it = locals.begin();
   for (; it != locals.end(); ++it)
     {
     init.erase(*it);
+    if (this->FindUnused && usage.find(*it) == usage.end())
+      {
+      cmOStringStream m;
+      m << "unused variable \'" << *it << "\'";
+      this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
+      }
+    else
+      {
+      usage.erase(*it);
+      }
     }
   this->Internal->VarStack.pop();
   this->Internal->VarInitStack.pop();
-  // Push initialization up to the parent scope.
+  this->Internal->VarUsageStack.pop();
+  // Push initialization and usage up to the parent scope.
   it = init.begin();
   for (; it != init.end(); ++it)
     {
     this->Internal->VarInitStack.top().insert(*it);
     }
+  it = usage.begin();
+  for (; it != usage.end(); ++it)
+    {
+    this->Internal->VarUsageStack.top().insert(*it);
+    }
 }
 
 void cmMakefile::RaiseScope(const char *var, const char *varDef)
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index cec2738..184253a 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -63,6 +63,8 @@ public:
 
   /* return true if a variable has been initialized */
   bool VariableInitialized(const char* ) const;
+  /* return true if a variable has been used */
+  bool VariableUsed(const char* ) const;
   /* return true if a variable has been set with
      set(foo )
   */
@@ -931,6 +933,10 @@ private:
   // should this makefile be processed before or after processing the parent
   bool PreOrder;
 
+  // Unused variable flags
+  bool FindUnused;
+  bool DefaultToUsed;
+
   // stack of list files being read 
   std::deque<cmStdString> ListFileStack;
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d3e8eb504137dde90a73f1b46f97f889af46db18
commit d3e8eb504137dde90a73f1b46f97f889af46db18
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Aug 24 16:49:49 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:14 2010 -0400

    Add flags to detect unused variables

diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 2e77748..41f2775 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -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);
diff --git a/Source/cmake.h b/Source/cmake.h
index 5c2f17a..7b612ea 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -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;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index ac2a338..235aaf5 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -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 "

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f332e14ff2035e33bced0915373296a1f4cf0876
commit f332e14ff2035e33bced0915373296a1f4cf0876
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Aug 24 14:38:06 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:14 2010 -0400

    Complete strict-mode checks for uninitialized vars

diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 410058f..d955ff7 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -127,7 +127,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
     // 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->StrictMode && !this->Makefile->VariableCleared(var))
+    if(this->StrictMode && !this->Makefile->VariableInitialized(var))
       {
       cmOStringStream msg;
       msg << this->FileName << ":" << this->FileLine << ":" <<
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c56641c..d89168d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -43,13 +43,17 @@ class cmMakefile::Internals
 {
 public:
   std::stack<cmDefinitions, std::list<cmDefinitions> > VarStack;
+  std::stack<std::set<cmStdString> > VarInitStack;
   std::set<cmStdString> VarRemoved;
 };
 
 // default is not to be building executables
 cmMakefile::cmMakefile(): Internal(new Internals)
 {
-  this->Internal->VarStack.push(cmDefinitions());
+  const cmDefinitions& defs = cmDefinitions();
+  const std::set<cmStdString> globalKeys = defs.LocalKeys();
+  this->Internal->VarStack.push(defs);
+  this->Internal->VarInitStack.push(globalKeys);
 
   // Setup the default include file regular expression (match everything).
   this->IncludeFileRegularExpression = "^.*$";
@@ -1685,6 +1689,7 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value,
 void cmMakefile::AddDefinition(const char* name, bool value)
 {
   this->Internal->VarStack.top().Set(name, value? "ON" : "OFF");
+  this->Internal->VarInitStack.top().insert(name);
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
   if ( vv )
@@ -1695,6 +1700,15 @@ void cmMakefile::AddDefinition(const char* name, bool value)
 #endif
 }
 
+bool cmMakefile::VariableInitialized(const char* var) const
+{
+  if(this->Internal->VarInitStack.top().find(var) != this->Internal->VarInitStack.top().end())
+    {
+    return true;
+    }
+  return false;
+}
+
 bool cmMakefile::VariableCleared(const char* var) const
 {
   if(this->Internal->VarRemoved.find(var) != this->Internal->VarRemoved.end())
@@ -1708,6 +1722,7 @@ void cmMakefile::RemoveDefinition(const char* name)
 {
   this->Internal->VarStack.top().Set(name, 0);
   this->Internal->VarRemoved.insert(name);
+  this->Internal->VarInitStack.top().insert(name);
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
   if ( vv )
@@ -3316,12 +3331,30 @@ std::string cmMakefile::GetListFileStack()
 void cmMakefile::PushScope()
 {
   cmDefinitions* parent = &this->Internal->VarStack.top();
+  const std::set<cmStdString>& init = this->Internal->VarInitStack.top();
   this->Internal->VarStack.push(cmDefinitions(parent));
+  this->Internal->VarInitStack.push(init);
 }
 
 void cmMakefile::PopScope()
 {
+  cmDefinitions* current = &this->Internal->VarStack.top();
+  std::set<cmStdString> init = this->Internal->VarInitStack.top();
+  const std::set<cmStdString>& locals = current->LocalKeys();
+  // Remove initialization information for variables in the local scope.
+  std::set<cmStdString>::const_iterator it = locals.begin();
+  for (; it != locals.end(); ++it)
+    {
+    init.erase(*it);
+    }
   this->Internal->VarStack.pop();
+  this->Internal->VarInitStack.pop();
+  // Push initialization up to the parent scope.
+  it = init.begin();
+  for (; it != init.end(); ++it)
+    {
+    this->Internal->VarInitStack.top().insert(*it);
+    }
 }
 
 void cmMakefile::RaiseScope(const char *var, const char *varDef)
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index daeab83..cec2738 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -61,6 +61,8 @@ public:
   unsigned int GetCacheMajorVersion();
   unsigned int GetCacheMinorVersion();
 
+  /* return true if a variable has been initialized */
+  bool VariableInitialized(const char* ) const;
   /* return true if a variable has been set with
      set(foo )
   */

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=52f9637174242752721dfb322908adb40c8244c2
commit 52f9637174242752721dfb322908adb40c8244c2
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Tue Aug 24 14:40:51 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:14 2010 -0400

    Add method to get the local scope variables

diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 2d40718..34ca68d 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -85,6 +85,19 @@ const char* cmDefinitions::Set(const char* key, const char* value)
 }
 
 //----------------------------------------------------------------------------
+std::set<cmStdString> cmDefinitions::LocalKeys() const
+{
+  std::set<cmStdString> keys;
+  // Consider local definitions.
+  for(MapType::const_iterator mi = this->Map.begin();
+      mi != this->Map.end(); ++mi)
+    {
+    keys.insert(mi->first);
+    }
+  return keys;
+}
+
+//----------------------------------------------------------------------------
 cmDefinitions cmDefinitions::Closure() const
 {
   return cmDefinitions(ClosureTag(), this);
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index e385e88..4834d84 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -40,6 +40,9 @@ public:
   /** Set (or unset if null) a value associated with a key.  */
   const char* Set(const char* key, const char* value);
 
+  /** Get the set of all local keys.  */
+  std::set<cmStdString> LocalKeys() const;
+
   /** Compute the closure of all defined keys with values.
       This flattens the scope.  The result has no parent.  */
   cmDefinitions Closure() const;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f794d589a44918c905911eb7688d69350922c6b3
commit f794d589a44918c905911eb7688d69350922c6b3
Author:     Bill Hoffman <bill.hoffman at kitware.com>
AuthorDate: Mon Jul 12 15:48:51 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:14 2010 -0400

    Make --strict-mode option, and integrate with cmake-gui

diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index d6df305..aa21c31 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -24,9 +24,13 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
 
     # Compile the ABI identification source.
     SET(BIN "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDetermineCompilerABI_${lang}.bin")
+    SET(CMAKE_FLAGS )
+    IF(DEFINED CMAKE_${lang}_VERBOSE_FLAG)
+      SET(CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}")
+    ENDIF()
     TRY_COMPILE(CMAKE_DETERMINE_${lang}_ABI_COMPILED
       ${CMAKE_BINARY_DIR} ${src}
-      CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}"
+      CMAKE_FLAGS "${CMAKE_FLAGS}"
                   "-DCMAKE_${lang}_STANDARD_LIBRARIES="
       OUTPUT_VARIABLE OUTPUT
       COPY_FILE "${BIN}"
@@ -58,10 +62,16 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
       # Parse implicit linker information for this language, if available.
       SET(implicit_dirs "")
       SET(implicit_libs "")
+      SET(MULTI_ARCH FALSE)
+      IF(DEFINED CMAKE_OSX_ARCHITECTURES)
+        IF( "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";" )
+          SET(MULTI_ARCH TRUE)
+        ENDIF()
+      ENDIF()
       IF(CMAKE_${lang}_VERBOSE_FLAG
           # Implicit link information cannot be used explicitly for
           # multiple OS X architectures, so we skip it.
-          AND NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES ";"
+          AND NOT MULTI_ARCH
           # Skip this with Xcode for now.
           AND NOT "${CMAKE_GENERATOR}" MATCHES Xcode)
         CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs log)
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index bf78a5b..9a3884a 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -243,7 +243,9 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
 #    ENDIF("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "feedface")
 
   ENDIF(NOT CMAKE_EXECUTABLE_FORMAT)
-
+  IF(NOT DEFINED CMAKE_EXECUTABLE_FORMAT)
+    SET(CMAKE_EXECUTABLE_FORMAT)
+  ENDIF()
   # Return the information extracted.
   SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
   SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE)
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 74a3d35..7600897 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -114,8 +114,12 @@ CMakeSetupDialog::CMakeSetupDialog()
                    this, SLOT(doInstallForCommandLine()));
 #endif  
   QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
-  this->SuppressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)"));
+  this->SuppressDevWarningsAction =
+    OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)"));
   this->SuppressDevWarningsAction->setCheckable(true);
+  this->StrictModeAction =
+    OptionsMenu->addAction(tr("&Strict Mode (--strict-mode)"));
+  this->StrictModeAction->setCheckable(true);
 
   QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output"));
   debugAction->setCheckable(true);
@@ -240,6 +244,9 @@ void CMakeSetupDialog::initialize()
 
   QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)), 
                    this->CMakeThread->cmakeInstance(), SLOT(setSuppressDevWarnings(bool)));
+  QObject::connect(this->StrictModeAction, SIGNAL(triggered(bool)),
+                   this->CMakeThread->cmakeInstance(),
+                   SLOT(setStrictMode(bool)));
   
   if(!this->SourceDirectory->text().isEmpty() ||
      !this->BinaryDirectory->lineEdit()->text().isEmpty())
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index 0e3caec..cd2be6e 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -93,6 +93,7 @@ protected:
   QAction* ConfigureAction;
   QAction* GenerateAction;
   QAction* SuppressDevWarningsAction;
+  QAction* StrictModeAction;
   QAction* InstallForCommandLineAction;
   State CurrentState;
 
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index dc31fad..31daf3c 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -28,6 +28,7 @@ QCMake::QCMake(QObject* p)
   : QObject(p)
 {
   this->SuppressDevWarnings = false;
+  this->StrictMode = false;
   qRegisterMetaType<QCMakeProperty>();
   qRegisterMetaType<QCMakePropertyList>();
   
@@ -164,6 +165,8 @@ void QCMake::configure()
     this->CMakeInstance->CreateGlobalGenerator(this->Generator.toAscii().data()));
   this->CMakeInstance->LoadCache();
   this->CMakeInstance->SetSuppressDevWarnings(this->SuppressDevWarnings);
+  std::cerr << "set strict " << this->StrictMode << "\n";
+  this->CMakeInstance->SetStrictMode(this->StrictMode);
   this->CMakeInstance->PreLoadCMakeFiles();
 
   cmSystemTools::ResetErrorOccuredFlag();
@@ -417,3 +420,8 @@ void QCMake::setSuppressDevWarnings(bool value)
 {
   this->SuppressDevWarnings = value;
 }
+
+void QCMake::setStrictMode(bool value)
+{
+  this->StrictMode = value;
+}
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index bbfb3d7..f20893f 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -88,6 +88,8 @@ public slots:
   void setDebugOutput(bool);
   /// set whether to do suppress dev warnings
   void setSuppressDevWarnings(bool value);
+  /// set whether to run cmake in strict mode
+  void setStrictMode(bool value);
 
 public:
   /// get the list of cache properties
@@ -133,6 +135,7 @@ protected:
   static void errorCallback(const char* msg, const char* title, 
                             bool&, void* cd);
   bool SuppressDevWarnings;
+  bool StrictMode;
   QString SourceDirectory;
   QString BinaryDirectory;
   QString Generator;
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 027a2ba..410058f 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -20,6 +20,7 @@ int cmCommandArgument_yyparse( yyscan_t yyscanner );
 //
 cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
 {
+  this->StrictMode = false;
   this->FileLine = -1;
   this->FileName = 0;
   this->RemoveEmpty = true;
@@ -123,10 +124,15 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
   const char* value = this->Makefile->GetDefinition(var);
   if(!value && !this->RemoveEmpty)
     {
-    if(!this->Makefile->VariableCleared(var))
+    // 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->StrictMode && !this->Makefile->VariableCleared(var))
       {
-      std::cerr << this->FileName << ":" << this->FileLine << ":" <<
-        " warning: uninitialized variable \'" << var << "\'\n";
+      cmOStringStream msg;
+      msg << this->FileName << ":" << this->FileLine << ":" <<
+        " warning: uninitialized variable \'" << var << "\'";
+      cmSystemTools::Message(msg.str().c_str());
       }
     return 0;
     }
@@ -324,6 +330,7 @@ void cmCommandArgumentParserHelper::Error(const char* str)
 void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
 {
   this->Makefile = mf;
+  this->StrictMode = mf->GetCMakeInstance()->GetStrictMode();
 }
 
 void cmCommandArgumentParserHelper::SetResult(const char* value)
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index 62cbc80..d7206ee 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -96,6 +96,7 @@ private:
   const cmMakefile* Makefile;
   std::string Result;
   const char* FileName;
+  bool StrictMode;
   long FileLine;
   bool EscapeQuotes;
   std::string ErrorString;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 0f9ef1b..2e77748 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -140,6 +140,7 @@ void cmNeedBackwardsCompatibility(const std::string& variable,
 cmake::cmake()
 {
   this->Trace = false;
+  this->StrictMode = false;
   this->SuppressDevWarnings = false;
   this->DoSuppressDevWarnings = false;
   this->DebugOutput = false;
@@ -613,6 +614,11 @@ void cmake::SetArgs(const std::vector<std::string>& args)
       std::cout << "Running with trace output on.\n";
       this->SetTrace(true);
       }
+    else if(arg.find("--strict-mode",0) == 0)
+      {
+      std::cout << "Running in strict mode.\n";
+      this->SetStrictMode(true);
+      }
     else if(arg.find("-G",0) == 0)
       {
       std::string value = arg.substr(2);
diff --git a/Source/cmake.h b/Source/cmake.h
index 8312795..5c2f17a 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -306,6 +306,8 @@ class cmake
   // Do we want trace output during the cmake run.
   bool GetTrace() { return this->Trace;}
   void SetTrace(bool b) {  this->Trace = b;}
+  bool GetStrictMode() { return this->StrictMode;}
+  void SetStrictMode(bool b) {  this->StrictMode = b;}
   // Define a property
   void DefineProperty(const char *name, cmProperty::ScopeType scope,
                       const char *ShortDescription,
@@ -443,6 +445,7 @@ private:
   bool ScriptMode;
   bool DebugOutput;
   bool Trace;
+  bool StrictMode;
   std::string CMakeEditCommand;
   std::string CMakeCommand;
   std::string CXXEnvironment;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index ddff71d..ac2a338 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -120,6 +120,9 @@ static const char * cmDocumentationOptions[][3] =
   {"--trace", "Put cmake in trace mode.",
    "Print a trace of all calls made and from where with "
    "message(send_error ) calls."},
+  {"--strict-mode", "Put cmake in strict mode.",
+   "In strict mode cmake will print a warning when an uninitialized variable "
+   "is 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 "

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=48b5b855934be341c02139c0bed88c35c1b40d8f
commit 48b5b855934be341c02139c0bed88c35c1b40d8f
Author:     Bill Hoffman <bill.hoffman at kitware.com>
AuthorDate: Tue Apr 13 09:21:31 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:13 2010 -0400

    Add a warning when variables are used uninitialized.

diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 234c37e..027a2ba 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -119,10 +119,15 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
     cmOStringStream ostr;
     ostr << this->FileLine;
     return this->AddString(ostr.str().c_str());
-    } 
+    }
   const char* value = this->Makefile->GetDefinition(var);
   if(!value && !this->RemoveEmpty)
     {
+    if(!this->Makefile->VariableCleared(var))
+      {
+      std::cerr << this->FileName << ":" << this->FileLine << ":" <<
+        " warning: uninitialized variable \'" << var << "\'\n";
+      }
     return 0;
     }
   if (this->EscapeQuotes && value)
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 8eece6b..c56641c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -43,6 +43,7 @@ class cmMakefile::Internals
 {
 public:
   std::stack<cmDefinitions, std::list<cmDefinitions> > VarStack;
+  std::set<cmStdString> VarRemoved;
 };
 
 // default is not to be building executables
@@ -1694,9 +1695,19 @@ void cmMakefile::AddDefinition(const char* name, bool value)
 #endif
 }
 
+bool cmMakefile::VariableCleared(const char* var) const
+{
+  if(this->Internal->VarRemoved.find(var) != this->Internal->VarRemoved.end())
+    {
+    return true;
+    }
+  return false;
+}
+
 void cmMakefile::RemoveDefinition(const char* name)
 {
   this->Internal->VarStack.top().Set(name, 0);
+  this->Internal->VarRemoved.insert(name);
 #ifdef CMAKE_BUILD_WITH_CMAKE
   cmVariableWatch* vv = this->GetVariableWatch();
   if ( vv )
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 4fae7ee..daeab83 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -61,6 +61,10 @@ public:
   unsigned int GetCacheMajorVersion();
   unsigned int GetCacheMinorVersion();
 
+  /* return true if a variable has been set with
+     set(foo )
+  */
+  bool VariableCleared(const char* ) const;
   /** Return whether compatibility features needed for a version of
       the cache or lower should be enabled.  */
   bool NeedCacheCompatibility(int major, int minor);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cd626ea66ed114736ddf5d6a4c989ef6c9b8d248
commit cd626ea66ed114736ddf5d6a4c989ef6c9b8d248
Author:     Bill Hoffman <bill.hoffman at kitware.com>
AuthorDate: Tue Apr 13 08:56:11 2010 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Sep 1 13:08:13 2010 -0400

    For macros make sure the FilePath points to a valid pointer in the args.

diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 497949a..774f32b 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -31,6 +31,7 @@ public:
     // we must copy when we clone
     newC->Args = this->Args;
     newC->Functions = this->Functions;
+    newC->FilePath = this->FilePath;
     newC->Policies = this->Policies;
     return newC;
   }
@@ -78,6 +79,7 @@ public:
   std::vector<std::string> Args;
   std::vector<cmListFileFunction> Functions;
   cmPolicies::PolicyMap Policies;
+  std::string FilePath;
 };
 
 
@@ -121,7 +123,10 @@ bool cmMacroHelperCommand::InvokeInitialPass
   std::string argnDef;
   bool argnDefInitialized = false;
   bool argvDefInitialized = false;
-
+  if( this->Functions.size())
+    {
+    this->FilePath = this->Functions[0].FilePath;
+    }
   // Invoke all the functions that were collected in the block.
   cmListFileFunction newLFF;
   // for each function
@@ -135,10 +140,13 @@ bool cmMacroHelperCommand::InvokeInitialPass
     newLFF.Line = this->Functions[c].Line;
 
     // for each argument of the current function
-    for (std::vector<cmListFileArgument>::const_iterator k = 
+    for (std::vector<cmListFileArgument>::iterator k =
            this->Functions[c].Arguments.begin();
          k != this->Functions[c].Arguments.end(); ++k)
       {
+      // Set the FilePath on the arguments to match the function since it is
+      // not stored and the original values may be freed
+      k->FilePath = this->FilePath.c_str();
       tmps = k->Value;
       // replace formal arguments
       for (unsigned int j = 1; j < this->Args.size(); ++j)
diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h
index 3457da2..93e10b2 100644
--- a/Source/cmMacroCommand.h
+++ b/Source/cmMacroCommand.h
@@ -112,7 +112,6 @@ public:
       "policies inside macros."
       ;
     }
-
   cmTypeMacro(cmMacroCommand, cmCommand);
 };
 

-----------------------------------------------------------------------

Summary of changes:
 Modules/CMakeDetermineCompilerABI.cmake  |   14 +++-
 Modules/CMakeDetermineCompilerId.cmake   |    4 +-
 Source/QtDialog/CMakeSetupDialog.cxx     |   15 ++++-
 Source/QtDialog/CMakeSetupDialog.h       |    2 +
 Source/QtDialog/QCMake.cxx               |   15 ++++
 Source/QtDialog/QCMake.h                 |    7 ++
 Source/cmCommandArgumentParserHelper.cxx |   20 +++++-
 Source/cmCommandArgumentParserHelper.h   |    2 +
 Source/cmDefinitions.cxx                 |   13 ++++
 Source/cmDefinitions.h                   |    3 +
 Source/cmMacroCommand.cxx                |   12 +++-
 Source/cmMacroCommand.h                  |    1 -
 Source/cmMakefile.cxx                    |  108 +++++++++++++++++++++++++++++-
 Source/cmMakefile.h                      |   12 +++
 Source/cmake.cxx                         |   54 +++++++++++++++
 Source/cmake.h                           |   16 +++++
 Source/cmakemain.cxx                     |    6 ++
 17 files changed, 295 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list