![]() |
In modern C++, libraries often consist of just header files, without any source files to compile. To use such libraries, you need to add proper includes and, maybe, defines, to your project. But with large number of external libraries it becomes problematic to remember which libraries are header only, and which are "real" ones. However, with Boost.Build a header-only library can be declared as Boost.Build target and all dependents can use such library without remebering if it's header-only or not.
Header-only libraries are declared using the alias
rule,
that specifies only usage requirements, for example:
alias mylib : # no sources : # no build requirements : # no default build : <include>whatever ;
The includes specified in usage requirements of mylib
are
automatically added to build properties of all dependents. The dependents
need not care if mylib
is header-only or not, and it's possible
to later make mylib
into a regular compiled library.
If you already have proper usage requirements declared for project where
header-only library is defined, you don't need to duplicate them for
the alias
target:
project my : usage-requirements <include>whatever ; alias mylib ;