| Home | Libraries | People | FAQ | More

## Conditions and alternatives

As we've just figured out, properties can significally affect the way targets are built. The processing of the <link> feature is built in the build system, and is quite complex. But there is a couple of mechanisms which allow ordinary users to do different things depending on properties.

The first mechanism is called conditinal requirement. For example, you might want to set specific defines when the library is build as shared, or you have your own define to be used in release mode. Here's a piece of Jamfile.

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

This will have exactly the effect we wanted: whenever <link>shared is in properties, <define>NEWORK_LIB_SHARED will be in properties as well.

Sometimes different variant of a target are so different, that describing them using conditional requirements would be hard. Imagine that a library has different sources on two supported toolsets, and dummy implementation for all the other toolset. We can express this situation using target alternatives:

    lib demangler : dummy_demangler.cpp ;
    lib demangler : demangler_gcc.cpp : <toolset>gcc ;
    lib demangler : demangler_msvc.cpp : <toolset>msvc ;

The proper alternative will be automatically selected.