File: conditions.html

package info (click to toggle)
boost-build 2.0-m12-2
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 8,692 kB
  • ctags: 6,963
  • sloc: ansic: 39,914; sh: 9,086; python: 6,120; xml: 5,524; cpp: 1,467; yacc: 456; asm: 353; makefile: 184
file content (73 lines) | stat: -rw-r--r-- 4,257 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
68
69
70
71
72
73
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Conditions and alternatives</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="Boost.Build V2 User Manual">
<link rel="up" href="../tutorial.html" title="Chapter3.Tutorial">
<link rel="prev" href="linkage.html" title="Static and shared libaries">
<link rel="next" href="prebuilt.html" title="Prebuilt targets">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="linkage.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../tutorial.html"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="prebuilt.html"><img src="../../../../doc/html/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.tutorial.conditions"></a>Conditions and alternatives</h2></div></div></div>
<p>Sometimes, particular relationships need to be maintained
    among a target's build properties. For example, you might want to set
    specific <code class="computeroutput">#define</code> when a library is built as shared,
    or when a target's <code class="computeroutput">release</code> variant is built. 
    This can be achieved with <em class="firstterm">conditional requirements</em>. 

    </p>
<pre class="programlisting">
lib network : network.cpp 
    : <span class="bold"><strong>&lt;link&gt;shared:&lt;define&gt;NEWORK_LIB_SHARED</strong></span>
     &lt;variant&gt;release:&lt;define&gt;EXTRA_FAST
    ;
</pre>
<p>

      In the example above, whenever <code class="filename">network</code> is
      built with <code class="computeroutput">&lt;link&gt;shared</code>,
      <code class="computeroutput">&lt;define&gt;NEWORK_LIB_SHARED</code> will be in its
      properties, too. Also, whenever its release variant is built, 
      <code class="computeroutput">&lt;define&gt;EXTRA_FAST</code> will appear in its properties.
    </p>
<p>
      Sometimes the ways a target is built are so different that
      describing them using conditional requirements would be
      hard. For example, imagine that a library actually uses
      different source files depending on the toolset used to build
      it. We can express this situation using <em class="firstterm">target
      alternatives</em>:
</p>
<pre class="programlisting">
lib demangler : dummy_demangler.cpp ;                      # alternative 1
lib demangler : demangler_gcc.cpp : &lt;toolset&gt;gcc ;   # alternative 2
lib demangler : demangler_msvc.cpp : &lt;toolset&gt;msvc ; # alternative 3
</pre>
<p>
      When building <code class="filename">demangler</code>, Boost.Build will compare
      requirements for each alternative with build properties to find the best match.
      For example, when building with with <code class="computeroutput">&lt;toolset&gt;gcc</code> 
      alternative 2, will be selected, and when building with 
      <code class="computeroutput">&lt;toolset&gt;msvc</code> alternative 3 will be selected. In all other
      cases, the most generic alternative 1 will be built.
    </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><small></small></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="linkage.html"><img src="../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../tutorial.html"><img src="../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="prebuilt.html"><img src="../../../../doc/html/images/next.png" alt="Next"></a>
</div>
</body>
</html>