[cmake-developers] New OBJECT library feature
Eric Noulard
eric.noulard at gmail.com
Mon Mar 19 13:56:36 EDT 2012
2012/3/19 Brad King <brad.king at kitware.com>:
> 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.
That's a great feature.
This would be useful for cross-compiled target.
Is there a feature that could guarantee the order of appearance of
those objects / object library on the link line generated for
add_executable ?
By the way why wouldn't you authorize
target_link_libraries(exetarget objlibname) ?
> --------------------------------------------------------------------------
>
> 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.
Ok this answers my previous question.
> 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.
>
I'll test the feature.
--
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org
More information about the cmake-developers
mailing list