Reputation: 584
I want to create a project where I am able to choose two different targets to build for, using define flags.
For example in my code I have multiple sections with
#ifdef LINUX
...
#else
...
#
What is the best practice for selecting between two targets in a Jamroot file and is that even possible? Should I create two different Jamroot files in the root directory and call them using bjam? From what I have found in the manual section it is not possible to call bjam with a specific Jamroot file.
Assume my example Jammroot file look like this;
project myproj_linux
:
requirements
<define>LINUX
;
exe myprog_linux:
test/Jamfile
myprog.cpp
;
Is it possible to add an extra project in the same file, for example myproj_ose, or how should this be done? Or can I have different Jamfiles, for example Jamfile.linux in the subdirectories which Jamroot invokes depending on the target specified?
If any of my suggestions are not possible, then how could this problem be solved?
Upvotes: 1
Views: 691
Reputation: 3059
I think you want something like this:
project myproj
: requirements
<target-os>linux:<define>LINUX
<target-os>windows:<define>WINDOWS
;
exe myprog : test/Jamfile myprog.cpp ;
You can read more about conditional requirements in the docs. But that just builds the same program with different options. It's also possible to change what variations of a target to build. For example:
exe myprog : test/Jamfile myprog_linux.cpp : <target-os>linux ;
exe myprog : test/Jamfile myprog_windows.cpp : <target-os>windows ;
Upvotes: 2