ENH: Teach message() how to display warnings
This adds message(WARNING) and message(AUTHOR_WARNING) command modes and fully documents the command behavior in all modes.
This commit is contained in:
parent
62702551db
commit
ca3b93d9c6
@ -28,29 +28,27 @@ bool cmMessageCommand
|
|||||||
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;
|
cmake::MessageType type = cmake::MESSAGE;
|
||||||
bool fatal_error = false;
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
if (*i == "SEND_ERROR")
|
if (*i == "SEND_ERROR" || *i == "FATAL_ERROR")
|
||||||
{
|
{
|
||||||
send_error = true;
|
type = cmake::FATAL_ERROR;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
else
|
else if (*i == "WARNING")
|
||||||
{
|
{
|
||||||
if (*i == "STATUS")
|
type = cmake::WARNING;
|
||||||
{
|
++i;
|
||||||
status = true;
|
}
|
||||||
++i;
|
else if (*i == "AUTHOR_WARNING")
|
||||||
}
|
{
|
||||||
else
|
type = cmake::AUTHOR_WARNING;
|
||||||
{
|
++i;
|
||||||
if (*i == "FATAL_ERROR")
|
}
|
||||||
{
|
else if (*i == "STATUS")
|
||||||
fatal_error = true;
|
{
|
||||||
++i;
|
status = true;
|
||||||
}
|
++i;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(;i != args.end(); ++i)
|
for(;i != args.end(); ++i)
|
||||||
@ -58,9 +56,9 @@ bool cmMessageCommand
|
|||||||
message += *i;
|
message += *i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_error || fatal_error)
|
if (type != cmake::MESSAGE)
|
||||||
{
|
{
|
||||||
this->Makefile->IssueMessage(cmake::FATAL_ERROR, message.c_str());
|
this->Makefile->IssueMessage(type, message.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -73,10 +71,6 @@ bool cmMessageCommand
|
|||||||
cmSystemTools::Message(message.c_str());
|
cmSystemTools::Message(message.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fatal_error )
|
|
||||||
{
|
|
||||||
cmSystemTools::SetFatalErrorOccured();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,16 +65,28 @@ public:
|
|||||||
virtual const char* GetFullDocumentation()
|
virtual const char* GetFullDocumentation()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
" message([SEND_ERROR | STATUS | FATAL_ERROR]\n"
|
" message([STATUS|WARNING|AUTHOR_WARNING|FATAL_ERROR|SEND_ERROR]\n"
|
||||||
" \"message to display\" ...)\n"
|
" \"message to display\" ...)\n"
|
||||||
"By default the message is displayed in a pop up window (CMakeSetup), "
|
"The optional keyword determines the type of message:\n"
|
||||||
"or in the stdout of cmake, or the error section of ccmake. "
|
" (none) = Important information\n"
|
||||||
"If the first argument is "
|
" STATUS = Incidental information\n"
|
||||||
"SEND_ERROR then an error is raised, and the generate phase will "
|
" WARNING = CMake Warning, continue processing\n"
|
||||||
"be skipped. If the first argument is FATAL_ERROR, all processing "
|
" AUTHOR_WARNING = CMake Warning (dev), continue processing\n"
|
||||||
"is halted. If the first argument is STATUS then the message is "
|
" FATAL_ERROR = CMake Error, stop all processing\n"
|
||||||
"displayed in the progress line for the GUI, or with a -- in the "
|
" SEND_ERROR = CMake Error, stop all processing (legacy)\n"
|
||||||
"command line cmake.";
|
"The CMake command-line tool displays STATUS messages on stdout "
|
||||||
|
"and all other message types on stderr. "
|
||||||
|
"The CMake GUI displays all messages in its log area. "
|
||||||
|
"The interactive dialogs (ccmake and CMakeSetup) show STATUS messages "
|
||||||
|
"one at a time on a status line and other messages in interactive "
|
||||||
|
"pop-up boxes."
|
||||||
|
"\n"
|
||||||
|
"CMake Warning and Error message text displays using a simple "
|
||||||
|
"markup language. "
|
||||||
|
"Non-indented text is formatted in line-wrapped paragraphs delimited "
|
||||||
|
"by newlines. "
|
||||||
|
"Indented text is considered pre-formatted."
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTypeMacro(cmMessageCommand, cmCommand);
|
cmTypeMacro(cmMessageCommand, cmCommand);
|
||||||
|
@ -16,6 +16,7 @@ AddCMakeTest(FindBase "")
|
|||||||
AddCMakeTest(Toolchain "")
|
AddCMakeTest(Toolchain "")
|
||||||
AddCMakeTest(GetFilenameComponentRealpath "")
|
AddCMakeTest(GetFilenameComponentRealpath "")
|
||||||
AddCMakeTest(Version "")
|
AddCMakeTest(Version "")
|
||||||
|
AddCMakeTest(Message "")
|
||||||
|
|
||||||
SET(GetPrerequisites_PreArgs
|
SET(GetPrerequisites_PreArgs
|
||||||
"-DCTEST_CONFIGURATION_TYPE:STRING=\\\${CTEST_CONFIGURATION_TYPE}"
|
"-DCTEST_CONFIGURATION_TYPE:STRING=\\\${CTEST_CONFIGURATION_TYPE}"
|
||||||
|
30
Tests/CMakeTests/MessageTest.cmake.in
Normal file
30
Tests/CMakeTests/MessageTest.cmake.in
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
execute_process(
|
||||||
|
COMMAND ${CMAKE_COMMAND} -P
|
||||||
|
"@CMAKE_CURRENT_SOURCE_DIR@/MessageTestScript.cmake"
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_VARIABLE err
|
||||||
|
RESULT_VARIABLE result
|
||||||
|
)
|
||||||
|
|
||||||
|
message("out=[${out}]")
|
||||||
|
message("err=[${err}]")
|
||||||
|
|
||||||
|
if(NOT "${result}" STREQUAL "0")
|
||||||
|
message(FATAL_ERROR "message script failed: [${result}]")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT "${out}" MATCHES "message-status")
|
||||||
|
message(FATAL_ERROR "message(STATUS) did not go to stdout")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT "${err}" MATCHES "message-default")
|
||||||
|
message(FATAL_ERROR "message() did not go to stderr by default")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT "${err}" MATCHES "CMake Warning at[^\n]*:\r?\n message-warning")
|
||||||
|
message(FATAL_ERROR "message(WARNING) did not appear properly")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT "${err}" MATCHES "CMake Warning \\(dev\\) at[^\n]*:\r?\n message-author")
|
||||||
|
message(FATAL_ERROR "message(AUTHOR_WARNING) did not appear properly")
|
||||||
|
endif()
|
4
Tests/CMakeTests/MessageTestScript.cmake
Normal file
4
Tests/CMakeTests/MessageTestScript.cmake
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
message("message-default")
|
||||||
|
message(STATUS "message-status")
|
||||||
|
message(WARNING "message-warning")
|
||||||
|
message(AUTHOR_WARNING "message-author")
|
Loading…
Reference in New Issue
Block a user