Boost logo

Boost-Build :

Subject: Re: [Boost-build] gcc version specific command
From: Moritz Hassert (mhassert_at_[hidden])
Date: 2013-02-08 06:57:04


Hi Gennadiy,

the construct
    <foo>uvw:<bar>xyz
allows only for a fixed feature value for a condition.

You have to use a <conditional> feature and a rule to achieve this. Now
you can set compiler flags (and all kinds of other feature values)
depending on values of other features. Here is a stripped-down code
snippet of mine (untested!) you could adapt to your needs:

rule get-gcc-flags ( properties * )
{
    local gcc-flags ;
    
    local toolset = [ feature.get-values <toolset> : $(properties) ] ;
    
    if ( $(toolset) = gcc )
    {
        local version = [ feature.get-values
<toolset-$(toolset):version> : $(properties) ] ;

        local variant = [ feature.get-values <variant> :
$(properties) ] ;

        local target-os = [ feature.get-values <target-os> :
$(properties) ] ;

        # flags for all gcc toolsets
        gcc-flags += <cflags>"-Werror" ;
        
        # only for debug
        if ( $(variant) = debug )
        {
            gcc-flags += <define>_GLIBCXX_DEBUG ;
        }
        
        # only for windows
        if ( $(target-os) = windows )
        {
            gcc-flags += <cflags>"-Wno-pedantic-ms-format" ;
        }
        
        # only for gcc >= 4.5
        if ( $(version) >= 4.5 )
        {
            gcc-flags += <cxxflags>-std=gnu++0x ;
        }
    }
        
    return $(gcc-flags) ;
}

lib foo
    : foo.cpp
    : <conditional>@get-gcc-flags
    ;

Greetings
Moritz

Am Freitag, den 08.02.2013, 07:51 +0000 schrieb Gennadiy Rozental:
> Hi,
>
> I'd like to add
>
> <toolset>gcc:<cxxflags>-std=gnu++0x
>
> for all gcc versions >= 4.5.0
>
> How can I do this?
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build

Geschaeftsfuehrer: Dipl.-Inform. Christopher Asp
Amtsgericht Mannheim HRB 105845


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