[Cmake-commits] CMake branch, next, updated. v2.8.2-657-g8aa478a
Ben Boeckel
ben.boeckel at kitware.com
Thu Sep 2 11:47:32 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 8aa478a07207baae969e2a49729e72e5eb50e67c (commit)
via 4cf17062d36ecb87314afbfc0bed4545c8711eeb (commit)
via b74777fdb21e3632a4adfcd1e15844b632a2765d (commit)
via b94812072a3e6dbcfc00255d46ea445769092d2f (commit)
via f047a17c5910cec1c0b9c20acb74510747ce6ba1 (commit)
via 75bda3864ea033f976773df80f22fea2992a165d (commit)
via 300fc15779330a1b733c9e1a19d24d682a3b4a91 (commit)
via d784e6af4d292e5ffee4b43b7ee740d1fa8e2e29 (commit)
from bf394083f21bbda8b513775e58e8b8f7f366fe25 (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=8aa478a07207baae969e2a49729e72e5eb50e67c
commit 8aa478a07207baae969e2a49729e72e5eb50e67c
Merge: bf39408 4cf1706
Author: Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Thu Sep 2 11:47:29 2010 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Sep 2 11:47:29 2010 -0400
Merge topic 'dev/strict-mode' into next
4cf1706 Add documentation for check-system-vars
b74777f Fix the spelling of the flag for warn-unused-vars
b948120 Change logic of flag to turn off cli unused checks
f047a17 Add test for uninitialized variables
75bda38 Add tests for unused command line variables
300fc15 Fix detection of system files
d784e6a Run the unused variables check on the final pass
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4cf17062d36ecb87314afbfc0bed4545c8711eeb
commit 4cf17062d36ecb87314afbfc0bed4545c8711eeb
Author: Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Thu Sep 2 11:39:22 2010 -0400
Commit: Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Thu Sep 2 11:39:22 2010 -0400
Add documentation for check-system-vars
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index d7ab951..aa455a0 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -126,6 +126,9 @@ static const char * cmDocumentationOptions[][3] =
"Find variables that are declared or set, but not used."},
{"--no-warn-unused-cli", "Don't warn about command line options.",
"Don't find variables that are declared on the command line, but not used."},
+ {"--check-system-vars", "Find problems with variable usage in system files.",
+ "Normally, unused and uninitialized variables are searched for only in CMAKE_SOURCE_DIR "
+ "and CMAKE_BINARY_DIR. This flag tells CMake to warn about other files as well."},
{"--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=b74777fdb21e3632a4adfcd1e15844b632a2765d
commit b74777fdb21e3632a4adfcd1e15844b632a2765d
Author: Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Thu Sep 2 11:39:01 2010 -0400
Commit: Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Thu Sep 2 11:39:01 2010 -0400
Fix the spelling of the flag for warn-unused-vars
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 93b844f..d7ab951 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -122,7 +122,7 @@ 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-all", "Warn about unused variables.",
+ {"--warn-unused-vars", "Warn about unused variables.",
"Find variables that are declared or set, but not used."},
{"--no-warn-unused-cli", "Don't warn about command line options.",
"Don't find variables that are declared on the command line, but not used."},
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b94812072a3e6dbcfc00255d46ea445769092d2f
commit b94812072a3e6dbcfc00255d46ea445769092d2f
Author: Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Thu Sep 2 11:38:00 2010 -0400
Commit: Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Thu Sep 2 11:38:00 2010 -0400
Change logic of flag to turn off cli unused checks
Since we default to checking unused cli variables, make the flag turn
off the checks.
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index b3261c5..f4680ca 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -641,10 +641,10 @@ void cmake::SetArgs(const std::vector<std::string>& args)
std::cout << "Finding unused variables.\n";
this->SetWarnUnused(true);
}
- else if(arg.find("--warn-unused-cli",0) == 0)
+ else if(arg.find("--no-warn-unused-cli",0) == 0)
{
- std::cout << "Finding unused variables given on the command line.\n";
- this->SetWarnUnusedCli(true);
+ std::cout << "Not finding unused variables given on the command line.\n";
+ this->SetWarnUnusedCli(false);
}
else if(arg.find("--check-system-vars",0) == 0)
{
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index cb3fcb0..93b844f 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -124,8 +124,8 @@ static const char * cmDocumentationOptions[][3] =
"Print a warning when an uninitialized variable is used."},
{"--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."},
+ {"--no-warn-unused-cli", "Don't warn about command line options.",
+ "Don't find variables that are declared on the command line, 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=f047a17c5910cec1c0b9c20acb74510747ce6ba1
commit f047a17c5910cec1c0b9c20acb74510747ce6ba1
Author: Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Thu Sep 2 11:34:13 2010 -0400
Commit: Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Thu Sep 2 11:34:13 2010 -0400
Add test for uninitialized variables
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 6415472..481be09 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1102,6 +1102,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
FAIL_REGULAR_EXPRESSION "warning: The variable, \"USED_VARIABLE\"")
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed")
+ ADD_TEST(WarnUninitialized ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/VariableUsage"
+ "${CMake_BINARY_DIR}/Tests/WarnUninitialized"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-noclean
+ --build-project WarnUninitialized
+ --build-options "--warn-uninitialized")
+ SET_TESTS_PROPERTIES(WarnUninitialized PROPERTIES
+ PASS_REGULAR_EXPRESSION "warning: uninitialized variable 'USED_VARIABLE'")
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUninitialized")
+
# Make sure CTest can handle a test with no newline in output.
ADD_TEST(CTest.NoNewline
${CMAKE_CMAKE_COMMAND} -E echo_append "This line has no newline!")
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75bda3864ea033f976773df80f22fea2992a165d
commit 75bda3864ea033f976773df80f22fea2992a165d
Author: Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Thu Sep 2 11:33:57 2010 -0400
Commit: Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Thu Sep 2 11:33:57 2010 -0400
Add tests for unused command line variables
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 5383bda..6415472 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1074,6 +1074,34 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest")
ENDIF(APPLE AND CTEST_TEST_CPACK)
+ ADD_TEST(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/VariableUsage"
+ "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-noclean
+ --build-project WarnUnusedCliUnused
+ --build-options "-DUNUSED_VARIABLE=Unused")
+ SET_TESTS_PROPERTIES(WarnUnusedCliUnused PROPERTIES
+ PASS_REGULAR_EXPRESSION "warning: The variable, \"UNUSED_VARIABLE\"")
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
+
+ ADD_TEST(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/VariableUsage"
+ "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-noclean
+ --build-project WarnUnusedCliUsed
+ --build-options "-DUSED_VARIABLE=Usage proven")
+ SET_TESTS_PROPERTIES(WarnUnusedCliUsed PROPERTIES
+ PASS_REGULAR_EXPRESSION "Usage proven")
+ SET_TESTS_PROPERTIES(WarnUnusedCliUsed PROPERTIES
+ FAIL_REGULAR_EXPRESSION "warning: The variable, \"USED_VARIABLE\"")
+ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUsed")
+
# Make sure CTest can handle a test with no newline in output.
ADD_TEST(CTest.NoNewline
${CMAKE_CMAKE_COMMAND} -E echo_append "This line has no newline!")
diff --git a/Tests/VariableUsage/CMakeLists.txt b/Tests/VariableUsage/CMakeLists.txt
new file mode 100644
index 0000000..4da1f56
--- /dev/null
+++ b/Tests/VariableUsage/CMakeLists.txt
@@ -0,0 +1 @@
+message(STATUS "${USED_VARIABLE}")
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=300fc15779330a1b733c9e1a19d24d682a3b4a91
commit 300fc15779330a1b733c9e1a19d24d682a3b4a91
Author: Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Thu Sep 2 11:30:28 2010 -0400
Commit: Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Thu Sep 2 11:33:34 2010 -0400
Fix detection of system files
Instead of looking to see if the file is under CMAKE_ROOT, check to see
if it is instead under the source or binary directories in use.
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index e9381d4..c0a8127 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -130,8 +130,10 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
// not been "cleared"/initialized with a set(foo ) call
if(this->WarnUninitialized && !this->Makefile->VariableInitialized(var))
{
- const char* root = this->Makefile->GetDefinition("CMAKE_ROOT");
- if (this->CheckSystemVars || strstr(this->FileName, root) != this->FileName)
+ const char* srcRoot = this->Makefile->GetDefinition("CMAKE_SOURCE_DIR");
+ const char* binRoot = this->Makefile->GetDefinition("CMAKE_BINARY_DIR");
+ if (this->CheckSystemVars || strstr(this->FileName, srcRoot) == this->FileName ||
+ strstr(this->FileName, binRoot) == this->FileName)
{
cmOStringStream msg;
msg << this->FileName << ":" << this->FileLine << ":" <<
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 288bc53..26b9a58 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3392,8 +3392,9 @@ void cmMakefile::PopScope()
if (this->WarnUnused && usage.find(*it) == usage.end())
{
const char* cdir = this->ListFileStack.back().c_str();
- const char* root = this->GetDefinition("CMAKE_ROOT");
- if (this->CheckSystemVars || strstr(cdir, root) != cdir)
+ const char* srcRoot = this->GetDefinition("CMAKE_SOURCE_DIR");
+ const char* binRoot = this->GetDefinition("CMAKE_BINARY_DIR");
+ if (this->CheckSystemVars || strstr(cdir, srcRoot) == cdir || strstr(cdir, binRoot) == cdir)
{
cmOStringStream m;
m << "unused variable \'" << *it << "\'";
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d784e6af4d292e5ffee4b43b7ee740d1fa8e2e29
commit d784e6af4d292e5ffee4b43b7ee740d1fa8e2e29
Author: Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Thu Sep 2 11:29:05 2010 -0400
Commit: Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Thu Sep 2 11:29:05 2010 -0400
Run the unused variables check on the final pass
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 3a23590..288bc53 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -828,6 +828,8 @@ void cmMakefile::ConfigureFinalPass()
{
l->second.FinishConfigure();
}
+
+ this->GetCMakeInstance()->RunCheckForUnusedVariables();
}
//----------------------------------------------------------------------------
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index cb70f1f..b3261c5 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -201,21 +201,6 @@ cmake::cmake()
cmake::~cmake()
{
-#ifdef CMAKE_BUILD_WITH_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 = "warning: The variable, \"" + it->first + "\", given "
- "on the command line, was not used within the build.";
- cmSystemTools::Message(message.c_str());
- }
- }
- }
-#endif
delete this->CacheManager;
delete this->Policies;
if (this->GlobalGenerator)
@@ -4500,3 +4485,22 @@ int cmake::Build(const std::string& dir,
config.c_str(), clean, false, 0, true,
0, nativeOptions);
}
+
+void cmake::RunCheckForUnusedVariables() const
+{
+#ifdef CMAKE_BUILD_WITH_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 = "warning: The variable, \"" + it->first + "\", given "
+ "on the command line, was not used within the build.";
+ cmSystemTools::Message(message.c_str());
+ }
+ }
+ }
+#endif
+}
diff --git a/Source/cmake.h b/Source/cmake.h
index 403809f..4277bdd 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -362,6 +362,8 @@ class cmake
const std::string& config,
const std::vector<std::string>& nativeOptions,
bool clean);
+
+ void RunCheckForUnusedVariables() const;
protected:
void InitializeProperties();
int HandleDeleteCacheVariables(const char* var);
-----------------------------------------------------------------------
Summary of changes:
Source/cmCommandArgumentParserHelper.cxx | 6 +++-
Source/cmMakefile.cxx | 7 +++-
Source/cmake.cxx | 40 ++++++++++++++++-------------
Source/cmake.h | 2 +
Source/cmakemain.cxx | 9 ++++--
Tests/CMakeLists.txt | 41 ++++++++++++++++++++++++++++++
Tests/VariableUsage/CMakeLists.txt | 1 +
7 files changed, 81 insertions(+), 25 deletions(-)
create mode 100644 Tests/VariableUsage/CMakeLists.txt
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list