Boost logo

Boost-Build :

Subject: Re: [Boost-build] Target alternatives - one more time
From: Matthew Chambers (matt.chambers42_at_[hidden])
Date: 2011-07-15 12:09:36


On 7/15/2011 10:58 AM, Edward Diener wrote:
> On 7/14/2011 5:12 PM, Matthew Chambers wrote:
>>
>>
>> On 7/14/2011 3:34 PM, Edward Diener wrote:
>>> Given a particular source I want to test if it will compile with a
>>> particular option, can someone
>>> show me how to set up the jamfile so that I compile for two different
>>> toolsets but not for any other
>>> toolsets ?
>>>
>>> As an example suppose I want to compile some_source.cpp with the
>>> -std=c++0x for gcc-4.6.0 and
>>> gcc-4.5.2, and I also want to compile some_source.cpp with no
>>> particular option for all toolsets.
>>> How do I do this in a jamfile ?
>>>
>>
>> obj some_source : some_source.cpp ;
>> obj some_source : some_source.cpp : <toolset>gcc-4.6.0 :
>> <cxxflags>-std=c++0x ;
>> obj some_source : some_source.cpp : <toolset>gcc-4.5.2 :
>> <cxxflags>-std=c++0x ;
>>
>> You could also do it all in a rule like:
>>
>> rule some_source_requirements ( properties * )
>> {
>> if gcc-4.6.0 gcc-4.5.2 in $(properties:G=) { return <cxxflags>-std=c++0x
>> ; }
>> }
>>
>> obj some_source : some_source.cpp :
>> <conditional>@some_source_requirements ;
>
> I tried this:
>
> test-suite some_dbg
> :
> [ compile-fail debug_fail_program.cpp
> : <variant>debug
> <cxxflags>-std=c++0x
> ]
> :
> <toolset>gcc
> ;
>
> test-suite some_dbg
> :
> [ compile-fail debug_fail_program.cpp
> : <variant>debug
> ]
> :
> <toolset>msvc
> ;
>
> test-suite some_dbg ;
>
> Only to get a Build error when I tried to invoke it with the toolset msvc-10.0:
>
> error: No best alternative for ./debug_fail_program
> next alternative: required properties: <variant>debug
> matched
> next alternative: required properties: <variant>debug
> matched
>
> How can I get this to work without having to create some sort of rule ? This can not be rocket
> science but I can not understand why Boost Build is making something that should so easy end up so
> difficult to do.

I'm not familiar with the new [ rule ] syntax but the error is fairly clear. The some_dbg target is
not the problem, it's the nested debug_fail_program. I assume you'll have to put the <toolset>
requirement inside that rule. Perhaps you can even do this:
test-suite some_dbg
: [ compile-fail debug_fail_program.cpp : <variant>debug <toolset>msvc ]
   [ compile-fail debug_fail_program.cpp : <variant>debug <cxxflags>-std=c++0x <toolset>gcc ] ;
;

-Matt


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