ENH: Add SEND_ERROR flag to MESSAGE so that an error can be raised within a CMakeList file

This commit is contained in:
Sebastien Barre 2002-03-29 10:56:07 -05:00
parent 61697fab50
commit b6ebd7b7fa
2 changed files with 21 additions and 3 deletions

View File

@ -25,13 +25,31 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args)
this->SetError("called with incorrect number of arguments"); this->SetError("called with incorrect number of arguments");
return false; return false;
} }
std::string message; std::string message;
std::vector<std::string>::const_iterator i = args.begin(); std::vector<std::string>::const_iterator i = args.begin();
bool send_error = false;
if (*i == "SEND_ERROR")
{
send_error = true;
++i;
}
for(;i != args.end(); ++i) for(;i != args.end(); ++i)
{ {
message += *i; message += *i;
} }
if (send_error)
{
cmSystemTools::Error(message.c_str());
}
else
{
cmSystemTools::Message(message.c_str()); cmSystemTools::Message(message.c_str());
}
return true; return true;
} }

View File

@ -60,8 +60,8 @@ public:
virtual const char* GetFullDocumentation() virtual const char* GetFullDocumentation()
{ {
return return
"MESSAGE(\"the message to display\" \"Title for dialog\")\n" "MESSAGE([SEND_ERROR] \"message to display\"...)\n"
"The first argument is the message to display. The second argument is optional and is the title for the dialog box on windows."; "The arguments are messages to display. If the first argument is SEND_ERROR then an error is raised.";
} }
cmTypeMacro(cmMessageCommand, cmCommand); cmTypeMacro(cmMessageCommand, cmCommand);