CMake exports should not depend on private INTERFACE target
Consider the following:
cmake_minimum_required(VERSION 3.10)
project(cmakeplayground VERSION 1.2.3)
add_library(foo STATIC somefile.cpp)
add_library(external::iface INTERFACE IMPORTED)
target_link_libraries(foo PRIVATE external::iface)
install(TARGETS foo EXPORT exp
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(EXPORT exp DESTINATION share/cmake)
The static library depends on the interface library privately.
Private dependencies of static libraries get exported as public LINK_ONLY
dependencies. This makes sense where the dependencies are static or shared libraries. However, when the private dependency is an interface target, it doesn't make sense to list it as a LINK_ONLY
public dependency.
$ grep -r external prefix/
prefix/share/cmake/exp.cmake: INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:external::iface>"