Get verbosity from within CMake scripts?

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.