[CMake] shared and static library

Mike Talbot mtalbot at abingdon.oilfield.slb.com
Thu Feb 2 11:38:52 EST 2006


Xavier Delannoy wrote:

>On Thu, 02 Feb 2006 15:02:00 +0000
>Mike Talbot <mtalbot at abingdon.oilfield.slb.com> wrote:
>
>  
>
>>I believe that if you don't specify STATIC or SHARED in the ADD_LIBRARY 
>>command, then you can control whether libraries are built as shared or 
>>static via the BUILD_SHARED_LIBS variable.  If you set this to true in 
>>your cache, then all libraries in your project that aren't explicitly 
>>STATIC will be built as shared and vice-versa.
>>
>>something like this should do it:
>>
>>cd static_lib_dir
>>cmake -D BUILD_SHARED_LIBS:BOOL=FALSE ../srcdir
>>
>>cd shared_lib_dir
>>cmake -D BUILD_SHARED_LIBS:BOOL=TRUE ../srcdir
>>    
>>
>
>this is exactly what I've tried.
>
>
>  
>
I think the short answer to your question is that you need separate 
build directories for shared and static (otherwise you may get name 
clashes, e.g. windows .lib files are produced for both shared and static 
builds).

Alternatively, you could try setting up different build configurations 
for static and shared libraries from the same build directory - the 
output would go in different directories (as debug and release do).  
However this may not be portable to generators that do not support 
multiple build configurations.  I'm not sure how to do this though.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20060202/b20ff44e/attachment.htm


More information about the CMake mailing list