[cmake-developers] Object library linking (and a bit about INTERFACE_SOURCES)

Ben Boeckel ben.boeckel at kitware.com
Wed Feb 25 17:37:56 EST 2015


On Wed, Feb 25, 2015 at 22:57:13 +0100, Stephen Kelly wrote:
> > What I envision for the future is:
> > 
> >  add_library(objlib OBJECT ...)
> >  target_compile_definitions(objlib PUBLIC MYDEF)
> >  target_sources(objlib INTERFACE $<TARGET_OBJECTS:objlib>)
> 
> Do you envision that as the idiomatic way to declare object libraries?

It would be nice if that's the pattern anyways. There'd probably have to
be a policy to ignore using TARGET_OBJECTS within target_sources (only
for itself? except INTERFACE libs? So many edge cases :/ ).

> Would CMakeLists authors have to write the target_sources line
> explicitly, if this future becomes possible?

No, I have a commit which initializes INTERFACE_SOURCES when object
libraries are created. Currently floating on its own branch.

--Ben


More information about the cmake-developers mailing list