Boost logo

Boost-Build :

Subject: [Boost-build] Conditional targets not resolving properly
From: Johan Larsson (hnefi.mail_at_[hidden])
Date: 2009-09-10 11:02:06


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
  : usage-requirements

alias commonsources
  : (snip)

lib libA
  : commonsources

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?

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at