diff options
author | Michael Scott <michael.scott250@gmail.com> | 2015-11-29 12:39:03 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-12-01 14:40:43 (GMT) |
commit | 07388f83b69739116c8364e9443f10158fcdc912 (patch) | |
tree | ecd6ab97971a063dabd853908754874d5f3baa0b /Source/cmake.cxx | |
parent | 246b0bfbfda9a8f3091fc34fc92816aebaf60ae9 (diff) | |
download | CMake-07388f83b69739116c8364e9443f10158fcdc912.zip CMake-07388f83b69739116c8364e9443f10158fcdc912.tar.gz CMake-07388f83b69739116c8364e9443f10158fcdc912.tar.bz2 |
Refactor the -W options parser to be generic.
Refactor the -Wdev and -Wno-dev options parser to use a generic -W
parser that follows the GCC pattern, excluding support for
-Werror=TYPE and -Wno-error=TYPE formats for now.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 104 |
1 files changed, 76 insertions, 28 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 5213130..e6433bd 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -127,8 +127,6 @@ cmake::cmake() this->WarnUnused = false; this->WarnUnusedCli = true; this->CheckSystemVars = false; - this->SuppressDevWarnings = false; - this->DoSuppressDevWarnings = false; this->DebugOutput = false; this->DebugTryCompile = false; this->ClearBuildSystem = false; @@ -274,15 +272,51 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) return false; } } - else if(arg.find("-Wno-dev",0) == 0) + else if(cmHasLiteralPrefix(arg, "-W")) { - this->SuppressDevWarnings = true; - this->DoSuppressDevWarnings = true; - } - else if(arg.find("-Wdev",0) == 0) - { - this->SuppressDevWarnings = false; - this->DoSuppressDevWarnings = true; + std::string entry = arg.substr(2); + if (entry.empty()) + { + ++i; + if (i < args.size()) + { + entry = args[i]; + } + else + { + cmSystemTools::Error("-W must be followed with [no-]<name>."); + return false; + } + } + + std::string name; + bool foundNo = false; + unsigned int nameStartPosition = 0; + + if (entry.find("no-", nameStartPosition) == 0) + { + foundNo = true; + nameStartPosition += 3; + } + + name = entry.substr(nameStartPosition); + if (name.empty()) + { + cmSystemTools::Error("No warning name provided."); + return false; + } + + if (!foundNo) + { + // -W<name> + this->DiagLevels[name] = std::max(this->DiagLevels[name], + DIAG_WARN); + } + else + { + // -Wno<name> + this->DiagLevels[name] = DIAG_IGNORE; + } } else if(arg.find("-U",0) == 0) { @@ -618,11 +652,7 @@ void cmake::SetArgs(const std::vector<std::string>& args, // skip for now i++; } - else if(arg.find("-Wno-dev",0) == 0) - { - // skip for now - } - else if(arg.find("-Wdev",0) == 0) + else if(arg.find("-W",0) == 0) { // skip for now } @@ -1231,25 +1261,28 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) int cmake::Configure() { - if(this->DoSuppressDevWarnings) + DiagLevel diagLevel; + + if (this->DiagLevels.count("dev") == 1) { - if(this->SuppressDevWarnings) + + diagLevel = this->DiagLevels["dev"]; + if (diagLevel == DIAG_IGNORE) { - this-> - AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE", - "Suppress Warnings that are meant for" - " the author of the CMakeLists.txt files.", - cmState::INTERNAL); + this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE", + "Suppress Warnings that are meant for" + " the author of the CMakeLists.txt files.", + cmState::INTERNAL); } - else + else if (diagLevel == DIAG_WARN) { - this-> - AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", - "Suppress Warnings that are meant for" - " the author of the CMakeLists.txt files.", - cmState::INTERNAL); + this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", + "Suppress Warnings that are meant for" + " the author of the CMakeLists.txt files.", + cmState::INTERNAL); } } + int ret = this->ActualConfigure(); const char* delCacheVars = this->State ->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_"); @@ -2805,6 +2838,21 @@ void cmake::RunCheckForUnusedVariables() #endif } +void cmake::SetSuppressDevWarnings(bool b) +{ + // equivalent to -Wno-dev + if (b) + { + this->DiagLevels["dev"] = DIAG_IGNORE; + } + // equivalent to -Wdev + else + { + this->DiagLevels["dev"] = std::max(this->DiagLevels["dev"], + DIAG_WARN); + } +} + bool cmake::GetSuppressDevWarnings(cmMakefile const* mf) { /* |