[CMake] static & shared library

Doug Henry brilligent at gmail.com
Wed Aug 3 08:30:02 EDT 2005


thanks. its not a real problem, but if I didn't have to compile twice that 
would obviously be better :-) Right now I just tack on -static to the target 
name and have two targets. I'm basically trying to loosely simulate the 
autotools functionality where you can independently switch on/off shared and 
static (--disable-shared --enable-static).


On 8/3/05, David Cole <david.cole at kitware.com> wrote:
> 
> Not in general. You'll want two distinct binary trees for this. On some
> platforms, the compile stage is different for the two types of
> libraries. And on Windows, specifically, creating a shared library (dll)
> also produces an import library (lib) which clients of the library need
> to link to. So, if you tried to build both, you'd end up with two
> target.lib files (one the "real" static lib and one an import lib which
> links the client to the dll) and somebody somewhere would get confused...
> 
> Is there a problem with "re-running cmake"? And using two separate
> binary directories, one for static, one for shared? (Other than the fact
> that your build has to be twice as long when you have two binary trees
> to produce...)
> 
> HTH,
> David
> 
> 
> Doug Henry wrote:
> 
> > is it possible to build a static and shared library (without
> > re-running cmake) for the same target? Something like:
> >
> > ADD_LIBRARY(target STATIC ...)
> > ADD_LIBRARY(target SHARED ...)
> >
> > cmake doesn't allow add_library twice for the same target, so it sort
> > of makes sense that the above doesn't work, even though they create
> > different files. Any info appreciated.
> >
> > -doug
> >
> >------------------------------------------------------------------------
> >
> >_______________________________________________
> >CMake mailing list
> >CMake at cmake.org
> >http://www.cmake.org/mailman/listinfo/cmake
> >
> >
> 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20050803/12910472/attachment.htm


More information about the CMake mailing list