[CMake] OBJECT libraries getting fully support?

Paul Smith paul at mad-scientist.net
Tue Feb 12 18:35:12 EST 2019


Don't want to be a noodge but wondering if anyone has any thoughts
about this question or ideas on how to solve my problem?


On Sat, 2019-02-09 at 12:29 -0500, Paul Smith wrote:
> Hi all;
> 
> I saw an email to the list from Chuck Atkins in the summer of 2017
> suggesting that OBJECT libraries were being enhanced and could become
> fully-functional libraries hopefully sometime that year.  I'm wondering
> if that ever actally happened and if so what release of cmake it was
> in, and if not is there still a plan for this sometime?
> 
> I'm trying to convert a large and complex cmake environment originally
> started in 2007 or so, which uses all old-school cmake facilities, to
> use modern cmake methods.
> 
> I have a situation where we have a library containing basic methods
> which can be implemented multiple ways and different executables use
> different implementations.  However these methods are used by all sorts
> of static libraries as well.
> 
> Since we don't know until executable link time which library to use,
> the static libraries cannot depend on the base library: it has to be
> listed only in the executable's target_link_libraries.  But of course
> because the static libraries use them as well we need the base library
> to be listed last (or near last) in the link line else we get undefined
> symbols.  Adding the base library to the executable TLL doesn't allow
> us to do that.
> 
> So I was thinking of making this base library an OBJECT library so it
> would always be fully linked but it seems that our version of cmake
> doesn't allow an OBJECT library to be used as a normal library and I'd
> be reduced to adding lots of generator expressions for it everywhere
> which is a huge PITA.
> 
> Any ideas on how best to address this situation, if OBJECT libraries
> are not supported yet?



More information about the CMake mailing list