message(): select default mode through a variable
In my experience, I have invoked the message()
command for general messages with mode STATUS 95% of the time. Emitting many messages might get verbose as the project grows.
I think it would be nice to have a variable, say CMAKE_MESSAGE_DEFAULT_MODE
, to specify the default mode for the subsequent message()
calls not providing an explicit mode. Since currently the mode is optional (corresponding to NOTICE
), the new variable could be empty by default for backwards compatibility. The message()
command could default to empty mode if the new variable is set to an invalid mode.
Example:
message("This message is emitted as NOTICE")
message(WARNING "This message is emitted as WARNING")
set(CMAKE_MESSAGE_DEFAULT_MODE "STATUS")
message("This message is emitted as STATUS")
message(WARNING "This message is emitted as WARNING")
set(CMAKE_MESSAGE_DEFAULT_MODE "NOT_VALID")
message("This message is emitted as NOTICE")