Suppose you have a CMakeLists.txt file like =================================
cmake_minimum_required(VERSION 2.8.12) project(Foo) add_library(Ext::Imported SHARED IMPORTED) add_library(FooDep SHARED main.cpp) install(TARGETS FooDep ARCHIVE DESTINATION "lib" LIBRARY DESTINATION "lib" ) add_library(FooMain SHARED main.cpp) target_link_libraries(FooMain PUBLIC Ext::Imported PRIVATE FooDep ) install(TARGETS FooMain EXPORT FooTargets ARCHIVE DESTINATION "lib" LIBRARY DESTINATION "lib" ) install(EXPORT FooTargets NAMESPACE Foo:: DESTINATION "lib/cmake/Foo" FILE FooTargets.cmake) ================================= This fails with the error CMake Error: install(EXPORT "FooTargets" ...) includes target "FooMain" which requires target "FooDep" that is not in the export set. It is not obvious from what I have read of the documentation that this should happen, but (looking at the CMake code), this seems to be deliberate - the issue is in trying to populate IMPORTED_LINK_DEPENDENT_LIBRARIES for the exported target, it wants the private dependencies as well as the interface ones. So it wants FooDep to be EXPORTed, even though this may be a private internal library. However, removing the PUBLIC dependencies of FooMain suppresses this error, presumably because the INTERFACE_LINK_LIBRARIES property is not set, so cmTargetInternals::ComputeLinkInterfaceLibraries does not set iface.ExplicitLibraries for the target, so cmTargetInternals::ComputeLinkInterface does not add anything to iface.SharedDeps, which is what is used to populate IMPORTED_LINK_DEPENDENT_LIBRARIES. This difference in behaviour does not make sense. So either neither case should be an error, or both cases should be. However, I don't know which it is. Alex -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers