File: header-only-libraries.html

package info (click to toggle)
boost-build 2.0-m11-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,624 kB
  • ctags: 2,387
  • sloc: ansic: 12,978; python: 5,209; xml: 4,782; cpp: 555; yacc: 456; sh: 237; makefile: 71
file content (67 lines) | stat: -rw-r--r-- 3,538 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Header-only libraries</title>
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="../../index.html" title="PartI.Boost.Build v2 User Manual">
<link rel="up" href="../faq.html" title="Chapter7.Frequently Asked Questions">
<link rel="prev" href="../recipies/site-config.html" title="Targets in site-config.jam">
<link rel="next" href="../arch.html" title="AppendixA.Boost.Build v2 architecture">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../recipies/site-config.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../arch.html"><img src="../../images/next.png" alt="Next"></a>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="bbv2.faq.header-only-libraries"></a>Header-only libraries</h2></div></div></div>
<p>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.
    </p>
<p>Header-only libraries are declared using the <code class="computeroutput">alias</code> rule,
    that specifies only usage requirements, for example:
</p>
<pre class="programlisting">
alias mylib 
    : # no sources
    : # no build requirements
    : # no default build
    : &lt;include&gt;whatever
    ;
</pre>
<p>
    The includes specified in usage requirements of <code class="computeroutput">mylib</code> are
    automatically added to build properties of all dependents. The dependents
    need not care if <code class="computeroutput">mylib</code> is header-only or not, and it's possible
    to later make <code class="computeroutput">mylib</code> into a regular compiled library.
    </p>
<p>
      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 <code class="computeroutput">alias</code> target:
</p>
<pre class="programlisting">
project my : usage-requirements &lt;include&gt;whatever ;
alias mylib ;
</pre>
<p>      
    </p>
</div>
<table width="100%"><tr>
<td align="left"></td>
<td align="right"><small></small></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../recipies/site-config.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../faq.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../arch.html"><img src="../../images/next.png" alt="Next"></a>
</div>
</body>
</html>