I have a project, Foo, which depends on another project, Bar. Bar creates multiple targets, which I add to a single export set via a macro thusly:
add_library(Bar::${TARGET_NAME} ALIAS ${TARGET_NAME})
# do things like target_include_directories(...)
install(TARGETS ${TARGET_NAME}
EXPORT Bar
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(EXPORT Bar
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/Bar
NAMESPACE Bar::
FILE BarConfig.cmake
)
In project Foo, I add Bar with FetchContent and create an export set for Foo as well, thusly:
install(EXPORT Foo
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/Foo
NAMESPACE Foo::
FILE FooConfig.cmake
)
However, I get an error:
CMake Error: install(EXPORT "Foo" ...) includes target "Foo-lib" which requires target "Bar-lib" that is not in this export set, but in multiple other export sets:
...
In this error, it lists many many locations where BarConfig.cmake definitely does not exist:
- /usr/local/lib/cmake/Bar/Bar.cmake
- /usr/local/lib/cmake/Bar/BarConfig.cmake
- and on and on, something like ~10-15 locations
I have no idea what’s going on here, or why it thinks there are so many Bar export sets.