[CMake] OBJECT Libraries and linking against targets

Wesley Smith wesley.hoke at gmail.com
Fri Aug 11 09:31:40 EDT 2017


Hi,
I understand vaguely why OBJECT libraries can't link against other targets,
but I don't think the restriction in place needs to be so constrained.
Consider the following:

* A target is being create as an OBJECT library
* A number of other targets are defined as INTERFACE target where they only
set include paths, compiler options, etc.

How is it possible to communicate the dependencies expressed in an
INTERFACE target to an OBJECT library?  So far the only method I've found
that works is to use a handful of generator expressions, which seems like a
lot of work for something that would just work if I could "link" the
INTERFACE library against the OBJECT library.

Here's what I have to do:

target_compile_features(tgt PUBLIC
    $<TARGET_PROPERTY:tgt_dep,COMPILE_FEATURES>
)
target_include_directories(tgt PUBLIC
    $<TARGET_PROPERTY:tgt_dep,INCLUDE_DIRECTORIES>
)
target_compile_options(tgt PUBLIC
    $<TARGET_PROPERTY:tgt_dep,COMPILE_OPTIONS>
    $<TARGET_PROPERTY:tgt_dep,COMPILE_FLAGS>
)
target_compile_definitions(tgt PUBLIC
    $<TARGET_PROPERTY:tgt_dep,COMPILE_DEFINITIONS>
)

thanks!
wes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170811/e8768d6c/attachment.html>


More information about the CMake mailing list