summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorGabor Bencze <b.gabor98@gmail.com>2019-08-04 16:39:45 (GMT)
committerBrad King <brad.king@kitware.com>2019-08-20 18:42:20 (GMT)
commitcfc7854ef07369d6fb614a4483543afaf72a5208 (patch)
treefb8ab8ed163cb4dd52bd6bcef559d03657d43d0a /Source
parent71724633a24fccfdf3d56a19176d8afe637be843 (diff)
downloadCMake-cfc7854ef07369d6fb614a4483543afaf72a5208.zip
CMake-cfc7854ef07369d6fb614a4483543afaf72a5208.tar.gz
CMake-cfc7854ef07369d6fb614a4483543afaf72a5208.tar.bz2
cmCommand refactor: CmMessageCommand
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCommands.cxx2
-rw-r--r--Source/cmMessageCommand.cxx32
-rw-r--r--Source/cmMessageCommand.h26
3 files changed, 20 insertions, 40 deletions
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 68122af..c9a192a 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -149,7 +149,7 @@ void GetScriptingCommands(cmState* state)
state->AddBuiltinCommand("make_directory", cmMakeDirectoryCommand);
state->AddBuiltinCommand("mark_as_advanced", cmMarkAsAdvancedCommand);
state->AddBuiltinCommand("math", cmMathCommand);
- state->AddBuiltinCommand("message", cm::make_unique<cmMessageCommand>());
+ state->AddBuiltinCommand("message", cmMessageCommand);
state->AddBuiltinCommand("option", cm::make_unique<cmOptionCommand>());
state->AddBuiltinCommand("cmake_parse_arguments",
cm::make_unique<cmParseArgumentsCommand>());
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index dec32fa..3f33312 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMessageCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmMessenger.h"
@@ -12,14 +13,12 @@
#include <cassert>
-class cmExecutionStatus;
-
// cmLibraryCommand
-bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmMessageCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
auto i = args.cbegin();
@@ -41,12 +40,13 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
level = cmake::LogLevel::LOG_WARNING;
++i;
} else if (*i == "AUTHOR_WARNING") {
- if (this->Makefile->IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") &&
- !this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) {
+ if (status.GetMakefile().IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") &&
+ !status.GetMakefile().IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) {
fatal = true;
type = MessageType::AUTHOR_ERROR;
level = cmake::LogLevel::LOG_ERROR;
- } else if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
+ } else if (!status.GetMakefile().IsOn(
+ "CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
type = MessageType::AUTHOR_WARNING;
level = cmake::LogLevel::LOG_WARNING;
} else {
@@ -66,12 +66,12 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
level = cmake::LogLevel::LOG_TRACE;
++i;
} else if (*i == "DEPRECATION") {
- if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED")) {
+ if (status.GetMakefile().IsOn("CMAKE_ERROR_DEPRECATED")) {
fatal = true;
type = MessageType::DEPRECATION_ERROR;
level = cmake::LogLevel::LOG_ERROR;
- } else if ((!this->Makefile->IsSet("CMAKE_WARN_DEPRECATED") ||
- this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))) {
+ } else if ((!status.GetMakefile().IsSet("CMAKE_WARN_DEPRECATED") ||
+ status.GetMakefile().IsOn("CMAKE_WARN_DEPRECATED"))) {
type = MessageType::DEPRECATION_WARNING;
level = cmake::LogLevel::LOG_WARNING;
} else {
@@ -89,7 +89,7 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
assert("Message log level expected to be set" &&
level != cmake::LogLevel::LOG_UNDEFINED);
- auto desiredLevel = this->Makefile->GetCMakeInstance()->GetLogLevel();
+ auto desiredLevel = status.GetMakefile().GetCMakeInstance()->GetLogLevel();
assert("Expected a valid log level here" &&
desiredLevel != cmake::LogLevel::LOG_UNDEFINED);
@@ -104,7 +104,7 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
// Check if any indentation has requested:
// `CMAKE_MESSAGE_INDENT` is a list of "padding" pieces
// to be joined and prepended to the message lines.
- auto indent = cmJoin(cmExpandedList(this->Makefile->GetSafeDefinition(
+ auto indent = cmJoin(cmExpandedList(status.GetMakefile().GetSafeDefinition(
"CMAKE_MESSAGE_INDENT")),
"");
// Make every line of the `message` indented
@@ -118,8 +118,8 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
case cmake::LogLevel::LOG_ERROR:
case cmake::LogLevel::LOG_WARNING:
// we've overridden the message type, above, so display it directly
- this->Makefile->GetMessenger()->DisplayMessage(
- type, message, this->Makefile->GetBacktrace());
+ status.GetMakefile().GetMessenger()->DisplayMessage(
+ type, message, status.GetMakefile().GetBacktrace());
break;
case cmake::LogLevel::LOG_NOTICE:
@@ -130,7 +130,7 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
case cmake::LogLevel::LOG_VERBOSE:
case cmake::LogLevel::LOG_DEBUG:
case cmake::LogLevel::LOG_TRACE:
- this->Makefile->DisplayStatus(message, -1);
+ status.GetMakefile().DisplayStatus(message, -1);
break;
default:
diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h
index ef89d59..7d544c4 100644
--- a/Source/cmMessageCommand.h
+++ b/Source/cmMessageCommand.h
@@ -8,33 +8,13 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmMessageCommand
+/**
* \brief Displays a message to the user
*
*/
-class cmMessageCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmMessageCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmMessageCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif