[CMake] static & shared library

David Cole david.cole at kitware.com
Wed Aug 3 08:20:40 EDT 2005


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
>  
>



More information about the CMake mailing list