Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

Main target rules

The main target rule is what creates a top-level target, for example "exe" or "lib". It's quite likely that you'll want to declare your own and there are as many as three ways to do that.

The first is the simplest, but is sufficient in a number of cases. Just write a wrapper rule, which will redirect to any of the existing rules. For example, you have only one library per directory and want all cpp files in the directory to be compiled. You can achieve this effect with:

lib codegen : [ glob *.cpp ] ;

but what if you want to make it even simple. Then, you add the following definition to the project-root.jam file:

rule glib ( name : extra-sources * : requirements * )
    lib $(name) : [ glob *.cpp ] $(extra-sources) : $(requirements) ;

which would allow to reduce Jamfile to

glib codegen ;

The second approach is suitable when your target rule should just produce a target of specific type. Then, when declaring a type you should tell Boost.Build that a main target rule should be created. For example, if you create a module "obfuscate.jam" containing:

import type ;
type.register OBFUSCATED_CPP  : ocpp : : main ;

import generators ;
generators.register-standard obfuscate.file : CPP : OBFUSCATED_CPP ;

and import that module, you'll be able to use the rule "obfuscated-cpp" in Jamfiles, which will convert source to the OBFUSCATED_CPP type.

The remaining method is to declare your own main target class. The simplest example of this can be found in "build/alias.jam" file. The current V2 uses this method when transformations are relatively complex. However, we might deprecate this approach. If you find that you need to use it (that is, the first two approaches are not sufficient), please let us know by posting to the mailing list.