Boost logo

Boost :

Subject: Re: [boost] CMake - one more time
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-04-27 21:59:33


Mere moments ago, quoth I:
> ie. add_library(name STATIC sources...) will always build a static library.
> add_library(name SHARED sources...) will always build a shared
> library.
> add_library(name sources...) will build a shared library if
> BUILD_SHARED_LIBS is ON, otherwise a static library.

Or to put it another way, you can consider:

     add_library(name sources...)

To be shorthand for:

     if(BUILD_SHARED_LIBS)
         add_library(name SHARED sources...)
     else()
         add_library(name STATIC sources...)
     endif()

ie. it's the same as your USE_STATIC (although inverted), but you're
fighting the system instead of working with it.

As previously noted, of course, this doesn't let you build both shared
and static libraries from one build run (though you can do it from
separate runs). To do that in one run, you need both add_library lines
unconditionally with different names for each library type (as discussed
elsewhere).

This is less commonly useful when building applications but it's the way
Boost Build prefers to build libraries (just in case).


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk