# Get verbosity from within CMake scripts?

**URL:** https://discourse.cmake.org/t/get-verbosity-from-within-cmake-scripts/5392
**Category:** Usage
**Created:** [April 7, 2022, 1:37am UTC](https://discourse.cmake.org/t/get-verbosity-from-within-cmake-scripts/5392 "2022-04-07T01:37:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [April 7, 2022, 1:37am UTC](https://discourse.cmake.org/t/get-verbosity-from-within-cmake-scripts/5392/1 "2022-04-07T01:37:31Z")

</div>

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`?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [April 7, 2022, 10:24pm UTC](https://discourse.cmake.org/t/get-verbosity-from-within-cmake-scripts/5392/2 "2022-04-07T22:24:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [April 7, 2022, 10:28pm UTC](https://discourse.cmake.org/t/get-verbosity-from-within-cmake-scripts/5392/3 "2022-04-07T22:28:41Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![sgilbert](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/58956e/32.png) [@sgilbert](https://discourse.cmake.org/u/sgilbert)
#### Post date: [October 1, 2024, 6:32pm UTC](https://discourse.cmake.org/t/get-verbosity-from-within-cmake-scripts/5392/4 "2024-10-01T18:32:49Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [October 1, 2024, 10:23pm UTC](https://discourse.cmake.org/t/get-verbosity-from-within-cmake-scripts/5392/5 "2024-10-01T22:23:41Z")

</div>

With CMake 3.25 and later, you can now obtain the current effective message log level using [`cmake_language(GET_MESSAGE_LOG_LEVEL)`](https://cmake.org/cmake/help/latest/command/cmake_language.html#get-message-log-level).
