Question

How do I specify Boost.build built-in features in a jam-file (user-config.jam) to be used for building the Boost library? For example I may use b2 from VS command prompt to build boost using

b2 link=shared threading=multi address-model=64 

and I need the same features enabled through .jam configuration.

I know that Boost.build system may use user-config.jam from the local directory but I am confused about the syntax. I've tried this:

using msvc : 11.0;
<address-model>64;

But this doesn't seem to affect the build process.

Was it helpful?

Solution

In short - you should not do that. Toolset configuration isn't meant to hardcode features (like <address-model>) to all targets built with that toolset. The proper way is to set this feature on all main targets being built.

exe myexe : a.cpp : <address-model>64 ;

This can also be done by setting feature value on project target.

project my-project : requirements <address-model>64 ;

# Same as above, project requirements are applied to
# all targets in the project.
exe myexe : a.cpp ;

This is in essence what Boost.Build does with features specified on the command line. They are parsed and applied to all top level targets as requirements.

If you really want to use user-config.jam to make sure that all targets have <address-model>64 you can use the following trick:

# In user-config.jam
import feature
feature.feature build-64 : on : composite ;
feature.compose <build-64>on : <address-model>64 ;

This defines a new feature. This feature is not optional, so Boost.Build will use it on all targets being built. The default value is the first (and only) one ('on'), and it is a composite which specifies <address-model>64, so this gets applied to every target.

When building Boost - you can rewrite the command line using user-config.jam. If you need to specify which libraries are built, I believe that this is the only way to go.

# Un user-config.jam
local argv = [ modules.peek : ARGV ] ;
ECHO Old command line is '$(argv)' ;
modules.poke : ARGV : $(argv) --with-thread address-model=64 ;
argv = [ modules.peek : ARGV ] ;
ECHO New command line is '$(argv)' ;

But it does seem more appropriate to pass the right command line in the first place, using a shell script, instead of rewriting it in user-config.jam.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top