Boost logo

Boost-Build :

From: Phillip Seaver (phil_at_[hidden])
Date: 2007-01-08 09:10:39


Kostas Kostiadis wrote:
> Hello all,
>
> I think this question is probably best asked with a simple example.
>
> Say I have a "framework" project, that uses an "audio" project.
> Now say I have an application that uses "framework" but doesn't want
> to inlcude "audio" support.
>
> I need to:
>
> 1) detect an EXTERNALY defined define in my "framework" project and
> conditionaly allow the inclusion of "audio".
> Pseudo code would look like:
>
> framework jamfile:
>
> #if !defined( EXTERNALY_DEFINED_NO_AUDIO )
> use-project /audio : /libs/audio ;
> #endif
>
> audio jamfile:
>
> as normal
>
> application jamfile:
>
> #define EXTERNALY_DEFINED_NO_AUDIO
>
>
> Any ideas on how to do this much appreciated.
>
> cheers,
> k.

Well, you can't use the <define> feature since it's a "free" feature,
and boost.build won't distinguish between the two builds (AFAIK). In
other words, it won't create two separate libraries, which is what you want.

You can probably do something similar to what I do in one of my
projects. I create my own feature to distinguish between different
applications that use much of the same code, but have slightly different
feature sets and included libraries. I think something like this might
work for you:

In your framework jamfile:

    import feature ;

    use-project /audio : /libs/audio ;

    feature.feature foo_framework_audio : yes no : optional composite
    link-incompatible ;
    feature.compose <foo_framework_audio>yes : <source>/audio ;
    feature.compose <foo_framework_audio>no :
    <define>EXTERNALY_DEFINED_NO_AUDIO ;

    lib foo_framework : {sources} : : <foo_framework_audio>yes
        : <foo_framework_audio>no:<define>EXTERNALY_DEFINED_NO_AUDIO ;

In application jamfile which uses audio:

    exe app : {sources} /foo_framework

In application jamfile which doesn't use audio:

    exe app : {sources} /foo_framework/<foo_framework_audio>no ;

I haven't tested this particular usage, but I think it's in the right
direction. Hope this helps.

Phillip Seaver


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk