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><link>shared:<define>NEWORK_LIB_SHARED</strong></span>
<variant>release:<define>EXTRA_FAST
;
</pre>
<p>
In the example above, whenever <code class="filename">network</code> is
built with <code class="computeroutput"><link>shared</code>,
<code class="computeroutput"><define>NEWORK_LIB_SHARED</code> will be in its
properties, too. Also, whenever its release variant is built,
<code class="computeroutput"><define>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 : <toolset>gcc ; # alternative 2
lib demangler : demangler_msvc.cpp : <toolset>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"><toolset>gcc</code>
alternative 2, will be selected, and when building with
<code class="computeroutput"><toolset>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>
|