diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2010-09-01 14:22:08 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2010-09-01 17:09:08 (GMT) |
commit | fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d (patch) | |
tree | cd9736d600c9a8606ed40493c33c825a1d0f3f30 /Source/cmake.cxx | |
parent | 786e2695cb68402d44357002b438c95229c4fb19 (diff) | |
download | CMake-fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d.zip CMake-fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d.tar.gz CMake-fff9f6d6f74aa92d0bc4adf3a80a25b1b662458d.tar.bz2 |
Rename flags again and use variablewatch for cli
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 43 |
1 files changed, 36 insertions, 7 deletions
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); |