[CMake] merge static libraries with ar

Timur Ivanov timur.ivanov at gmail.com
Sat Jul 28 15:05:11 EDT 2007


On 7/28/07, Brandon Van Every <bvanevery at gmail.com> wrote:
> On 7/28/07, Timur Ivanov <timur.ivanov at gmail.com> wrote:
> > Hello again :)
> >
> > Suppose i have
> >
> > ADD_SUBDIRECTORY(foo)  # produce libfoo.a
> > ADD_SUBDIRECTORY(bar)  # produce libbar.a
> > ADD_SUBDIRECTORY(baz) # produce libbaz.a
> >
> > Now i need to merge all of them into single library libcool.a. Would
> > you like to give me some hints for that task ?
>
> You can't.  AR itself does not support static libraries that contain
> static libraries.  What you have to do, is find all the object files
> for those libraries, and combine them into your final libcool.a.  This
> requires special knowledge of where CMake has put the object files,
> there's no standard interface for it.  Chicken does all of this with
> the PCRE libraries so that the object files don't have to be
> recompiled over and over again, and so that the user doesn't have to
> link against libpcre.  This is called "faking a convenience library."
> See the Chicken build for details.
> http://www.call-with-current-continuation.org/
>

So the only way is to extract all .o files from foo bar baz libraries
(ar x ...) and create libcool.a  from them by some MACRO ? Is there
any way in cmake to get full path to that  foo, bar, baz libraries ?


More information about the CMake mailing list