Boost logo

Boost-Build :

Subject: Re: [Boost-build] Conditional targets not resolving properly
From: Matthew Chambers (matthew.chambers_at_[hidden])
Date: 2009-09-10 11:05:01


Indirect conditionals are my preferred solution for this case.

rule exclude-source-if-not-gcc ( properties * )
{
   if ! <toolset>gcc in $(properties) { return <source>SOURCE.cpp ; }
}

project A
  : requirements
    <link>static
    <toolset>gcc:<cxxflags>-DNO_SMART
  : usage-requirements
    <linkflags>-lA
    <include>.
  ;

alias commonsources
  : (snip)
  ;

lib libA
  : commonsources
  : <conditional>@exclude-source-if-not-gcc
  ;

HTH,
-Matt

Johan Larsson wrote:
> Hello.
>
> As part of a project, I have a library with an associated Jamfile I
> need to build. I want to build this particular library as a static
> lib, so I've added <link>static to the project requirements in the
> Jamfile for the library. So far so good.
>
> However, I also want to exclude a particular source file from the
> library if I use a particular toolset (gcc in this case). So I've
> created two targets; one with all the sources and no particular
> requirements, and one without the source file in question with
> <toolset>gcc added as a requirement, like so:
>
>
>
> project A
> : requirements
> <link>static
> <toolset>gcc:<cxxflags>-DNO_SMART
> : usage-requirements
> <linkflags>-lA
> <include>.
> ;
>
> alias commonsources
> : (snip)
> ;
>
> lib libA
> : commonsources
> SOURCE.cpp
> ;
>
> lib libA
> : commonsources
> : <toolset>gcc
> ;
>
> The problem is that when building with a toolset that is not gcc, bjam
> fails to find an appropriate target. The output it gives me is as follows:
> error: No best alternative for ./libA
> next alternative: required properties: <link>static
> not matched
> next alternative: required properties: <link>static <toolset>gcc
> not matched
>
> Obviously, I want the builds to match the closest possible
> alternative; that is, any build with a toolset other than gcc should
> match the first target, and any build with gcc as a toolset should
> match the second target.
>
> Is there a way to achieve this, or perhaps a different way altoghether
> to exclude source files from a target when build with a particular
> toolset?
> ------------------------------------------------------------------------
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build
>


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