boost.png (6897 bytes) Home Libraries People FAQ More

PrevUpHomeNext

Conditions and alternatives

Sometimes, particular relationships need to be maintained among a target's build properties. This can be achieved with conditional requirement. For example, you might want to set specific #defines when a library is built as shared, or when a target's release variant is built in release mode.

lib network : network.cpp 
    : <link>shared:<define>NEWORK_LIB_SHARED
     <variant>release:<define>EXTRA_FAST
    ;

In the example above, whenever network is built with <link>shared, <define>NEWORK_LIB_SHARED will be in its properties, too.

Sometimes the ways a target is built are so different that describing them using conditional requirements would be hard. For example, imagine that a library actually uses different source files depending on the toolset used to build it. We can express this situation using target alternatives:

lib demangler : dummy_demangler.cpp ;                      # alternative 1
lib demangler : demangler_gcc.cpp : <toolset>gcc ;   # alternative 2
lib demangler : demangler_msvc.cpp : <toolset>msvc ; # alternative 3

In the example above, when built with gcc or msvc, demangler will use a source file specific to the toolset. Otherwise, it will use a generic source file, dummy_demangler.cpp.


PrevUpHomeNext