[CMake] INSTALL(EXPORT) does not honor LINK_INTERFACE_LIBRARIES?
Rolf Eike Beer
eike at sf-mail.de
Tue Mar 29 05:19:23 EDT 2011
> On 03/28/2011 02:51 PM, Rolf Eike Beer wrote:
>> I try to do an INSTALL(EXPORT) to allow others to link against one of my
>> libraries. That libraries is linked against some other internal
>> libraries
>> the target's don't need to link to as everything in them is purely
>> internal.
>>
>> I tried something like that:
>>
>> ADD_LIBRARY(publiclib SHARED ${publiclib_SOURCES})
>>
>> TARGET_LINK_LIBRARIES(publiclib privatelib)
>>
>> SET_TARGET_PROPERTIES(publiclib PROPERTIES LINK_INTERFACE_LIBRARIES "")
>>
>> INSTALL(TARGETS publiclib
>> EXPORT publiclib_export
>> RUNTIME DESTINATION bin
>> LIBRARY DESTINATION lib
>> ARCHIVE DESTINATION lib)
>>
>> INSTALL(EXPORT publiclib_export DESTINATION cmake/modules)
>>
>> This results in:
>>
>> Make Error: INSTALL(EXPORT "publiclib_export" ...) includes target
>> "publiclib" which requires target "privatelib" that is not in the export
>> set.
>>
>> Ehm, no, it doesn't? Is this intentional (why?), is there a workaround
>> or should I file a bug report?
> That's got nothing to do with the LINK_INTERFACE_LIBRARIES property.
> Your publiclib target is linked against the privatelib one, so you
> can't place the former in an export set without the latter, and this
> is what CMake tells you, cf. [1]. Remove the SET_TARGET_PROPERTIES()
> command and you'll probably see that the error message persists, i.e.
> LINK_INTERFACE_LIBRARIES can not be used to break any dependencies
> established by TARGET_LINK_LIBRARIES(); it has other purposes [2].
The basic idea is: any symbols from those private libraries are, well,
private. The user only ever sees the symbols from the public library. In
fact he _can't_ even link to the private libraries on Windows as we never
install the .lib files. And that's no problem at all as we already link to
everything we need. I'm using --as-needed and --no-undefined on Un*x and
see no problem there either.
So the point is I want CMake to stop telling the user that he needs to
those private libraries as that's simply not true.
Eike
More information about the CMake
mailing list