Is it possible to tell what verbosity level was passed to cmake with the command-line --log-level
option?
I’m aware of the CMAKE_MESSAGE_LOG_LEVEL
variable, I had assumed that it would be set to the value of the --log-level
option from the command line, but that doesn’t appear to be the case. Is there any other way to get the verbosity level that was set via --log-level
?
Not that I’m aware of (and I was involved in the development/reviewing of the related features). I too have sometimes wanted the capability you describe. I don’t know if there would be side effects for making --log-level
set CMAKE_MESSAGE_LOG_LEVEL
if it wasn’t already set. Someone would need to explore the code and see if that would be safe to do.
1 Like
it could be a policy?
Even if a new variable were introduced, I think that being able to detect the verbosity level specified with --log-level
would be very useful.
Given how other things work in CMake, I really expected the --log-level
command line argument to set the CMAKE_MESSAGE_LOG_LEVEL
variable.
It would be really useful. In one of my projects, I have a custom target that calls cmake
to generate a header file which contains build information that is updated whenever make
is invoked. If the log level was set in a variable, I could add it to the command line of my custom target and have debugging info for the sub-cmake when requested at the top-level command line.
With CMake 3.25 and later, you can now obtain the current effective message log level using cmake_language(GET_MESSAGE_LOG_LEVEL)
.
1 Like