3

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.

TemplateRex
  • 69,038
  • 19
  • 164
  • 304
Dmitrii S.
  • 479
  • 1
  • 5
  • 17
  • I believe the syntax should be `using msvc : 11.0 : : 64 shared multi ;`, but unfortunately I can't test it right now. (The spaces are important). – llonesmiz Jul 16 '13 at 09:01
  • Pay attention to the whitespaces before and after `;` – Igor R. Jul 16 '13 at 09:06
  • I tried `using msvc : 11.0 : : 64 shared multi ;` and the relevant part of the output is as follows: http://pastebin.com/5EAKQscU – Dmitrii S. Jul 16 '13 at 09:43
  • @cv_and_he Quite strange. I modified the C:/CppLibraries/boost_1_54_0/tools/build/v2/user-config.jam in the first place but now when I used --user-config option (note "Loading explicitly specified user...") it still uses 32 bit etc. – Dmitrii S. Jul 16 '13 at 11:52
  • 1
    @Dmitry I have found the same, it ignores whatever you put, so it seems that my first comment was incorrect. I'll try to investigate further, but hopefully someone with more knowledge will be able to help you. – llonesmiz Jul 16 '13 at 11:58

1 Answers1

4

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.

Juraj Ivančić
  • 727
  • 5
  • 8
  • You're right - that would be an overkill. Its more clear to me now about how to use the Boost.build for generic binaries or libraries but I want to specify the requirements for building the Boost library itself. For example, I need to invoke `b2` with `--user-config=some-file.jam` and in that file I want to specify an address-model, list of the boost libraries to build and some other options. I know that `b2` searches for the `boost-build.jam` file in the current directory and then does the bootstrapping etc. but I am not sure how to alter this behavior using a target for a specific tool-set. – Dmitrii S. Jul 16 '13 at 22:44