[Cmake-commits] CMake branch, next, updated. v2.8.4-1265-gfccdca9

Brad King brad.king at kitware.com
Thu Mar 24 12:13:35 EDT 2011


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  fccdca95de7e2381701883bdb68db496bc3e46ce (commit)
       via  a4335a621eabd74645dfdb6b0c731a6d354fcd30 (commit)
       via  a75ebe3ea48c957e3e7b8c1438ceb6136595eb61 (commit)
      from  56d2a2cc9976b6eb70a819272c1c832f7438a9a4 (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=fccdca95de7e2381701883bdb68db496bc3e46ce
commit fccdca95de7e2381701883bdb68db496bc3e46ce
Merge: 56d2a2c a4335a6
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Mar 24 12:13:33 2011 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Mar 24 12:13:33 2011 -0400

    Merge topic 'cleanup-unused-variable-check' into next
    
    a4335a6 Fix unused cache warning after multiple configure iterations
    a75ebe3 Refine unused cache variable warning


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a4335a621eabd74645dfdb6b0c731a6d354fcd30
commit a4335a621eabd74645dfdb6b0c731a6d354fcd30
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Mar 24 09:44:23 2011 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Mar 24 09:45:33 2011 -0400

    Fix unused cache warning after multiple configure iterations
    
    The curses dialog (ccmake) allows variables to be specified on the
    command line.  If any of these variables is used during any configure
    iteration or during generate we must not warn about it.
    
    The Qt dialog (cmake-gui) allows variables to be added and removed in
    the GUI interactively.  If a variable is added, removed, and then added
    again we must still warn if it is unused.

diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 221a2f3..7f7ca97 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -4306,7 +4306,10 @@ void cmake::WatchUnusedCli(const char* var)
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
   this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
-  this->UsedCliVariables[var] = false;
+  if(this->UsedCliVariables.find(var) == this->UsedCliVariables.end())
+    {
+    this->UsedCliVariables[var] = false;
+    }
 #endif
 }
 
@@ -4314,7 +4317,7 @@ void cmake::UnwatchUnusedCli(const char* var)
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
   this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning);
-  this->UsedCliVariables[var] = true;
+  this->UsedCliVariables.erase(var);
 #endif
 }
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a75ebe3ea48c957e3e7b8c1438ceb6136595eb61
commit a75ebe3ea48c957e3e7b8c1438ceb6136595eb61
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Mar 24 09:24:27 2011 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Mar 24 09:45:33 2011 -0400

    Refine unused cache variable warning
    
    List all unused variables in one warning.  Cleanup implementation to run
    the check exactly once at the end of generation.

diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index d47fb6f..6c8938e 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -903,8 +903,6 @@ void cmGlobalGenerator::Generate()
     }
 
   this->CMakeInstance->UpdateProgress("Generating done", -1);
-
-  this->CMakeInstance->RunCheckForUnusedVariables("generation");
 }
 
 //----------------------------------------------------------------------------
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index bab0aaf..221a2f3 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2310,11 +2310,6 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
   std::string oldstartoutputdir = this->GetStartOutputDirectory();
   this->SetStartDirectory(this->GetHomeDirectory());
   this->SetStartOutputDirectory(this->GetHomeOutputDirectory());
-  const bool warncli = this->WarnUnusedCli;
-  if (!this->ScriptMode)
-    {
-    this->WarnUnusedCli = false;
-    }
   int ret = this->Configure();
   if (ret || this->ScriptMode)
     {
@@ -2336,7 +2331,6 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
 #endif
     return ret;
     }
-  this->WarnUnusedCli = warncli;
   ret = this->Generate();
   std::string message = "Build files have been written to: ";
   message += this->GetHomeOutputDirectory();
@@ -2358,6 +2352,10 @@ int cmake::Generate()
     return -1;
     }
   this->GlobalGenerator->Generate();
+  if(this->WarnUnusedCli)
+    {
+    this->RunCheckForUnusedVariables();
+    }
   if(cmSystemTools::GetErrorOccuredFlag())
     {
     return -1;
@@ -4320,23 +4318,25 @@ void cmake::UnwatchUnusedCli(const char* var)
 #endif
 }
 
-void cmake::RunCheckForUnusedVariables(const std::string& reason) const
+void cmake::RunCheckForUnusedVariables()
 {
 #ifdef CMAKE_BUILD_WITH_CMAKE
-    if(this->WarnUnusedCli)
+  bool haveUnused = false;
+  cmOStringStream msg;
+  msg << "Manually-specified variables were not used by the project:";
+  for(std::map<cmStdString, bool>::const_iterator
+        it = this->UsedCliVariables.begin();
+      it != this->UsedCliVariables.end(); ++it)
+    {
+    if(!it->second)
       {
-      std::map<std::string, bool>::const_iterator it;
-      for(it = this->UsedCliVariables.begin();
-          it != this->UsedCliVariables.end(); ++it)
-        {
-        if(!it->second)
-          {
-          std::string message = "CMake Warning: The variable, '" + it->first +
-            "', specified manually, was not used during the " + reason +
-            ".";
-          cmSystemTools::Message(message.c_str());
-          }
-        }
+      haveUnused = true;
+      msg << "\n  " << it->first;
       }
+    }
+  if(haveUnused)
+    {
+    this->IssueMessage(cmake::WARNING, msg.str(), cmListFileBacktrace());
+    }
 #endif
 }
diff --git a/Source/cmake.h b/Source/cmake.h
index 1bb42d3..00fba57 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -368,8 +368,8 @@ class cmake
 
   void UnwatchUnusedCli(const char* var);
   void WatchUnusedCli(const char* var);
-  void RunCheckForUnusedVariables(const std::string& reason) const;
 protected:
+  void RunCheckForUnusedVariables();
   void InitializeProperties();
   int HandleDeleteCacheVariables(const char* var);
   cmPropertyMap Properties;
@@ -465,7 +465,7 @@ private:
   bool WarnUnused;
   bool WarnUnusedCli;
   bool CheckSystemVars;
-  std::map<std::string, bool> UsedCliVariables;
+  std::map<cmStdString, bool> UsedCliVariables;
   std::string CMakeEditCommand;
   std::string CMakeCommand;
   std::string CXXEnvironment;
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 2c11919..9fdc9f9 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1202,7 +1202,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
     --build-project WarnUnusedCliUnused
     --build-options "-DUNUSED_CLI_VARIABLE=Unused")
   SET_TESTS_PROPERTIES(WarnUnusedCliUnused PROPERTIES
-    PASS_REGULAR_EXPRESSION "CMake Warning: The variable, 'UNUSED_CLI_VARIABLE'")
+    PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.*  UNUSED_CLI_VARIABLE")
   LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
 
   ADD_TEST(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}

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

Summary of changes:
 Source/cmGlobalGenerator.cxx |    2 -
 Source/cmake.cxx             |   47 ++++++++++++++++++++++-------------------
 Source/cmake.h               |    4 +-
 Tests/CMakeLists.txt         |    2 +-
 4 files changed, 28 insertions(+), 27 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list