[CMake] OBJECT libraries getting fully support?

Paul Smith paul at mad-scientist.net
Sat Feb 9 12:29:23 EST 2019


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