C++ Boost


The config module

Table of Contents

The config mechanism can be used to perform a set of checks prior to defining the build logic. Config check results are typically captured as features that can subsequently be used, either to fine-tune the build actions (e.g., by defining a macro or adding an include path), to select what source files to include in a build, etc.

synopsis

class check(name, features=(), if_=(), ifnot=())

A check is an artefact that performs some tests (typically involving compilation), then stores the result in a cache, so it doesn't need to be performed again, until the cache is explicitly cleared.

class try_compile(name, source, type, features=(), if_=(), ifnot=())

Try to compile a chunk of source code.

Try to compile and link a chunk of source code.

class has_cxx11(features=(), if_=(), ifnot=())
class has_cxx14(features=(), if_=(), ifnot=())
class has_cxx17(features=(), if_=(), ifnot=())
class sizeof(c_type, lang_type=<type c>, features=())

Examples

checks = [c_checks.sizeof('char', cxx, features=features),
          c_checks.sizeof('long', cxx, features=features),
          cxx_checks.has_cxx11(features, define('HAS_CXX11')),
          cxx_checks.has_cxx14(features, define('HAS_CXX14')),
          cxx_checks.has_cxx17(features, define('HAS_CXX17'))]

config = report('config', checks)

Running faber config will perform the above checks, and print out a little report, such as:

configuration check results:
sizeof_char : 1
sizeof_long : 8
pytest      : False
has_cxx11   : True
has_cxx14   : True
has_cxx17   : False

(Note that the check base class implements some caching, so the actual checks are only performed if the cache is not present or invalidated.)