diff options
author | Marius Messerschmidt <marius.messerschmidt@googlemail.com> | 2021-05-18 21:32:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-20 11:38:45 (GMT) |
commit | 0a0a0f8a744e2bfa35cdbc90db6e4e23adadd59b (patch) | |
tree | 5c8aff122dce421ae24d56d221b77d39658b0c36 /Source/cmMessenger.cxx | |
parent | bceb8e2ed23340a90d2093e05d50f0cc797f6432 (diff) | |
download | CMake-0a0a0f8a744e2bfa35cdbc90db6e4e23adadd59b.zip CMake-0a0a0f8a744e2bfa35cdbc90db6e4e23adadd59b.tar.gz CMake-0a0a0f8a744e2bfa35cdbc90db6e4e23adadd59b.tar.bz2 |
cmMessenger: Color messages to terminal by type
Fixes: #16183
Diffstat (limited to 'Source/cmMessenger.cxx')
-rw-r--r-- | Source/cmMessenger.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx index 4c0faa9..1cb638a 100644 --- a/Source/cmMessenger.cxx +++ b/Source/cmMessenger.cxx @@ -13,6 +13,8 @@ #include <sstream> +#include "cmsys/Terminal.h" + MessageType cmMessenger::ConvertMessageType(MessageType t) const { bool warningsAsErrors; @@ -85,6 +87,21 @@ static bool printMessagePreamble(MessageType t, std::ostream& msg) return true; } +static int getMessageColor(MessageType t) +{ + switch (t) { + case MessageType::INTERNAL_ERROR: + case MessageType::FATAL_ERROR: + case MessageType::AUTHOR_ERROR: + return cmsysTerminal_Color_ForegroundRed; + case MessageType::AUTHOR_WARNING: + case MessageType::WARNING: + return cmsysTerminal_Color_ForegroundYellow; + default: + return cmsysTerminal_Color_Normal; + } +} + void printMessageText(std::ostream& msg, std::string const& text) { msg << ":\n"; @@ -122,6 +139,7 @@ void displayMessage(MessageType t, std::ostringstream& msg) // Output the message. cmMessageMetadata md; + md.desiredColor = getMessageColor(t); if (t == MessageType::FATAL_ERROR || t == MessageType::INTERNAL_ERROR || t == MessageType::DEPRECATION_ERROR || t == MessageType::AUTHOR_ERROR) { cmSystemTools::SetErrorOccured(); |