Boost logo

Boost-Build :

Subject: Re: [Boost-build] Conditional src files
From: Phillip Seaver (phil_at_[hidden])
Date: 2009-11-04 22:11:19


Anant Rao wrote:
> Thanks Steven!
> I'm sorry I didn't give the correct and complete info.
>
> Here's what my Jamfile looks like:
>
>
> project blah
> : source-location $(OS_SRC) $(OS_LINUX_SRC) $(OS_WIN_SRC)
> ;
>
> lib libblah
> :
> CommonFile1.cpp
> CommonFile2.cpp
> WinFile.cpp
> LinuxFile.cpp
> : <define>$(DEFINES)
> : <link>static
> ;
>
>
> Now, WinFile.cpp should be included only on Windows and LinuxFile.cpp on Linux. Given this, could you please let me know how I can do it?
>
> Thanks again,
>
>
> -----Original Message-----
> From: boost-build-bounces_at_[hidden] [mailto:boost-build-bounces_at_[hidden]] On Behalf Of Steven Watanabe
> Sent: Wednesday, November 04, 2009 6:05 PM
> To: Boost.Build developer's and user's list
> Subject: Re: [Boost-build] Conditional src files
>
> AMDG
>
> Anant Rao wrote:
>
>> How is it to handle diff files on diff OSs using bjam?
>>
>> What I mean is - say, file File1.cpp exists only Windows and File2.cpp exists only on Linux.
>> Using a single Jamfile, is there a way to handle it i.e., conditionally add the files to the build, depending on the OS?
>>
>>
>
> You can use conditional features:
>
> <target-os>windows:<source>File1.cpp
> <target-os>linux:<source>File2.cpp
>
> In Christ,
> Steven Watanabe
>

This should do what you want:

lib libblah
:
CommonFile1.cpp
CommonFile2.cpp
: <define>$(DEFINES)
<target-os>windows:<source>WinFile.cpp
<target-os>linux:<source>LinuxFile.cpp
: <link>static
;

Phillip


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