Boost logo

Boost-Build :

Subject: Re: [Boost-build] Different builds for XP and Vista/7
From: Juraj Ivanèiæ (juraj.ivancic_at_[hidden])
Date: 2011-04-12 17:42:34


On 12.4.2011 22:28, Artem Alimarine wrote:
> Thanks for help.
>
> The next step is to select implementation based on the target flavor. I
> have now the following Jamroot.
>
> --------------------------------------------------------------------------
> import feature ;
>
> feature.subfeature target-os windows : flavor : vista xp : composite
> optional ;
>
> feature.compose<target-os-windows:flavor>vista :
> <define>_WIN32_WINNT=0x0600 ;
> feature.compose<target-os-windows:flavor>xp :
> <define>_WIN32_WINNT=0x0501 ;
>
> lib foo_lib : foo_xp.cpp :<target-os>windows-xp ;
> lib foo_lib : foo_vista.cpp :<target-os>windows-vista ;
>
> exe main : main.cpp foo_lib ;
> exe main_xp : main.cpp foo_lib :<target-os>windows-xp ;
> exe main_vista : main.cpp foo_lib :<target-os>windows-vista ;
> --------------------------------------------------------------------------
>
> There is a problem. When I run it with
> bjam toolset=msvc target-os=windows-xp main
> or
> bjam toolset=msvc target-os=windows-xp main_xp
> I always get
>
> error: No best alternative for ./foo_lib
> next alternative: required properties:<target-os>windows-xp
> not matched
> next alternative: required properties:<target-os>windows-vista
> not matched
>
> How do I achieve that the build is picked according to the flavor given
> in the command line or in the executable properties?

This is merely a warning - main target is built correctly. This warning
is emitted because there is no default target alternative for the
top-level foo_lib target. You can silence it by adding a dummy default:

alias foo_lib ;

Furthermore - you can also use alias to avoid creating an intermediate
library:

alias foo ;
alias foo : foo_xp.cpp : <target-os>windows-xp ;
alias foo : foo_vista.cpp : <target-os>windows-vista ;

exe main : main.cpp foo ;
exe main_xp : main.cpp foo : <target-os>windows-xp ;
exe main_vista : main.cpp foo :<target-os>windows-vista ;


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