[cmake-developers] New OBJECT library feature

Alexander Neundorf neundorf at kde.org
Mon Mar 19 17:29:27 EDT 2012


On Monday 19 March 2012, Brad King wrote:
> Hi Folks,
> 
> I've just pushed a new 'object-library' topic and merged to 'next'
> for testing.  David Cole and I have been working on it for a couple
> of weeks.  The following documentation added to the add_library
> command explains:
> 
> --------------------------------------------------------------------------
>   The signature
> 
>     add_library(<name> OBJECT <src>...)
> 
>   creates a special "object library" target.  An object library compiles
>   source files but does not archive or link their object files into a
>   library.  Instead other targets created by add_library or
>   add_executable may reference the objects using an expression of the
>   form $<TARGET_OBJECTS:objlib> as a source, where "objlib" is the
>   object library name.  For example:
> 
>     add_library(... $<TARGET_OBJECTS:objlib> ...)
>     add_executable(... $<TARGET_OBJECTS:objlib> ...)
> 
>   will include objlib's object files in a library and an executable
>   along with those compiled from their own sources.  Object libraries
>   may contain only sources (and headers) that compile to object files.
>   They may contain custom commands generating such sources, but not
>   PRE_BUILD, PRE_LINK, or POST_BUILD commands.  Object libraries cannot
>   be imported, exported, installed, or linked.
> --------------------------------------------------------------------------
> 
> Many of the documented restrictions are temporary until meaningful
> behavior can be defined and implemented for them in a future version.
> It is easiest to simply disallow all but the basic use case for now.
> 
> This feature plays a role similar to autotools convenience libraries
> but works with all toolchains and under VS and Xcode.  We've updated
> all primary generators to support object libraries including the Ninja
> generator.  Until this goes into master watch out for conflicts when
> making changes to the other generators.

Cool :-)
This must be one of the most requested missing features :-)
 
> We are still missing support in the "Extra" generators to present
> OBJECT libraries in the project files.  They need to appear much like
> STATIC libraries but have no library/archive file.  We request help
> from the contributors of Extra generators to handle them.

Can you please create a ticket for each of them, and assign them to me ?
I'll see that I can do the Eclipse one still for 2.8.8.
CodeBlocks/QtCreator will have to wait until 2.8.9 I think.

Alex



More information about the cmake-developers mailing list