Privately linked interface library triggers 'install(EXPORT "ftlTargets" ...) includes target "..." which requires target "..." that is not in any export set.'
Consider the following CML:
cmake_minimum_required(VERSION 3.10)
project(Foo)
add_library(project_options INTERFACE)
target_include_directories(project_options INTERFACE /foobar)
add_library(ftl ftl.cpp)
target_compile_features(ftl PUBLIC cxx_std_17)
target_include_directories(ftl
PUBLIC
$<BUILD_INTERFACE:${ftl_BINARY_DIR}/include/>
$<BUILD_INTERFACE:${ftl_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:include/>
)
target_link_libraries(ftl
PRIVATE
project_options
)
install(TARGETS project_options EXPORT ftlDummy)
install(TARGETS ftl EXPORT ftlTargets
LIBRARY DESTINATION lib)
install(EXPORT ftlTargets
FILE ftlTargets.cmake
NAMESPACE ftl::
DESTINATION lib/cmake/ftl)
This triggers an error CMake Error: install(EXPORT "ftlTargets" ...) includes target "ftl" which requires target "project_options" that is not in any export set.
I have 2 issues with that error:
- Why is it required to export a privately linked interface library? I mean that is meant to be consumed at build time and there will be no effect on the installed library. So to me it seems overly restrictive to require it there
- The message says "is not in any export set". This is confusing at least as the
install(TARGETS project_options EXPORT ftlDummy)
line does add it to an export set. The only valid concern I can see is that this export set is not installed, but that is not what the message tells me.
Can anyone clarify this?
Edit: If I export and install that options library a line INTERFACE_LINK_LIBRARIES "\$<LINK_ONLY:ftl::project_options>"
is added to the ftl::ftl target properties. I'm surprised by the escape of the $
which looks odd. Not fully sure though and I guess it gets removed anyway once the string is evaluated
Edited by Alexander Grund