Open Lorac opened 2 years ago
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
Package and Environment Details (include every applicable attribute)
Conan profile (output of
conan profile show default
orconan profile show <profile>
if custom profile is in use)Steps to reproduce (Include if Applicable)
If you have a requirement with eigen and
find_package(Eigen3 CONFIG)
you get the warning.You get the following warning:
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)