Hi Brad,
Let's work out the command line options for the existing deprecation warning/error options first and then extend capabilities as a second step. It will be easier to review in smaller pieces anyway.
Okay no problem, I'll try and break the changes down into chunks for review.
I've made the first set of changes, to reapply the series of previous changes for the -W options, along with some tweaks to improve the implementation and some additional tests for the changes. Let me know if there are any issues with the proposed changes. The changes in the patch for the Help files are the same as before, so they can probably be skimmed over to be honest, likewise the changes in cmMessageCommand are the same as before too.
The next stage would then be to add support for upgrading and downgrading warning and error messages depending on the state of the CMake variables, in the IssueMessage function, and update the callers of the function to check the error flag and take appropriate action.
Cheers, Michael
From 8d7aae1411331b980bd5d7515e5f7326db5890cb Mon Sep 17 00:00:00 2001 From: Michael Scott <michael.scott...@gmail.com> Date: Fri, 23 Oct 2015 19:48:58 +0100 Subject: [PATCH] Add -W options to control deprecation and author warnings and errors Refactor the -Wdev and -Wno-dev options parser to use a generic -W parser that follows the GCC pattern, which includes support for -Werror=TYPE and -Wno-error=TYPE formats. Add 'deprecated' warning options type, to allow setting CMAKE_ERROR_DEPRECATED and CMAKE_WARN_DEPRECATED via the -W options. Add -Werror=dev and -Wno-error=dev options so that dev warning options are in line with deprecated warning options. Use a new CMAKE_SUPPRESS_DEVELOPER_ERRORS internal cache entry to store the above new dev options persistently. Add tests for new options and updated cmake documentation and release notes to list new options. --- Help/manual/OPTIONS_BUILD.txt | 43 ++- Help/release/dev/cmake-W-options.rst | 13 + Help/variable/CMAKE_ERROR_DEPRECATED.rst | 8 +- Help/variable/CMAKE_WARN_DEPRECATED.rst | 6 +- Source/cmMessageCommand.cxx | 14 +- Source/cmake.cxx | 297 ++++++++++++++++++--- Source/cmake.h | 27 +- Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 59 +++- Tests/RunCMake/CommandLine/W_bad-arg1-result.txt | 1 + Tests/RunCMake/CommandLine/W_bad-arg1-stderr.txt | 2 + Tests/RunCMake/CommandLine/W_bad-arg2-result.txt | 1 + Tests/RunCMake/CommandLine/W_bad-arg2-stderr.txt | 2 + Tests/RunCMake/CommandLine/W_bad-arg3-result.txt | 1 + Tests/RunCMake/CommandLine/W_bad-arg3-stderr.txt | 2 + Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt | 4 + Tests/RunCMake/CommandLine/Wdeprecated.cmake | 1 + Tests/RunCMake/CommandLine/Wdev-stderr.txt | 2 +- Tests/RunCMake/CommandLine/Wdev.cmake | 2 +- .../CommandLine/Werror_deprecated-result.txt | 1 + .../CommandLine/Werror_deprecated-stderr.txt | 4 + Tests/RunCMake/CommandLine/Werror_deprecated.cmake | 1 + Tests/RunCMake/CommandLine/Werror_dev-result.txt | 1 + Tests/RunCMake/CommandLine/Werror_dev-stderr.txt | 5 + Tests/RunCMake/CommandLine/Werror_dev.cmake | 1 + Tests/RunCMake/CommandLine/Wno-deprecated.cmake | 1 + Tests/RunCMake/CommandLine/Wno-dev.cmake | 2 +- .../CommandLine/Wno-error_deprecated.cmake | 2 + Tests/RunCMake/CommandLine/Wno-error_dev.cmake | 2 + 28 files changed, 447 insertions(+), 58 deletions(-) create mode 100644 Help/release/dev/cmake-W-options.rst create mode 100644 Tests/RunCMake/CommandLine/W_bad-arg1-result.txt create mode 100644 Tests/RunCMake/CommandLine/W_bad-arg1-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/W_bad-arg2-result.txt create mode 100644 Tests/RunCMake/CommandLine/W_bad-arg2-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/W_bad-arg3-result.txt create mode 100644 Tests/RunCMake/CommandLine/W_bad-arg3-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/Wdeprecated.cmake create mode 100644 Tests/RunCMake/CommandLine/Werror_deprecated-result.txt create mode 100644 Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/Werror_deprecated.cmake create mode 100644 Tests/RunCMake/CommandLine/Werror_dev-result.txt create mode 100644 Tests/RunCMake/CommandLine/Werror_dev-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/Werror_dev.cmake create mode 100644 Tests/RunCMake/CommandLine/Wno-deprecated.cmake create mode 100644 Tests/RunCMake/CommandLine/Wno-error_deprecated.cmake create mode 100644 Tests/RunCMake/CommandLine/Wno-error_dev.cmake diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index 4207db4..b65b7c7 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -77,10 +77,49 @@ Suppress developer warnings. Suppress warnings that are meant for the author of the - CMakeLists.txt files. + CMakeLists.txt files. By default this will also turn off + deprecation warnings. ``-Wdev`` Enable developer warnings. Enable warnings that are meant for the author of the CMakeLists.txt - files. + files. By default this will also turn on deprecation warnings. + +``-Werror=dev`` + Make developer warnings errors. + + Make warnings that are meant for the author of the CMakeLists.txt + files errors. By default this will also turn on treatment of + deprecation warnings as errors. + +``-Wno-error=dev`` + Make developer warnings not errors. + + Make warnings that are meant for the author of the CMakeLists.txt + files not errors. By default this will also turn off treatment of + deprecation warnings as errors. + +``-Wdeprecated`` + Enable deprecated macro and function warnings. + + Enable warnings for usage of deprecated macros and functions, that + are meant for the author of the CMakeLists.txt files. + +``-Wno-deprecated`` + Suppress deprecated macro and function warnings. + + Suppress warnings for usage of deprecated macros and functions, that + are meant for the author of the CMakeLists.txt files. + +``-Werror=deprecated`` + Make deprecated macro and function warnings errors. + + Make warnings for usage of deprecated macros and functions, that + are meant for the author of the CMakeLists.txt files, errors. + +``-Wno-error=deprecated`` + Make deprecated macro and function warnings not errors. + + Make warnings for usage of deprecated macros and functions, that + are meant for the author of the CMakeLists.txt files, not errors. diff --git a/Help/release/dev/cmake-W-options.rst b/Help/release/dev/cmake-W-options.rst new file mode 100644 index 0000000..c0b51d0 --- /dev/null +++ b/Help/release/dev/cmake-W-options.rst @@ -0,0 +1,13 @@ +cmake-W-options +--------------- + +* The :variable:`CMAKE_ERROR_DEPRECATED` variable can now be set using the + ``-Werror=deprecated`` and ``-Wno-error=deprecated`` :manual:`cmake(1)` + options. + +* The :variable:`CMAKE_WARN_DEPRECATED` variable can now be set using the + ``-Wdeprecated`` and ``-Wno-deprecated`` :manual:`cmake(1)` options. + +* :manual:`cmake(1)` gained options ``-Werror=dev`` and ``-Wno-error=dev`` + to control whether developer warnings intended for project authors + are treated as errors. diff --git a/Help/variable/CMAKE_ERROR_DEPRECATED.rst b/Help/variable/CMAKE_ERROR_DEPRECATED.rst index 277a4cc..59eb391 100644 --- a/Help/variable/CMAKE_ERROR_DEPRECATED.rst +++ b/Help/variable/CMAKE_ERROR_DEPRECATED.rst @@ -3,6 +3,10 @@ CMAKE_ERROR_DEPRECATED Whether to issue deprecation errors for macros and functions. -If ``TRUE``, this can be used by macros and functions to issue fatal -errors when deprecated macros or functions are used. This variable is +If ``TRUE``, then macros and functions can issue fatal errors when +deprecated macros or functions are used. This variable is ``FALSE`` by default. + +These errors can be enabled with the ``-Werror=deprecated`` option, or +disabled with the ``-Wno-error=deprecated`` option, when running +:manual:`cmake(1)`. diff --git a/Help/variable/CMAKE_WARN_DEPRECATED.rst b/Help/variable/CMAKE_WARN_DEPRECATED.rst index 662cbd8..5c8ce88 100644 --- a/Help/variable/CMAKE_WARN_DEPRECATED.rst +++ b/Help/variable/CMAKE_WARN_DEPRECATED.rst @@ -4,4 +4,8 @@ CMAKE_WARN_DEPRECATED Whether to issue deprecation warnings for macros and functions. If ``TRUE``, this can be used by macros and functions to issue deprecation -warnings. This variable is ``FALSE`` by default. +warnings. This variable is ``TRUE`` by default. + +These warnings can be enabled with the ``-Wdeprecated`` option, or +disabled with the ``-Wno-deprecated`` option, when running +:manual:`cmake(1)`. diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index 2854a82..e09ba75 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -43,7 +43,19 @@ bool cmMessageCommand } else if (*i == "AUTHOR_WARNING") { - type = cmake::AUTHOR_WARNING; + if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) + { + fatal = true; + type = cmake::AUTHOR_ERROR; + } + else if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) + { + type = cmake::AUTHOR_WARNING; + } + else + { + return true; + } ++i; } else if (*i == "STATUS") diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 7268241..4d4553a 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; @@ -250,15 +248,70 @@ 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; + 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-][error=]<name>."); + return false; + } } - else if(arg.find("-Wdev",0) == 0) - { - this->SuppressDevWarnings = false; - this->DoSuppressDevWarnings = true; + + std::string name; + bool foundNo = false; + bool foundError = false; + unsigned int nameStartPosition = 0; + + if (entry.find("no-", nameStartPosition) == 0) + { + foundNo = true; + nameStartPosition += 3; + } + + if (entry.find("error=", nameStartPosition) == 0) + { + foundError = true; + nameStartPosition += 6; + } + + name = entry.substr(nameStartPosition); + if (name.empty()) + { + cmSystemTools::Error("No warning name provided."); + return false; + } + + if (!foundNo && !foundError) + { + // -W<name> + this->WarningLevels[name] = std::max(this->WarningLevels[name], + WARNING_LEVEL); + } + else if (foundNo && !foundError) + { + // -Wno<name> + this->WarningLevels[name] = IGNORE_LEVEL; + } + else if (!foundNo && foundError) + { + // -Werror=<name> + this->WarningLevels[name] = ERROR_LEVEL; + } + else + { + // -Wno-error=<name> + this->WarningLevels[name] = std::min(this->WarningLevels[name], + WARNING_LEVEL); + } } else if(arg.find("-U",0) == 0) { @@ -591,11 +644,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 } @@ -1190,25 +1239,133 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) int cmake::Configure() { - if(this->DoSuppressDevWarnings) + WarningLevel warningLevel; + + if (this->WarningLevels.count("deprecated") == 1) { - if(this->SuppressDevWarnings) + warningLevel = this->WarningLevels["deprecated"]; + if (warningLevel == IGNORE_LEVEL) { - 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_WARN_DEPRECATED", "FALSE", + "Whether to issue deprecation warnings for" + " macros and functions.", + cmState::BOOL); + this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", "FALSE", + "Whether to issue deprecation errors for macros" + " and functions.", + cmState::BOOL); } - else + if (warningLevel == WARNING_LEVEL) + { + this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE", + "Whether to issue deprecation warnings for" + " macros and functions.", + cmState::BOOL); + this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", "FALSE", + "Whether to issue deprecation errors for macros" + " and functions.", + cmState::BOOL); + } + else if (warningLevel == ERROR_LEVEL) + { + this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE", + "Whether to issue deprecation warnings for" + " macros and functions.", + cmState::BOOL); + this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", "TRUE", + "Whether to issue deprecation errors for macros" + " and functions.", + cmState::BOOL); + } + } + + if (this->WarningLevels.count("dev") == 1) + { + bool setDeprecatedVariables = false; + + const char* cachedWarnDeprecated = + this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED"); + const char* cachedErrorDeprecated = + this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED"); + + // don't overwrite deprecated warning setting from a previous invocation + if (!cachedWarnDeprecated && !cachedErrorDeprecated) + { + setDeprecatedVariables = true; + } + + warningLevel = this->WarningLevels["dev"]; + if (warningLevel == IGNORE_LEVEL) + { + 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_ERRORS", "TRUE", + "Suppress errors that are meant for" + " the author of the CMakeLists.txt files.", + cmState::INTERNAL); + + if (setDeprecatedVariables) + { + this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE", + "Whether to issue deprecation warnings for" + " macros and functions.", + cmState::BOOL); + this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", "FALSE", + "Whether to issue deprecation errors for macros" + " and functions.", + cmState::BOOL); + } + } + else if (warningLevel == WARNING_LEVEL) { - 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); + this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", "TRUE", + "Suppress errors that are meant for" + " the author of the CMakeLists.txt files.", + cmState::INTERNAL); + + if (setDeprecatedVariables) + { + this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "TRUE", + "Whether to issue deprecation warnings for" + " macros and functions.", + cmState::BOOL); + this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", "FALSE", + "Whether to issue deprecation errors for macros" + " and functions.", + cmState::BOOL); + } + } + else if (warningLevel == ERROR_LEVEL) + { + 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_ERRORS", "FALSE", + "Suppress errors that are meant for" + " the author of the CMakeLists.txt files.", + cmState::INTERNAL); + + if (setDeprecatedVariables) + { + this->AddCacheEntry("CMAKE_WARN_DEPRECATED", "FALSE", + "Whether to issue deprecation warnings for" + " macros and functions.", + cmState::BOOL); + this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", "TRUE", + "Whether to issue deprecation errors for macros" + " and functions.", + cmState::BOOL); + } } } + int ret = this->ActualConfigure(); const char* delCacheVars = this->State ->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_"); @@ -1539,6 +1696,10 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) { this->AddCMakePaths(); } + + // turn on author, and in turn deprecated, warnings (only) by default + this->WarningLevels["dev"] = WARNING_LEVEL; + // Add any cache args if ( !this->SetCacheArgs(args) ) { @@ -2462,26 +2623,57 @@ bool cmake::PrintMessagePreamble(cmake::MessageType t, std::ostream& msg) else if(t == cmake::DEPRECATION_ERROR) { msg << "CMake Deprecation Error"; + + // if CMAKE_ERROR_DEPRECATED is on, show the message, otherwise suppress it + const char* errorDeprecated = this->State->GetCacheEntryValue( + "CMAKE_ERROR_DEPRECATED"); + if(cmSystemTools::IsOff(errorDeprecated)) + { + return false; + } } else if (t == cmake::DEPRECATION_WARNING) { msg << "CMake Deprecation Warning"; + + // if CMAKE_WARN_DEPRECATED is on, show the message, otherwise suppress it + const char* warnDeprecated = this->State->GetInitializedCacheValue( + "CMAKE_WARN_DEPRECATED"); + if(cmSystemTools::IsOff(warnDeprecated)) + { + return false; + } } - else + else if (t == cmake::AUTHOR_WARNING) { - msg << "CMake Warning"; - if(t == cmake::AUTHOR_WARNING) + msg << "CMake Warning (dev)"; + + // if CMAKE_SUPPRESS_DEVELOPER_WARNINGS is on, suppress the message, + // otherwise show it + const char* suppressDevWarnings = this->State->GetCacheEntryValue( + "CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); + if(cmSystemTools::IsOn(suppressDevWarnings)) { - // Allow suppression of these warnings. - const char* suppress = this->State->GetCacheEntryValue( - "CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); - if(suppress && cmSystemTools::IsOn(suppress)) - { - return false; - } - msg << " (dev)"; + return false; } } + else if (t == cmake::AUTHOR_ERROR) + { + msg << "CMake Error (dev)"; + + // if CMAKE_SUPPRESS_DEVELOPER_WARNINGS is on, suppress the message, + // otherwise show it + const char* suppressDevErrors = this->State->GetCacheEntryValue( + "CMAKE_SUPPRESS_DEVELOPER_ERRORS"); + if(cmSystemTools::IsOn(suppressDevErrors)) + { + return false; + } + } + else + { + msg << "CMake Warning"; + } return true; } @@ -2502,6 +2694,12 @@ void displayMessage(cmake::MessageType t, std::ostringstream& msg) msg << "This warning is for project developers. Use -Wno-dev to suppress it."; } + else if (t == cmake::AUTHOR_ERROR) + { + msg << + "This error is for project developers. Use -Wno-error=dev to suppress " + "it."; + } // Add a terminating blank line. msg << "\n"; @@ -2525,7 +2723,8 @@ void displayMessage(cmake::MessageType t, std::ostringstream& msg) // Output the message. if(t == cmake::FATAL_ERROR || t == cmake::INTERNAL_ERROR - || t == cmake::DEPRECATION_ERROR) + || t == cmake::DEPRECATION_ERROR + || t == cmake::AUTHOR_ERROR) { cmSystemTools::SetErrorOccured(); cmSystemTools::Message(msg.str().c_str(), "Error"); @@ -2557,6 +2756,11 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, backtrace.PrintCallStack(msg); displayMessage(t, msg); + + if (t == cmake::DEPRECATION_ERROR || t == cmake::AUTHOR_ERROR) + { + cmSystemTools::SetFatalErrorOccured(); + } } //---------------------------------------------------------------------------- @@ -2722,3 +2926,18 @@ void cmake::RunCheckForUnusedVariables() } #endif } + +void cmake::SetSuppressDevWarnings(bool b) +{ + // equivalent to -Wno-dev + if (b) + { + this->WarningLevels["dev"] = IGNORE_LEVEL; + } + // equivalent to -Wdev + else + { + this->WarningLevels["dev"] = std::max(this->WarningLevels["dev"], + WARNING_LEVEL); + } +} diff --git a/Source/cmake.h b/Source/cmake.h index 9d28cba..8ac8897 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -59,6 +59,7 @@ class cmake public: enum MessageType { AUTHOR_WARNING, + AUTHOR_ERROR, FATAL_ERROR, INTERNAL_ERROR, MESSAGE, @@ -68,6 +69,12 @@ class cmake DEPRECATION_WARNING }; + enum WarningLevel + { + IGNORE_LEVEL, + WARNING_LEVEL, + ERROR_LEVEL + }; /** \brief Describes the working modes of cmake */ enum WorkingMode @@ -271,6 +278,7 @@ class cmake void SetTrace(bool b) { this->Trace = b;} bool GetTraceExpand() { return this->TraceExpand;} void SetTraceExpand(bool b) { this->TraceExpand = b;} + void SetSuppressDevWarnings(bool b); bool GetWarnUninitialized() { return this->WarnUninitialized;} void SetWarnUninitialized(bool b) { this->WarnUninitialized = b;} bool GetWarnUnused() { return this->WarnUnused;} @@ -291,12 +299,6 @@ class cmake std::string const& GetCMakeEditCommand() const { return this->CMakeEditCommand; } - void SetSuppressDevWarnings(bool v) - { - this->SuppressDevWarnings = v; - this->DoSuppressDevWarnings = true; - } - /** Display a message to the user. */ void IssueMessage(cmake::MessageType t, std::string const& text, cmListFileBacktrace const& backtrace = cmListFileBacktrace()); @@ -339,8 +341,7 @@ protected: cmGlobalGenerator *GlobalGenerator; cmCacheManager *CacheManager; - bool SuppressDevWarnings; - bool DoSuppressDevWarnings; + std::map<std::string, WarningLevel> WarningLevels; std::string GeneratorPlatform; std::string GeneratorToolset; @@ -416,7 +417,15 @@ private: {"-T <toolset-name>", "Specify toolset name if supported by generator."}, \ {"-A <platform-name>", "Specify platform name if supported by generator."}, \ {"-Wno-dev", "Suppress developer warnings."},\ - {"-Wdev", "Enable developer warnings."} + {"-Wdev", "Enable developer warnings."},\ + {"-Werror=dev", "Make developer warnings errors."},\ + {"-Wno-error=dev", "Make developer warnings not errors."},\ + {"-Wdeprecated", "Enable deprecated macro and function warnings."},\ + {"-Wno-deprecated", "Suppress deprecated macro and function warnings."},\ + {"-Werror=deprecated", "Make deprecated macro and function warnings " \ + "errors."},\ + {"-Wno-error=deprecated", "Make deprecated macro and function warnings " \ + "not errors."} #define FOR_EACH_C_FEATURE(F) \ F(c_function_prototypes) \ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 2d94e29..dc706e2 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -129,10 +129,67 @@ set(RunCMake_TEST_OPTIONS -Wno-dev) run_cmake(Wno-dev) unset(RunCMake_TEST_OPTIONS) -set(RunCMake_TEST_OPTIONS -Wno-dev -Wdev) +set(RunCMake_TEST_OPTIONS -Wdev) run_cmake(Wdev) unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS -Werror=dev) +run_cmake(Werror_dev) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS -Wno-error=dev) +run_cmake(Wno-error_dev) +unset(RunCMake_TEST_OPTIONS) + +# -Wdev should not override deprecated options if specified +set(RunCMake_TEST_OPTIONS -Wdev -Wno-deprecated) +run_cmake(Wno-deprecated) +unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS -Wno-deprecated -Wdev) +run_cmake(Wno-deprecated) +unset(RunCMake_TEST_OPTIONS) + +# -Wdev should enable deprecated warnings as well +set(RunCMake_TEST_OPTIONS -Wdev) +run_cmake(Wdeprecated) +unset(RunCMake_TEST_OPTIONS) + +# -Werror=dev should enable deprecated errors as well +set(RunCMake_TEST_OPTIONS -Werror=dev) +run_cmake(Werror_deprecated) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS -Wdeprecated) +run_cmake(Wdeprecated) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS -Wno-deprecated) +run_cmake(Wno-deprecated) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS -Werror=deprecated) +run_cmake(Werror_deprecated) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS -Wno-error=deprecated) +run_cmake(Wno-error_deprecated) +unset(RunCMake_TEST_OPTIONS) + +# Dev warnings should be on by default +run_cmake(Wdev) + +# Deprecated warnings should be on by default +run_cmake(Wdeprecated) + +# Conflicting -W options should honor the last value +set(RunCMake_TEST_OPTIONS -Wdev -Wno-dev) +run_cmake(Wno-dev) +unset(RunCMake_TEST_OPTIONS) + +run_cmake_command(W_bad-arg1 ${CMAKE_COMMAND} -W) +run_cmake_command(W_bad-arg2 ${CMAKE_COMMAND} -Wno-) +run_cmake_command(W_bad-arg3 ${CMAKE_COMMAND} -Werror=) + set(RunCMake_TEST_OPTIONS --debug-output) run_cmake(debug-output) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/CommandLine/W_bad-arg1-result.txt b/Tests/RunCMake/CommandLine/W_bad-arg1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/W_bad-arg1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/W_bad-arg1-stderr.txt b/Tests/RunCMake/CommandLine/W_bad-arg1-stderr.txt new file mode 100644 index 0000000..e912728 --- /dev/null +++ b/Tests/RunCMake/CommandLine/W_bad-arg1-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: -W must be followed with \[no-\]\[error=\]<name>. +CMake Error: Problem processing arguments. Aborting. diff --git a/Tests/RunCMake/CommandLine/W_bad-arg2-result.txt b/Tests/RunCMake/CommandLine/W_bad-arg2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/W_bad-arg2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/W_bad-arg2-stderr.txt b/Tests/RunCMake/CommandLine/W_bad-arg2-stderr.txt new file mode 100644 index 0000000..cc643df --- /dev/null +++ b/Tests/RunCMake/CommandLine/W_bad-arg2-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: No warning name provided. +CMake Error: Problem processing arguments. Aborting. diff --git a/Tests/RunCMake/CommandLine/W_bad-arg3-result.txt b/Tests/RunCMake/CommandLine/W_bad-arg3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/W_bad-arg3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/W_bad-arg3-stderr.txt b/Tests/RunCMake/CommandLine/W_bad-arg3-stderr.txt new file mode 100644 index 0000000..cc643df --- /dev/null +++ b/Tests/RunCMake/CommandLine/W_bad-arg3-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: No warning name provided. +CMake Error: Problem processing arguments. Aborting. diff --git a/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt b/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt new file mode 100644 index 0000000..e9be1dc --- /dev/null +++ b/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt @@ -0,0 +1,4 @@ +^CMake Deprecation Warning at Wdeprecated.cmake:1 \(message\): + Some deprecated warning +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CommandLine/Wdeprecated.cmake b/Tests/RunCMake/CommandLine/Wdeprecated.cmake new file mode 100644 index 0000000..3142b42 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Wdeprecated.cmake @@ -0,0 +1 @@ +message(DEPRECATION "Some deprecated warning") diff --git a/Tests/RunCMake/CommandLine/Wdev-stderr.txt b/Tests/RunCMake/CommandLine/Wdev-stderr.txt index 92c1d23..88cfb3a 100644 --- a/Tests/RunCMake/CommandLine/Wdev-stderr.txt +++ b/Tests/RunCMake/CommandLine/Wdev-stderr.txt @@ -1,5 +1,5 @@ ^CMake Warning \(dev\) at Wdev.cmake:1 \(message\): - Some Author Warning + Some author warning Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CommandLine/Wdev.cmake b/Tests/RunCMake/CommandLine/Wdev.cmake index e5026ef..756f31e 100644 --- a/Tests/RunCMake/CommandLine/Wdev.cmake +++ b/Tests/RunCMake/CommandLine/Wdev.cmake @@ -1,4 +1,4 @@ -message(AUTHOR_WARNING "Some Author Warning") +message(AUTHOR_WARNING "Some author warning") # with -Wdev this will also cause an AUTHOR_WARNING message, checks that # messages issued outside of the message command, by other CMake commands, also diff --git a/Tests/RunCMake/CommandLine/Werror_deprecated-result.txt b/Tests/RunCMake/CommandLine/Werror_deprecated-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Werror_deprecated-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt b/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt new file mode 100644 index 0000000..6acdc73 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt @@ -0,0 +1,4 @@ +^CMake Deprecation Error at Werror_deprecated.cmake:1 \(message\): + Some deprecated warning +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CommandLine/Werror_deprecated.cmake b/Tests/RunCMake/CommandLine/Werror_deprecated.cmake new file mode 100644 index 0000000..3142b42 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Werror_deprecated.cmake @@ -0,0 +1 @@ +message(DEPRECATION "Some deprecated warning") diff --git a/Tests/RunCMake/CommandLine/Werror_dev-result.txt b/Tests/RunCMake/CommandLine/Werror_dev-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/Werror_dev-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt b/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt new file mode 100644 index 0000000..c6b4e74 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error \(dev\) at Werror_dev.cmake:1 \(message\): + Some author warning +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This error is for project developers. Use -Wno-error=dev to suppress it.$ diff --git a/Tests/RunCMake/CommandLine/Werror_dev.cmake b/Tests/RunCMake/CommandLine/Werror_dev.cmake new file mode 100644 index 0000000..e05cf9d --- /dev/null +++ b/Tests/RunCMake/CommandLine/Werror_dev.cmake @@ -0,0 +1 @@ +message(AUTHOR_WARNING "Some author warning") diff --git a/Tests/RunCMake/CommandLine/Wno-deprecated.cmake b/Tests/RunCMake/CommandLine/Wno-deprecated.cmake new file mode 100644 index 0000000..3142b42 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Wno-deprecated.cmake @@ -0,0 +1 @@ +message(DEPRECATION "Some deprecated warning") diff --git a/Tests/RunCMake/CommandLine/Wno-dev.cmake b/Tests/RunCMake/CommandLine/Wno-dev.cmake index d81b858..802b435 100644 --- a/Tests/RunCMake/CommandLine/Wno-dev.cmake +++ b/Tests/RunCMake/CommandLine/Wno-dev.cmake @@ -1,4 +1,4 @@ -message(AUTHOR_WARNING "Some Author Warning") +message(AUTHOR_WARNING "Some author warning") # without -Wno-dev this will also cause an AUTHOR_WARNING message, checks that # messages issued outside of the message command, by other CMake commands, also diff --git a/Tests/RunCMake/CommandLine/Wno-error_deprecated.cmake b/Tests/RunCMake/CommandLine/Wno-error_deprecated.cmake new file mode 100644 index 0000000..676792a --- /dev/null +++ b/Tests/RunCMake/CommandLine/Wno-error_deprecated.cmake @@ -0,0 +1,2 @@ +# This should still produce a warning when -Wno-error=deprecated is specified +message(DEPRECATION "Some deprecated warning") diff --git a/Tests/RunCMake/CommandLine/Wno-error_dev.cmake b/Tests/RunCMake/CommandLine/Wno-error_dev.cmake new file mode 100644 index 0000000..d43e4ed --- /dev/null +++ b/Tests/RunCMake/CommandLine/Wno-error_dev.cmake @@ -0,0 +1,2 @@ +# This should still produce a warning when -Wno-error=dev is specified +message(AUTHOR_WARNING "Some author warning") -- 2.1.4
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers