Skip to content

Draft: Reflect --log-level value in CMAKE_MESSAGE_LOG_LEVEL non-cache var

alcroito requested to merge alcroito/cmake:consistent_log_level into master

Previously the CMAKE_MESSAGE_LOG_LEVEL variable was unset if the --log-level option was specified on the command line, which made it impossible to query what is the current log level.

Assign the --log-level value to a global non-cache CMAKE_MESSAGE_LOG_LEVEL variable which can be queried anywhere in the project.

If both --log-level and the CMAKE_MESSAGE_LOG_LEVEL cache var are set, the log-level takes precedence.

If neither --log-level nor the CMAKE_MESSAGE_LOG_LEVEL cache var are set, report the default log level (STATUS).

This means CMAKE_MESSAGE_LOG_LEVEL will always have a value now.

The priority is --log-level > cache > default (STATUS)

The new behavior also applies to script mode.

Fixes: #23572 (closed)

Edited by alcroito

Merge request reports