cmake/Source/cmMessageCommand.cxx

81 lines
2.3 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMessageCommand.h"
2017-04-14 19:02:05 +02:00
#include "cmAlgorithms.h"
#include "cmMakefile.h"
2016-10-30 18:24:19 +01:00
#include "cmMessenger.h"
2017-04-14 19:02:05 +02:00
#include "cmSystemTools.h"
#include "cmake.h"
class cmExecutionStatus;
2016-10-30 18:24:19 +01:00
// cmLibraryCommand
2016-07-09 11:21:54 +02:00
bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
2016-10-30 18:24:19 +01:00
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
2016-07-09 11:21:54 +02:00
}
std::vector<std::string>::const_iterator i = args.begin();
2009-10-04 10:30:41 +03:00
cmake::MessageType type = cmake::MESSAGE;
bool status = false;
2009-10-04 10:30:41 +03:00
bool fatal = false;
2016-07-09 11:21:54 +02:00
if (*i == "SEND_ERROR") {
2009-10-04 10:30:41 +03:00
type = cmake::FATAL_ERROR;
++i;
2016-07-09 11:21:54 +02:00
} else if (*i == "FATAL_ERROR") {
2009-10-04 10:30:41 +03:00
fatal = true;
type = cmake::FATAL_ERROR;
++i;
2016-07-09 11:21:54 +02:00
} else if (*i == "WARNING") {
2009-10-04 10:30:41 +03:00
type = cmake::WARNING;
++i;
2016-07-09 11:21:54 +02:00
} else if (*i == "AUTHOR_WARNING") {
2016-10-30 18:24:19 +01:00
if (this->Makefile->IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") &&
!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) {
2016-03-13 13:35:51 +01:00
fatal = true;
type = cmake::AUTHOR_ERROR;
2016-10-30 18:24:19 +01:00
} else if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
2016-03-13 13:35:51 +01:00
type = cmake::AUTHOR_WARNING;
2016-07-09 11:21:54 +02:00
} else {
2016-03-13 13:35:51 +01:00
return true;
2009-10-04 10:30:41 +03:00
}
2016-07-09 11:21:54 +02:00
++i;
} else if (*i == "STATUS") {
2009-10-04 10:30:41 +03:00
status = true;
++i;
2016-07-09 11:21:54 +02:00
} else if (*i == "DEPRECATION") {
2016-10-30 18:24:19 +01:00
if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED")) {
2014-08-03 19:52:23 +02:00
fatal = true;
type = cmake::DEPRECATION_ERROR;
2016-10-30 18:24:19 +01:00
} else if ((!this->Makefile->IsSet("CMAKE_WARN_DEPRECATED") ||
this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))) {
2014-08-03 19:52:23 +02:00
type = cmake::DEPRECATION_WARNING;
2016-07-09 11:21:54 +02:00
} else {
2014-08-03 19:52:23 +02:00
return true;
}
2016-07-09 11:21:54 +02:00
++i;
}
2015-11-17 17:22:37 +01:00
std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
2016-07-09 11:21:54 +02:00
if (type != cmake::MESSAGE) {
2016-10-30 18:24:19 +01:00
// we've overriden the message type, above, so display it directly
cmMessenger* m = this->Makefile->GetMessenger();
m->DisplayMessage(type, message, this->Makefile->GetBacktrace());
2016-07-09 11:21:54 +02:00
} else {
if (status) {
this->Makefile->DisplayStatus(message.c_str(), -1);
2016-07-09 11:21:54 +02:00
} else {
cmSystemTools::Message(message.c_str());
}
2016-07-09 11:21:54 +02:00
}
if (fatal) {
cmSystemTools::SetFatalErrorOccured();
2016-07-09 11:21:54 +02:00
}
return true;
}