[cmake-developers] TargetLinkLibraries on OBJECT-libraries

Brad King brad.king at kitware.com
Tue May 16 09:11:41 EDT 2017


On 05/16/2017 05:16 AM, Patrick Boettcher wrote:
> I'd like to use target_link_libraries() on an OBJECT-library
> 
> I started looking into the code, except removing the check in
> cmTargetLinkLibraries.cpp I didn't do much. And this does not make it
> work. 
> 
> Before continuing I'd like to know whether this is a good idea to work
> on or if there are good arguments to never allow "linking" an
> object-library to get compile information from other libraries?

Adding Ben and Robert to Cc who've recently discussed a plan for this.

The reason that object libraries were not made linkable originally
is that the semantics were not clear.  Back then we were only first
starting to do usage requirements besides linking.  Since then things
have matured enough to provide a path forward.

We can't allow target_link_libraries to propagate the object files
themselves because then they could end up in multiple dependent
consumers.  However, we can make target_link_libraries treat OBJECT
libraries just like INTERFACE libraries for all the other usage
requirements.  Once we do that then we can support object libraries
on the left of target_link_libraries too because then the transitive
behavior of the INTERFACE requirements becomes well-defined.

-Brad



More information about the cmake-developers mailing list