summaryrefslogtreecommitdiff
path: root/3.8.2/doc/cmake/html/manual/cmake-generator-expressions.7.html
blob: 034bd688ff74decbe06a47276d1b72412fd7d213 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
  <title>cmake-generator-expressions(7) &mdash; CMake 3.8.2 Documentation</title>

    
    <link rel="stylesheet" href="../_static/cmake.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '3.8.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="shortcut icon" href="../_static/cmake-favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="cmake-generators(7)" href="cmake-generators.7.html" />
    <link rel="prev" title="cmake-developer(7)" href="cmake-developer.7.html" /> 
  </head>
  <body role="document">
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="cmake-generators.7.html" title="cmake-generators(7)"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="cmake-developer.7.html" title="cmake-developer(7)"
             accesskey="P">previous</a> |</li>
  <li>
    <img src="../_static/cmake-logo-16.png" alt=""
         style="vertical-align: middle; margin-top: -2px" />
  </li>
  <li>
    <a href="https://cmake.org/">CMake</a> &#187;
  </li>
  <li>
    <a href="../index.html">3.8.2 Documentation</a> &#187;
  </li>
 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <span class="target" id="manual:cmake-generator-expressions(7)"></span><div class="section" id="cmake-generator-expressions-7">
<h1><a class="toc-backref" href="#id1">cmake-generator-expressions(7)</a><a class="headerlink" href="#cmake-generator-expressions-7" title="Permalink to this headline">¶</a></h1>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#cmake-generator-expressions-7" id="id1">cmake-generator-expressions(7)</a><ul>
<li><a class="reference internal" href="#introduction" id="id2">Introduction</a></li>
<li><a class="reference internal" href="#logical-expressions" id="id3">Logical Expressions</a></li>
<li><a class="reference internal" href="#informational-expressions" id="id4">Informational Expressions</a></li>
<li><a class="reference internal" href="#output-expressions" id="id5">Output Expressions</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="introduction">
<h2><a class="toc-backref" href="#id2">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>Generator expressions are evaluated during build system generation to produce
information specific to each build configuration.</p>
<p>Generator expressions are allowed in the context of many target properties,
such as <span class="target" id="index-0-prop_tgt:LINK_LIBRARIES"></span><a class="reference internal" href="../prop_tgt/LINK_LIBRARIES.html#prop_tgt:LINK_LIBRARIES" title="LINK_LIBRARIES"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">LINK_LIBRARIES</span></code></a>, <span class="target" id="index-0-prop_tgt:INCLUDE_DIRECTORIES"></span><a class="reference internal" href="../prop_tgt/INCLUDE_DIRECTORIES.html#prop_tgt:INCLUDE_DIRECTORIES" title="INCLUDE_DIRECTORIES"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">INCLUDE_DIRECTORIES</span></code></a>,
<span class="target" id="index-0-prop_tgt:COMPILE_DEFINITIONS"></span><a class="reference internal" href="../prop_tgt/COMPILE_DEFINITIONS.html#prop_tgt:COMPILE_DEFINITIONS" title="COMPILE_DEFINITIONS"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">COMPILE_DEFINITIONS</span></code></a> and others.  They may also be used when using
commands to populate those properties, such as <span class="target" id="index-0-command:target_link_libraries"></span><a class="reference internal" href="../command/target_link_libraries.html#command:target_link_libraries" title="target_link_libraries"><code class="xref cmake cmake-command docutils literal"><span class="pre">target_link_libraries()</span></code></a>,
<span class="target" id="index-0-command:target_include_directories"></span><a class="reference internal" href="../command/target_include_directories.html#command:target_include_directories" title="target_include_directories"><code class="xref cmake cmake-command docutils literal"><span class="pre">target_include_directories()</span></code></a>, <span class="target" id="index-0-command:target_compile_definitions"></span><a class="reference internal" href="../command/target_compile_definitions.html#command:target_compile_definitions" title="target_compile_definitions"><code class="xref cmake cmake-command docutils literal"><span class="pre">target_compile_definitions()</span></code></a>
and others.</p>
<p>This means that they enable conditional linking, conditional
definitions used when compiling, and conditional include directories and
more.  The conditions may be based on the build configuration, target
properties, platform information or any other queryable information.</p>
</div>
<div class="section" id="logical-expressions">
<h2><a class="toc-backref" href="#id3">Logical Expressions</a><a class="headerlink" href="#logical-expressions" title="Permalink to this headline">¶</a></h2>
<p>Logical expressions are used to create conditional output.  The basic
expressions are the <code class="docutils literal"><span class="pre">0</span></code> and <code class="docutils literal"><span class="pre">1</span></code> expressions.  Because other logical
expressions evaluate to either <code class="docutils literal"><span class="pre">0</span></code> or <code class="docutils literal"><span class="pre">1</span></code>, they can be composed to
create conditional output:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$&lt;$&lt;CONFIG:Debug&gt;:DEBUG_MODE&gt;
</pre></div>
</div>
<p>expands to <code class="docutils literal"><span class="pre">DEBUG_MODE</span></code> when the <code class="docutils literal"><span class="pre">Debug</span></code> configuration is used, and
otherwise expands to nothing.</p>
<p>Available logical expressions are:</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">$&lt;BOOL:...&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if the <code class="docutils literal"><span class="pre">...</span></code> is true, else <code class="docutils literal"><span class="pre">0</span></code></dd>
<dt><code class="docutils literal"><span class="pre">$&lt;AND:?[,?]...&gt;</span></code></dt>
<dd><p class="first"><code class="docutils literal"><span class="pre">1</span></code> if all <code class="docutils literal"><span class="pre">?</span></code> are <code class="docutils literal"><span class="pre">1</span></code>, else <code class="docutils literal"><span class="pre">0</span></code></p>
<p class="last">The <code class="docutils literal"><span class="pre">?</span></code> must always be either <code class="docutils literal"><span class="pre">0</span></code> or <code class="docutils literal"><span class="pre">1</span></code> in boolean expressions.</p>
</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;OR:?[,?]...&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">0</span></code> if all <code class="docutils literal"><span class="pre">?</span></code> are <code class="docutils literal"><span class="pre">0</span></code>, else <code class="docutils literal"><span class="pre">1</span></code></dd>
<dt><code class="docutils literal"><span class="pre">$&lt;NOT:?&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">0</span></code> if <code class="docutils literal"><span class="pre">?</span></code> is <code class="docutils literal"><span class="pre">1</span></code>, else <code class="docutils literal"><span class="pre">1</span></code></dd>
<dt><code class="docutils literal"><span class="pre">$&lt;IF:?,true-value...,false-value...&gt;`</span></code></dt>
<dd><code class="docutils literal"><span class="pre">true-value...</span></code> if <code class="docutils literal"><span class="pre">?</span></code> is <code class="docutils literal"><span class="pre">1</span></code>, <code class="docutils literal"><span class="pre">false-value...</span></code> if <code class="docutils literal"><span class="pre">?</span></code> is <code class="docutils literal"><span class="pre">0</span></code></dd>
<dt><code class="docutils literal"><span class="pre">$&lt;STREQUAL:a,b&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if <code class="docutils literal"><span class="pre">a</span></code> is STREQUAL <code class="docutils literal"><span class="pre">b</span></code>, else <code class="docutils literal"><span class="pre">0</span></code></dd>
<dt><code class="docutils literal"><span class="pre">$&lt;EQUAL:a,b&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if <code class="docutils literal"><span class="pre">a</span></code> is EQUAL <code class="docutils literal"><span class="pre">b</span></code> in a numeric comparison, else <code class="docutils literal"><span class="pre">0</span></code></dd>
<dt><code class="docutils literal"><span class="pre">$&lt;CONFIG:cfg&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if config is <code class="docutils literal"><span class="pre">cfg</span></code>, else <code class="docutils literal"><span class="pre">0</span></code>. This is a case-insensitive comparison.
The mapping in <span class="target" id="index-0-prop_tgt:MAP_IMPORTED_CONFIG_&lt;CONFIG&gt;"></span><a class="reference internal" href="../prop_tgt/MAP_IMPORTED_CONFIG_CONFIG.html#prop_tgt:MAP_IMPORTED_CONFIG_&lt;CONFIG&gt;" title="MAP_IMPORTED_CONFIG_&lt;CONFIG&gt;"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">MAP_IMPORTED_CONFIG_&lt;CONFIG&gt;</span></code></a> is also considered by
this expression when it is evaluated on a property on an <span class="target" id="index-0-prop_tgt:IMPORTED"></span><a class="reference internal" href="../prop_tgt/IMPORTED.html#prop_tgt:IMPORTED" title="IMPORTED"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">IMPORTED</span></code></a>
target.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;PLATFORM_ID:comp&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if the CMake-id of the platform matches <code class="docutils literal"><span class="pre">comp</span></code>, otherwise <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;C_COMPILER_ID:comp&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if the CMake-id of the C compiler matches <code class="docutils literal"><span class="pre">comp</span></code>, otherwise <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;CXX_COMPILER_ID:comp&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if the CMake-id of the CXX compiler matches <code class="docutils literal"><span class="pre">comp</span></code>, otherwise <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;VERSION_LESS:v1,v2&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if <code class="docutils literal"><span class="pre">v1</span></code> is a version less than <code class="docutils literal"><span class="pre">v2</span></code>, else <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;VERSION_GREATER:v1,v2&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if <code class="docutils literal"><span class="pre">v1</span></code> is a version greater than <code class="docutils literal"><span class="pre">v2</span></code>, else <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;VERSION_EQUAL:v1,v2&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if <code class="docutils literal"><span class="pre">v1</span></code> is the same version as <code class="docutils literal"><span class="pre">v2</span></code>, else <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;VERSION_LESS_EQUAL:v1,v2&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if <code class="docutils literal"><span class="pre">v1</span></code> is a version less than or equal to <code class="docutils literal"><span class="pre">v2</span></code>, else <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;VERSION_GREATER_EQUAL:v1,v2&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if <code class="docutils literal"><span class="pre">v1</span></code> is a version greater than or equal to <code class="docutils literal"><span class="pre">v2</span></code>, else <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;C_COMPILER_VERSION:ver&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if the version of the C compiler matches <code class="docutils literal"><span class="pre">ver</span></code>, otherwise <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;CXX_COMPILER_VERSION:ver&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if the version of the CXX compiler matches <code class="docutils literal"><span class="pre">ver</span></code>, otherwise <code class="docutils literal"><span class="pre">0</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_POLICY:pol&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if the policy <code class="docutils literal"><span class="pre">pol</span></code> was NEW when the &#8216;head&#8217; target was created,
else <code class="docutils literal"><span class="pre">0</span></code>.  If the policy was not set, the warning message for the policy
will be emitted. This generator expression only works for a subset of
policies.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;COMPILE_FEATURES:feature[,feature]...&gt;</span></code></dt>
<dd><code class="docutils literal"><span class="pre">1</span></code> if all of the <code class="docutils literal"><span class="pre">feature</span></code> features are available for the &#8216;head&#8217;
target, and <code class="docutils literal"><span class="pre">0</span></code> otherwise. If this expression is used while evaluating
the link implementation of a target and if any dependency transitively
increases the required <span class="target" id="index-0-prop_tgt:C_STANDARD"></span><a class="reference internal" href="../prop_tgt/C_STANDARD.html#prop_tgt:C_STANDARD" title="C_STANDARD"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">C_STANDARD</span></code></a> or <span class="target" id="index-0-prop_tgt:CXX_STANDARD"></span><a class="reference internal" href="../prop_tgt/CXX_STANDARD.html#prop_tgt:CXX_STANDARD" title="CXX_STANDARD"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">CXX_STANDARD</span></code></a>
for the &#8216;head&#8217; target, an error is reported.  See the
<span class="target" id="index-0-manual:cmake-compile-features(7)"></span><a class="reference internal" href="cmake-compile-features.7.html#manual:cmake-compile-features(7)" title="cmake-compile-features(7)"><code class="xref cmake cmake-manual docutils literal"><span class="pre">cmake-compile-features(7)</span></code></a> manual for information on
compile features and a list of supported compilers.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;COMPILE_LANGUAGE:lang&gt;</span></code></dt>
<dd><p class="first"><code class="docutils literal"><span class="pre">1</span></code> when the language used for compilation unit matches <code class="docutils literal"><span class="pre">lang</span></code>,
otherwise <code class="docutils literal"><span class="pre">0</span></code>.  This expression used to specify compile options for
source files of a particular language in a target. For example, to specify
the use of the <code class="docutils literal"><span class="pre">-fno-exceptions</span></code> compile option (compiler id checks
elided):</p>
<div class="highlight-cmake"><div class="highlight"><pre><span></span><span class="nb">add_executable</span><span class="p">(</span><span class="s">myapp</span> <span class="s">main.cpp</span> <span class="s">foo.c</span> <span class="s">bar.cpp</span><span class="p">)</span>
<span class="nb">target_compile_options</span><span class="p">(</span><span class="s">myapp</span>
  <span class="s">PRIVATE</span> <span class="o">$&lt;</span><span class="nv">$&lt;COMPILE_LANGUAGE:CXX</span><span class="o">&gt;</span><span class="s">:-fno-exceptions&gt;</span>
<span class="p">)</span>
</pre></div>
</div>
<p>This generator expression has limited use because it is not possible to
use it with the Visual Studio generators.  Portable buildsystems would
not use this expression, and would create separate libraries for each
source file language instead:</p>
<div class="highlight-cmake"><div class="highlight"><pre><span></span><span class="nb">add_library</span><span class="p">(</span><span class="s">myapp_c</span> <span class="s">foo.c</span><span class="p">)</span>
<span class="nb">add_library</span><span class="p">(</span><span class="s">myapp_cxx</span> <span class="s">foo.c</span><span class="p">)</span>
<span class="nb">target_compile_options</span><span class="p">(</span><span class="s">myapp_cxx</span> <span class="s">PUBLIC</span> <span class="s">-fno-exceptions</span><span class="p">)</span>
<span class="nb">add_executable</span><span class="p">(</span><span class="s">myapp</span> <span class="s">main.cpp</span><span class="p">)</span>
<span class="nb">target_link_libraries</span><span class="p">(</span><span class="s">myapp</span> <span class="s">myapp_c</span> <span class="s">myapp_cxx</span><span class="p">)</span>
</pre></div>
</div>
<p>The <code class="docutils literal"><span class="pre">Makefile</span></code> and <code class="docutils literal"><span class="pre">Ninja</span></code> based generators can also use this
expression to specify compile-language specific compile definitions
and include directories:</p>
<div class="last highlight-cmake"><div class="highlight"><pre><span></span><span class="nb">add_executable</span><span class="p">(</span><span class="s">myapp</span> <span class="s">main.cpp</span> <span class="s">foo.c</span> <span class="s">bar.cpp</span><span class="p">)</span>
<span class="nb">target_compile_definitions</span><span class="p">(</span><span class="s">myapp</span>
  <span class="s">PRIVATE</span> <span class="o">$&lt;</span><span class="nv">$&lt;COMPILE_LANGUAGE:CXX</span><span class="o">&gt;</span><span class="s">:COMPILING_CXX&gt;</span>
<span class="p">)</span>
<span class="nb">target_include_directories</span><span class="p">(</span><span class="s">myapp</span>
  <span class="s">PRIVATE</span> <span class="o">$&lt;</span><span class="nv">$&lt;COMPILE_LANGUAGE:CXX</span><span class="o">&gt;</span><span class="s">:/opt/foo/cxx_headers&gt;</span>
<span class="p">)</span>
</pre></div>
</div>
</dd>
</dl>
</div>
<div class="section" id="informational-expressions">
<h2><a class="toc-backref" href="#id4">Informational Expressions</a><a class="headerlink" href="#informational-expressions" title="Permalink to this headline">¶</a></h2>
<p>These expressions expand to some information. The information may be used
directly, eg:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>include_directories(/usr/include/$&lt;CXX_COMPILER_ID&gt;/)
</pre></div>
</div>
<p>expands to <code class="docutils literal"><span class="pre">/usr/include/GNU/</span></code> or <code class="docutils literal"><span class="pre">/usr/include/Clang/</span></code> etc, depending on
the Id of the compiler.</p>
<p>These expressions may also may be combined with logical expressions:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$&lt;$&lt;VERSION_LESS:$&lt;CXX_COMPILER_VERSION&gt;,4.2.0&gt;:OLD_COMPILER&gt;
</pre></div>
</div>
<p>expands to <code class="docutils literal"><span class="pre">OLD_COMPILER</span></code> if the
<span class="target" id="index-0-variable:CMAKE_&lt;LANG&gt;_COMPILER_VERSION"></span><a class="reference internal" href="../variable/CMAKE_LANG_COMPILER_VERSION.html#variable:CMAKE_&lt;LANG&gt;_COMPILER_VERSION" title="CMAKE_&lt;LANG&gt;_COMPILER_VERSION"><code class="xref cmake cmake-variable docutils literal"><span class="pre">CMAKE_CXX_COMPILER_VERSION</span></code></a> is less
than 4.2.0.</p>
<p>Available informational expressions are:</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">$&lt;CONFIGURATION&gt;</span></code></dt>
<dd>Configuration name. Deprecated. Use <code class="docutils literal"><span class="pre">CONFIG</span></code> instead.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;CONFIG&gt;</span></code></dt>
<dd>Configuration name</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;PLATFORM_ID&gt;</span></code></dt>
<dd>The CMake-id of the platform.
See also the <span class="target" id="index-0-variable:CMAKE_SYSTEM_NAME"></span><a class="reference internal" href="../variable/CMAKE_SYSTEM_NAME.html#variable:CMAKE_SYSTEM_NAME" title="CMAKE_SYSTEM_NAME"><code class="xref cmake cmake-variable docutils literal"><span class="pre">CMAKE_SYSTEM_NAME</span></code></a> variable.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;C_COMPILER_ID&gt;</span></code></dt>
<dd>The CMake-id of the C compiler used.
See also the <span class="target" id="index-0-variable:CMAKE_&lt;LANG&gt;_COMPILER_ID"></span><a class="reference internal" href="../variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_&lt;LANG&gt;_COMPILER_ID" title="CMAKE_&lt;LANG&gt;_COMPILER_ID"><code class="xref cmake cmake-variable docutils literal"><span class="pre">CMAKE_&lt;LANG&gt;_COMPILER_ID</span></code></a> variable.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;CXX_COMPILER_ID&gt;</span></code></dt>
<dd>The CMake-id of the CXX compiler used.
See also the <span class="target" id="index-1-variable:CMAKE_&lt;LANG&gt;_COMPILER_ID"></span><a class="reference internal" href="../variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_&lt;LANG&gt;_COMPILER_ID" title="CMAKE_&lt;LANG&gt;_COMPILER_ID"><code class="xref cmake cmake-variable docutils literal"><span class="pre">CMAKE_&lt;LANG&gt;_COMPILER_ID</span></code></a> variable.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;C_COMPILER_VERSION&gt;</span></code></dt>
<dd>The version of the C compiler used.
See also the <span class="target" id="index-1-variable:CMAKE_&lt;LANG&gt;_COMPILER_VERSION"></span><a class="reference internal" href="../variable/CMAKE_LANG_COMPILER_VERSION.html#variable:CMAKE_&lt;LANG&gt;_COMPILER_VERSION" title="CMAKE_&lt;LANG&gt;_COMPILER_VERSION"><code class="xref cmake cmake-variable docutils literal"><span class="pre">CMAKE_&lt;LANG&gt;_COMPILER_VERSION</span></code></a> variable.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;CXX_COMPILER_VERSION&gt;</span></code></dt>
<dd>The version of the CXX compiler used.
See also the <span class="target" id="index-2-variable:CMAKE_&lt;LANG&gt;_COMPILER_VERSION"></span><a class="reference internal" href="../variable/CMAKE_LANG_COMPILER_VERSION.html#variable:CMAKE_&lt;LANG&gt;_COMPILER_VERSION" title="CMAKE_&lt;LANG&gt;_COMPILER_VERSION"><code class="xref cmake cmake-variable docutils literal"><span class="pre">CMAKE_&lt;LANG&gt;_COMPILER_VERSION</span></code></a> variable.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_FILE:tgt&gt;</span></code></dt>
<dd>Full path to main file (.exe, .so.1.2, .a) where <code class="docutils literal"><span class="pre">tgt</span></code> is the name of a target.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_FILE_NAME:tgt&gt;</span></code></dt>
<dd>Name of main file (.exe, .so.1.2, .a).</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_FILE_DIR:tgt&gt;</span></code></dt>
<dd>Directory of main file (.exe, .so.1.2, .a).</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_LINKER_FILE:tgt&gt;</span></code></dt>
<dd>File used to link (.a, .lib, .so) where <code class="docutils literal"><span class="pre">tgt</span></code> is the name of a target.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_LINKER_FILE_NAME:tgt&gt;</span></code></dt>
<dd>Name of file used to link (.a, .lib, .so).</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_LINKER_FILE_DIR:tgt&gt;</span></code></dt>
<dd>Directory of file used to link (.a, .lib, .so).</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_SONAME_FILE:tgt&gt;</span></code></dt>
<dd>File with soname (.so.3) where <code class="docutils literal"><span class="pre">tgt</span></code> is the name of a target.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_SONAME_FILE_NAME:tgt&gt;</span></code></dt>
<dd>Name of file with soname (.so.3).</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_SONAME_FILE_DIR:tgt&gt;</span></code></dt>
<dd>Directory of with soname (.so.3).</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_PDB_FILE:tgt&gt;</span></code></dt>
<dd><p class="first">Full path to the linker generated program database file (.pdb)
where <code class="docutils literal"><span class="pre">tgt</span></code> is the name of a target.</p>
<p class="last">See also the <span class="target" id="index-0-prop_tgt:PDB_NAME"></span><a class="reference internal" href="../prop_tgt/PDB_NAME.html#prop_tgt:PDB_NAME" title="PDB_NAME"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">PDB_NAME</span></code></a> and <span class="target" id="index-0-prop_tgt:PDB_OUTPUT_DIRECTORY"></span><a class="reference internal" href="../prop_tgt/PDB_OUTPUT_DIRECTORY.html#prop_tgt:PDB_OUTPUT_DIRECTORY" title="PDB_OUTPUT_DIRECTORY"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">PDB_OUTPUT_DIRECTORY</span></code></a>
target properties and their configuration specific variants
<span class="target" id="index-0-prop_tgt:PDB_NAME_&lt;CONFIG&gt;"></span><a class="reference internal" href="../prop_tgt/PDB_NAME_CONFIG.html#prop_tgt:PDB_NAME_&lt;CONFIG&gt;" title="PDB_NAME_&lt;CONFIG&gt;"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">PDB_NAME_&lt;CONFIG&gt;</span></code></a> and <span class="target" id="index-0-prop_tgt:PDB_OUTPUT_DIRECTORY_&lt;CONFIG&gt;"></span><a class="reference internal" href="../prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.html#prop_tgt:PDB_OUTPUT_DIRECTORY_&lt;CONFIG&gt;" title="PDB_OUTPUT_DIRECTORY_&lt;CONFIG&gt;"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">PDB_OUTPUT_DIRECTORY_&lt;CONFIG&gt;</span></code></a>.</p>
</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_PDB_FILE_NAME:tgt&gt;</span></code></dt>
<dd>Name of the linker generated program database file (.pdb).</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_PDB_FILE_DIR:tgt&gt;</span></code></dt>
<dd>Directory of the linker generated program database file (.pdb).</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_PROPERTY:tgt,prop&gt;</span></code></dt>
<dd><p class="first">Value of the property <code class="docutils literal"><span class="pre">prop</span></code> on the target <code class="docutils literal"><span class="pre">tgt</span></code>.</p>
<p class="last">Note that <code class="docutils literal"><span class="pre">tgt</span></code> is not added as a dependency of the target this
expression is evaluated on.</p>
</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_PROPERTY:prop&gt;</span></code></dt>
<dd>Value of the property <code class="docutils literal"><span class="pre">prop</span></code> on the target on which the generator
expression is evaluated.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;INSTALL_PREFIX&gt;</span></code></dt>
<dd>Content of the install prefix when the target is exported via
<span class="target" id="index-0-command:install"></span><a class="reference internal" href="../command/install.html#command:install" title="install"><code class="xref cmake cmake-command docutils literal"><span class="pre">install(EXPORT)</span></code></a> and empty otherwise.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;COMPILE_LANGUAGE&gt;</span></code></dt>
<dd>The compile language of source files when evaluating compile options. See
the unary version for notes about portability of this generator
expression.</dd>
</dl>
</div>
<div class="section" id="output-expressions">
<h2><a class="toc-backref" href="#id5">Output Expressions</a><a class="headerlink" href="#output-expressions" title="Permalink to this headline">¶</a></h2>
<p>These expressions generate output, in some cases depending on an input. These
expressions may be combined with other expressions for information or logical
comparison:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>-I$&lt;JOIN:$&lt;TARGET_PROPERTY:INCLUDE_DIRECTORIES&gt;, -I&gt;
</pre></div>
</div>
<p>generates a string of the entries in the <span class="target" id="index-1-prop_tgt:INCLUDE_DIRECTORIES"></span><a class="reference internal" href="../prop_tgt/INCLUDE_DIRECTORIES.html#prop_tgt:INCLUDE_DIRECTORIES" title="INCLUDE_DIRECTORIES"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">INCLUDE_DIRECTORIES</span></code></a> target
property with each entry preceded by <code class="docutils literal"><span class="pre">-I</span></code>. Note that a more-complete use
in this situation would require first checking if the INCLUDE_DIRECTORIES
property is non-empty:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>$&lt;$&lt;BOOL:${prop}&gt;:-I$&lt;JOIN:${prop}, -I&gt;&gt;
</pre></div>
</div>
<p>where <code class="docutils literal"><span class="pre">${prop}</span></code> refers to a helper variable:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="nb">set</span><span class="p">(</span><span class="n">prop</span> <span class="s2">&quot;$&lt;TARGET_PROPERTY:INCLUDE_DIRECTORIES&gt;&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Available output expressions are:</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">$&lt;0:...&gt;</span></code></dt>
<dd>Empty string (ignores <code class="docutils literal"><span class="pre">...</span></code>)</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;1:...&gt;</span></code></dt>
<dd>Content of <code class="docutils literal"><span class="pre">...</span></code></dd>
<dt><code class="docutils literal"><span class="pre">$&lt;JOIN:list,...&gt;</span></code></dt>
<dd>Joins the list with the content of <code class="docutils literal"><span class="pre">...</span></code></dd>
<dt><code class="docutils literal"><span class="pre">$&lt;ANGLE-R&gt;</span></code></dt>
<dd>A literal <code class="docutils literal"><span class="pre">&gt;</span></code>. Used to compare strings which contain a <code class="docutils literal"><span class="pre">&gt;</span></code> for example.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;COMMA&gt;</span></code></dt>
<dd>A literal <code class="docutils literal"><span class="pre">,</span></code>. Used to compare strings which contain a <code class="docutils literal"><span class="pre">,</span></code> for example.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;SEMICOLON&gt;</span></code></dt>
<dd>A literal <code class="docutils literal"><span class="pre">;</span></code>. Used to prevent list expansion on an argument with <code class="docutils literal"><span class="pre">;</span></code>.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_NAME:...&gt;</span></code></dt>
<dd>Marks <code class="docutils literal"><span class="pre">...</span></code> as being the name of a target.  This is required if exporting
targets to multiple dependent export sets.  The <code class="docutils literal"><span class="pre">...</span></code> must be a literal
name of a target- it may not contain generator expressions.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;LINK_ONLY:...&gt;</span></code></dt>
<dd>Content of <code class="docutils literal"><span class="pre">...</span></code> except when evaluated in a link interface while
propagating <a class="reference internal" href="cmake-buildsystem.7.html#target-usage-requirements"><span class="std std-ref">Transitive Usage Requirements</span></a>, in which case it is the
empty string.
Intended for use only in an <span class="target" id="index-0-prop_tgt:INTERFACE_LINK_LIBRARIES"></span><a class="reference internal" href="../prop_tgt/INTERFACE_LINK_LIBRARIES.html#prop_tgt:INTERFACE_LINK_LIBRARIES" title="INTERFACE_LINK_LIBRARIES"><code class="xref cmake cmake-prop_tgt docutils literal"><span class="pre">INTERFACE_LINK_LIBRARIES</span></code></a> target
property, perhaps via the <span class="target" id="index-1-command:target_link_libraries"></span><a class="reference internal" href="../command/target_link_libraries.html#command:target_link_libraries" title="target_link_libraries"><code class="xref cmake cmake-command docutils literal"><span class="pre">target_link_libraries()</span></code></a> command,
to specify private link dependencies without other usage requirements.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;INSTALL_INTERFACE:...&gt;</span></code></dt>
<dd>Content of <code class="docutils literal"><span class="pre">...</span></code> when the property is exported using <span class="target" id="index-1-command:install"></span><a class="reference internal" href="../command/install.html#command:install" title="install"><code class="xref cmake cmake-command docutils literal"><span class="pre">install(EXPORT)</span></code></a>,
and empty otherwise.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;BUILD_INTERFACE:...&gt;</span></code></dt>
<dd>Content of <code class="docutils literal"><span class="pre">...</span></code> when the property is exported using <span class="target" id="index-0-command:export"></span><a class="reference internal" href="../command/export.html#command:export" title="export"><code class="xref cmake cmake-command docutils literal"><span class="pre">export()</span></code></a>, or
when the target is used by another target in the same buildsystem. Expands to
the empty string otherwise.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;LOWER_CASE:...&gt;</span></code></dt>
<dd>Content of <code class="docutils literal"><span class="pre">...</span></code> converted to lower case.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;UPPER_CASE:...&gt;</span></code></dt>
<dd>Content of <code class="docutils literal"><span class="pre">...</span></code> converted to upper case.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;MAKE_C_IDENTIFIER:...&gt;</span></code></dt>
<dd>Content of <code class="docutils literal"><span class="pre">...</span></code> converted to a C identifier.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;TARGET_OBJECTS:objLib&gt;</span></code></dt>
<dd>List of objects resulting from build of <code class="docutils literal"><span class="pre">objLib</span></code>. <code class="docutils literal"><span class="pre">objLib</span></code> must be an
object of type <code class="docutils literal"><span class="pre">OBJECT_LIBRARY</span></code>.  This expression may only be used in
the sources of <span class="target" id="index-0-command:add_library"></span><a class="reference internal" href="../command/add_library.html#command:add_library" title="add_library"><code class="xref cmake cmake-command docutils literal"><span class="pre">add_library()</span></code></a> and <span class="target" id="index-0-command:add_executable"></span><a class="reference internal" href="../command/add_executable.html#command:add_executable" title="add_executable"><code class="xref cmake cmake-command docutils literal"><span class="pre">add_executable()</span></code></a>
commands.</dd>
<dt><code class="docutils literal"><span class="pre">$&lt;SHELL_PATH:...&gt;</span></code></dt>
<dd>Content of <code class="docutils literal"><span class="pre">...</span></code> converted to shell path style. For example, slashes are
converted to backslashes in Windows shells and drive letters are converted
to posix paths in MSYS shells. The <code class="docutils literal"><span class="pre">...</span></code> must be an absolute path.</dd>
</dl>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">cmake-generator-expressions(7)</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#logical-expressions">Logical Expressions</a></li>
<li><a class="reference internal" href="#informational-expressions">Informational Expressions</a></li>
<li><a class="reference internal" href="#output-expressions">Output Expressions</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="cmake-developer.7.html"
                        title="previous chapter">cmake-developer(7)</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="cmake-generators.7.html"
                        title="next chapter">cmake-generators(7)</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/manual/cmake-generator-expressions.7.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="cmake-generators.7.html" title="cmake-generators(7)"
             >next</a> |</li>
        <li class="right" >
          <a href="cmake-developer.7.html" title="cmake-developer(7)"
             >previous</a> |</li>
  <li>
    <img src="../_static/cmake-logo-16.png" alt=""
         style="vertical-align: middle; margin-top: -2px" />
  </li>
  <li>
    <a href="https://cmake.org/">CMake</a> &#187;
  </li>
  <li>
    <a href="../index.html">3.8.2 Documentation</a> &#187;
  </li>
 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2000-2017 Kitware, Inc. and Contributors.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.2.
    </div>
  </body>
</html>