Merge topic 'messenger-no-cmstate-v2'

8a803d784b cmMessenger: Decouple from cmState

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2653
This commit is contained in:
Craig Scott
2019-01-02 20:28:14 +00:00
committed by Kitware Robot
3 changed files with 61 additions and 44 deletions

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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