From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-03-14 02:14:15
Ali Azarbayejani wrote:
> Here's a simple question...can I do "Conditional Sources" using the same
> syntax as Conditional Properties?
> lib mylib : foo.cxx bar.cxx <os>NT:ntbase.cxx ;
No, it's not possible. Probably that would nicely rhyme with conditional
properties, but some time ago Rene Rivera noted that conditional sources
can be achieved right now
alias platform-sources ;
alias platform-sources : a.cpp : <os>LINUX ;
exe hello : hello.cpp platform-sources ;
There are two alternatives for 'platform-sources' main target.
The first one is generic: it has any sources and produces nothing. The second
is used only with <os>LINUX is properties and just returns all sources. So,
on Linux, "a.cpp" will be compiled. On NT --- not. I attach a complete
example. In the example, you can swithc <os>LINUX to <os>NT to see how it
A question how this method relates with conditional features now raises. I
don't yet have an answer --- probably some experiments are needed.
> Or do I have to do something more convoluted like the following?
> Sources = foo.cxx bar.cxx ;
> if [ os.name ] = NT
> Sources += ntbase.cxx ;
> lib mylib : $(Sources) ;
That's an option too. I think I like "alternatives"-based variant better,
though, especially because it's more flexible. For example, if Boost.Build
ever supports cross compiling, the if-based solution won't work anymore.
[ os.name ] will be host os name.
--------------Boundary-00=_RF9Q6ZXEG3SMAYT6MI0N Content-Type: application/x-tgz;
Content-Disposition: attachment; filename="cs.tar.gz"
[Attachment content not displayed.] --------------Boundary-00=_RF9Q6ZXEG3SMAYT6MI0N--
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