[CMake] OBJECT libraries and INTERFACE_SOURCES

Giovanni Funchal gio at cloudnc.co.uk
Thu Dec 8 11:43:25 EST 2016


Hi,

The help page [1] mentions that:

> Although object libraries may not be named directly in calls to the
> target_link_libraries() command, they can be “linked” indirectly by
> using an Interface Library whose INTERFACE_SOURCES target property
> is set to name $<TARGET_OBJECTS:objlib>.

However, I was unable to get this to work. Doing this:

add_library(lib-obj OBJECT test.cpp)
add_library(lib INTERFACE)
add_dependencies(lib lib-obj)
set_target_properties(lib PROPERTIES INTERFACE_SOURCES
$<TARGET_OBJECTS:lib-obj>)

And then trying to specify lib in link_libraries of an executable yields an
error message "Cannot find source file: ... Tried extensions:... ".

Am I doing something wrong?

Thanks,
-- Giovanni

[1]
https://cmake.org/cmake/help/v3.6/manual/cmake-buildsystem.7.html#object-libraries
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161208/6045132a/attachment.html>


More information about the CMake mailing list