Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[package] eigen3/3.3.9: CMake Warning stating that target name Eigen3::Eigen already exists. #8949

Closed
Lorac opened this issue Jan 17, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Lorac
Copy link
Contributor

Lorac commented Jan 17, 2022

Package and Environment Details (include every applicable attribute)

  • Package Name/Version: eigen/3.3.9#4c35d86148747164763f493d90277d8f
  • Operating System+version: Linux Ubuntu 21.04
  • Compiler+version: GCC 7
  • Docker image: None
  • Conan version: conan 1.44.0
  • Python version: Python 3.7

Conan profile (output of conan profile show default or conan profile show <profile> if custom profile is in use)

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=7
compiler.libcxx=libstdc++
build_type=Release
[options]
[conf]
[build_requires]
[env]

Steps to reproduce (Include if Applicable)

If you have a requirement with eigen and find_package(Eigen3 CONFIG) you get the warning.

[requires]
eigen/3.3.9#4c35d86148747164763f493d90277d8f
[generators]
CMakeDeps

You get the following warning:

CMake Warning at build/x64/Eigen3Targets.cmake:15 (message):
  Component target name 'Eigen3::Eigen' already exists.
Call Stack (most recent call first):
  build/x64/Eigen3Config.cmake:11 (include)
  CMakeLists.txt:154 (find_package)

If I don't use find_package I don't get a warning, but I should use find_package, shouldn't I?

find_package(Eigen3 REQUIRED CONFIG)

@Lorac Lorac added the bug Something isn't working label Jan 17, 2022
@SpaceIm
Copy link
Contributor

SpaceIm commented Jan 17, 2022

Looks like a small issue in CMakeDeps generator rather than eigen recipe itself. Maybe Eigen3Targets.cmake generated by CMakeDeps is included multiple time through multiple find_package(Eigen) of different downstream libraries, leading to this warning?

Indeed this file contains:

foreach(_COMPONENT ${eigen_COMPONENT_NAMES} )
    if(NOT TARGET ${_COMPONENT})
        add_library(${_COMPONENT} INTERFACE IMPORTED)
        conan_message(STATUS "Conan: Component target declared '${_COMPONENT}'")
    else()
        message(WARNING "Component target name '${_COMPONENT}' already exists.")
    endif()
endforeach()

It's worth noting that official config target files generated by install(EXPORT) have sophisticated multi inclusion guard logic that files generated by CMakeDeps seem to lack:

# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget Eigen3::Eigen)
  list(APPEND _expectedTargets ${_expectedTarget})
  if(NOT TARGET ${_expectedTarget})
    list(APPEND _targetsNotDefined ${_expectedTarget})
  endif()
  if(TARGET ${_expectedTarget})
    list(APPEND _targetsDefined ${_expectedTarget})
  endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
  unset(_targetsDefined)
  unset(_targetsNotDefined)
  unset(_expectedTargets)
  set(CMAKE_IMPORT_FILE_VERSION)
  cmake_policy(POP)
  return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
  message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)

So it's not so different, but official config target files don't display warnings. I think it should be fixed in CMakeDeps generator

/cc @czoido

@perseoGI
Copy link
Contributor

Hi there,
I was reviewing old issues and I have come across this one.

This warning was removed from CMakeDeps generator in this PR conan-io/conan#14644

Happy coding 🐸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants