diff options
author | Craig Scott <craig.scott@crascit.com> | 2019-01-02 20:28:14 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-01-02 20:31:39 (GMT) |
commit | 124a8632cbdb88be8e9768a83ddb63790d5bf60f (patch) | |
tree | 67e5fe33c183be06b2fa3477308204ff69421d57 | |
parent | 88f1e79f3e8076bd57d9ae54037fd05f655c2960 (diff) | |
parent | 8a803d784bf65d2c8556eb1e6b6134b878e89c79 (diff) | |
download | CMake-124a8632cbdb88be8e9768a83ddb63790d5bf60f.zip CMake-124a8632cbdb88be8e9768a83ddb63790d5bf60f.tar.gz CMake-124a8632cbdb88be8e9768a83ddb63790d5bf60f.tar.bz2 |
Merge topic 'messenger-no-cmstate-v2'
8a803d784b cmMessenger: Decouple from cmState
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2653
-rw-r--r-- | Source/cmMessenger.cxx | 34 | ||||
-rw-r--r-- | Source/cmMessenger.h | 40 | ||||
-rw-r--r-- | Source/cmake.cxx | 31 |
3 files changed, 61 insertions, 44 deletions
diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx index a81428a..880cf4b 100644 --- a/Source/cmMessenger.cxx +++ b/Source/cmMessenger.cxx @@ -4,7 +4,6 @@ #include "cmAlgorithms.h" #include "cmDocumentationFormatter.h" -#include "cmState.h" #include "cmSystemTools.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -131,11 +130,6 @@ void displayMessage(cmake::MessageType t, std::ostringstream& msg) } } -cmMessenger::cmMessenger(cmState* state) - : State(state) -{ -} - void cmMessenger::IssueMessage(cmake::MessageType t, const std::string& text, const cmListFileBacktrace& backtrace) const { @@ -173,31 +167,3 @@ void cmMessenger::DisplayMessage(cmake::MessageType t, const std::string& text, displayMessage(t, msg); } - -bool cmMessenger::GetSuppressDevWarnings() const -{ - const char* cacheEntryValue = - this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); - return cmSystemTools::IsOn(cacheEntryValue); -} - -bool cmMessenger::GetSuppressDeprecatedWarnings() const -{ - const char* cacheEntryValue = - this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED"); - return cacheEntryValue && cmSystemTools::IsOff(cacheEntryValue); -} - -bool cmMessenger::GetDevWarningsAsErrors() const -{ - const char* cacheEntryValue = - this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS"); - return cacheEntryValue && cmSystemTools::IsOff(cacheEntryValue); -} - -bool cmMessenger::GetDeprecatedWarningsAsErrors() const -{ - const char* cacheEntryValue = - this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED"); - return cmSystemTools::IsOn(cacheEntryValue); -} diff --git a/Source/cmMessenger.h b/Source/cmMessenger.h index 4aafbd4..e947eaa 100644 --- a/Source/cmMessenger.h +++ b/Source/cmMessenger.h @@ -10,13 +10,9 @@ #include <string> -class cmState; - class cmMessenger { public: - cmMessenger(cmState* state); - void IssueMessage( cmake::MessageType t, std::string const& text, cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const; @@ -24,16 +20,42 @@ public: void DisplayMessage(cmake::MessageType t, std::string const& text, cmListFileBacktrace const& backtrace) const; - bool GetSuppressDevWarnings() const; - bool GetSuppressDeprecatedWarnings() const; - bool GetDevWarningsAsErrors() const; - bool GetDeprecatedWarningsAsErrors() const; + void SetSuppressDevWarnings(bool suppress) + { + this->SuppressDevWarnings = suppress; + } + void SetSuppressDeprecatedWarnings(bool suppress) + { + this->SuppressDeprecatedWarnings = suppress; + } + void SetDevWarningsAsErrors(bool error) + { + this->DevWarningsAsErrors = error; + } + void SetDeprecatedWarningsAsErrors(bool error) + { + this->DeprecatedWarningsAsErrors = error; + } + + bool GetSuppressDevWarnings() const { return this->SuppressDevWarnings; } + bool GetSuppressDeprecatedWarnings() const + { + return this->SuppressDeprecatedWarnings; + } + bool GetDevWarningsAsErrors() const { return this->DevWarningsAsErrors; } + bool GetDeprecatedWarningsAsErrors() const + { + return this->DeprecatedWarningsAsErrors; + } private: bool IsMessageTypeVisible(cmake::MessageType t) const; cmake::MessageType ConvertMessageType(cmake::MessageType t) const; - cmState* State; + bool SuppressDevWarnings = false; + bool SuppressDeprecatedWarnings = false; + bool DevWarningsAsErrors = false; + bool DeprecatedWarningsAsErrors = false; }; #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index e81d14b..1bc36cc 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -141,7 +141,7 @@ cmake::cmake(Role role) this->State = new cmState; this->CurrentSnapshot = this->State->CreateBaseSnapshot(); - this->Messenger = new cmMessenger(this->State); + this->Messenger = new cmMessenger; #ifdef __APPLE__ struct rlimit rlp; @@ -1300,6 +1300,23 @@ int cmake::Configure() } } + // Cache variables may have already been set by a previous invocation, + // so we cannot rely on command line options alone. Always ensure our + // messenger is in sync with the cache. + const char* value = this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED"); + this->Messenger->SetSuppressDeprecatedWarnings(value && + cmSystemTools::IsOff(value)); + + value = this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED"); + this->Messenger->SetDeprecatedWarningsAsErrors(cmSystemTools::IsOn(value)); + + value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); + this->Messenger->SetSuppressDevWarnings(cmSystemTools::IsOn(value)); + + value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS"); + this->Messenger->SetDevWarningsAsErrors(value && + cmSystemTools::IsOff(value)); + int ret = this->ActualConfigure(); const char* delCacheVars = this->State->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_"); @@ -1701,6 +1718,18 @@ void cmake::AddCacheEntry(const std::string& key, const char* value, this->State->AddCacheEntry(key, value, helpString, cmStateEnums::CacheEntryType(type)); this->UnwatchUnusedCli(key); + + if (key == "CMAKE_WARN_DEPRECATED") { + this->Messenger->SetSuppressDeprecatedWarnings( + value && cmSystemTools::IsOff(value)); + } else if (key == "CMAKE_ERROR_DEPRECATED") { + this->Messenger->SetDeprecatedWarningsAsErrors(cmSystemTools::IsOn(value)); + } else if (key == "CMAKE_SUPPRESS_DEVELOPER_WARNINGS") { + this->Messenger->SetSuppressDevWarnings(cmSystemTools::IsOn(value)); + } else if (key == "CMAKE_SUPPRESS_DEVELOPER_ERRORS") { + this->Messenger->SetDevWarningsAsErrors(value && + cmSystemTools::IsOff(value)); + } } bool cmake::DoWriteGlobVerifyTarget() const |