Skip to content

[bug] CMakeToolchain/CMakeDeps generates CMake warnings when dependency was already found via find_package #10132

Description

@n-morales

Environment Details (include every applicable attribute)

  • Operating System+version: Linux Mint 20.1 Ulyssa
  • Compiler+version: gcc 11.1.0
  • Conan version: 1.43.0
  • Python version: 3.8.10

Steps to reproduce (Include if Applicable)

Use the CMakeToolchain and CMakeDeps generator.
Use the generated conan_toolchain.cmake file then find_package for a dependency and then find_package for a transitive dependency. E.g.

find_package(PNG 1.6 REQUIRED)
find_package(Freetype 2.10 REQUIRED)

In this example, Freetype depends on PNG.

This could possibly be avoided by omitting the find_package for PNG (in this case), but that's not a good solution in case the consumer depends on PNG (or other transitively dependent library) and can't depend on the library being included transitively.

Also, adding QUIET to the find_package calls does not suppress the warning because they are emitted directly via message(WARNING) and so cannot be suppressed with that flag.

Logs (Executed commands with output) (Include/Attach if Applicable)

CMake Warning at cmake-build-debug/zlibTargets.cmake:24 (message):
  Target name 'zlib::zlib' already exists.
Call Stack (most recent call first):
  cmake-build-debug/zlib-config.cmake:11 (include)
  [omitted path to cmake]/cmake-3.21/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  cmake-build-debug/libpng-config.cmake:16 (find_dependency)
  [omitted path to cmake]/cmake-3.21/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  cmake-build-debug/freetype-config.cmake:16 (find_dependency)
  CMakeLists.txt:83 (find_package)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions