Skip to content

[bug] CMakeConfigDeps ignores find_package's QUIET, CMakeDeps doesn't #20272

Description

@vilchanskyio-work

Describe the bug

CMakeConfigDeps hardcodes the message verbosity level (conan/tools/cmake/cmakeconfigdeps/target_configuration.py):

message(STATUS "Conan: Target declared imported {{lib_info["type"]}} library '{{lib}}'")

, while CMakeDeps respects the QUIET specifier to find_package (conan/tools/cmake/cmakedeps/templates/config.py):

if({{ file_name }}_FIND_QUIETLY)
    set({{ file_name }}_MESSAGE_MODE VERBOSE)
else()
    set({{ file_name }}_MESSAGE_MODE STATUS)

Current workaround is to write a wrapper to temporarily set the cmake log level manually.

Why this is needed: abseil defines about a hundred targets which results in a huge amount of spam (try the repo below).

Environment: Conan 2.31.1, CMake 3.31, Linux.

If you'd like, I can try and submit a PR. I treat it as a bug since CMakeDeps behaves like that, but may as well be a feature request depending on how you interpret it.

How to reproduce it

cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.27)
project(m LANGUAGES CXX)
find_package(absl REQUIRED QUIET)
EOF

conan install --requires=abseil/20250814.1 -g CMakeConfigDeps -of=cnn --build=missing

cmake -B b \
    -DCMAKE_PREFIX_PATH="$PWD/cnn" \
    -DCMAKE_BUILD_TYPE=Release \
    | grep -c 'Target declared'

Metadata

Metadata

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions