Question about unclear behavior with a list

Hello,

[cmake version 3.24.3 on Debian Bullseye]

  1. With a minimal CMakeLists.txt:
    cmake_minimum_required(VERSION 3.24)
    project(cmake_test C)

mkdir build && cd build && cmake .. gives:

-- The C compiler identification is GNU 10.2.1
-- [...]
-- Configuring done
-- Generating done
  1. With CMakeLists.txt:
function(message)
     list(GET ARGV 0 MessageType)
     list(REMOVE_AT ARGV 0)
     _message(${MessageType} "${ARGV}")
endfunction()

cmake_minimum_required(VERSION 3.24)
project(cmake_test C)

(Part of build - tell cmake to be quiet - Stack Overflow second answer)

mkdir build && cd build && cmake .. gives:

-- The C compiler identification is ;GNU 10.2.1
                                    ^-------------- additional semicolon here
-- [...]
-- Configuring done
-- Generating done

Why this additional semicolon?
Did I miss something?

You quoted ${ARGV} which means that it renders as a single ;-separated list of strings instead of the standard behavior of “simply concat all arguments”.

Thank you for your solution!

Regarding overriding the built-in message() command, see Do Note Redefine CMake Commands.

CMake 3.15 added the ability to control log verbosity. You can use the --log-level=<mode> command line option to cmake, where only messages of <mode> level or higher will be logged. The option was called --loglevel in 3.15, but it was renamed to --log-level in 3.16 to make it consistent with other options.

CMake 3.17 added support for the CMAKE_MESSAGE_LOG_LEVEL variable. It can be used to locally change the logging level in a part of a project (useful just before pulling in a noisy third-party dependency, for example).

Regarding overriding the built-in message() command, see Do Note Redefine CMake Commands.

CMake 3.15 added the ability to control log verbosity. You can use the --log-level=<mode> command line option to cmake, where only messages of <mode> level or higher will be logged. The option was called --loglevel in 3.15, but it was renamed to --log-level in 3.16 to make it consistent with other options.

CMake 3.17 added support for the CMAKE_MESSAGE_LOG_LEVEL variable. It can be used to locally change the logging level in a part of a project (useful just before pulling in a noisy third-party dependency, for example).

This detailed information is useful, thank you.