1CMAKE-GENERATOR-EXPRESSIONS(7)       CMake      CMAKE-GENERATOR-EXPRESSIONS(7)
2
3
4

NAME

6       cmake-generator-expressions - CMake Generator Expressions
7

INTRODUCTION

9       Generator  expressions  are evaluated during build system generation to
10       produce information specific to each build configuration.
11
12       Generator expressions are allowed in the context of many target proper‐
13       ties,  such as LINK_LIBRARIES, INCLUDE_DIRECTORIES, COMPILE_DEFINITIONS
14       and others.  They may also be used  when  using  commands  to  populate
15       those     properties,    such    as    target_link_libraries(),    tar‐
16       get_include_directories(), target_compile_definitions() and others.
17
18       They enable conditional linking, conditional definitions used when com‐
19       piling,  conditional include directories, and more.  The conditions may
20       be based on the build configuration, target properties, platform infor‐
21       mation or any other queryable information.
22
23       Generator  expressions  have the form $<...>.  To avoid confusion, this
24       page deviates from most of the CMake documentation  in  that  it  omits
25       angular brackets <...> around placeholders like condition, string, tar‐
26       get, among others.
27
28       Generator expressions can be nested, as shown in most of  the  examples
29       below.
30

BOOLEAN GENERATOR EXPRESSIONS

32       Boolean expressions evaluate to either 0 or 1.  They are typically used
33       to construct the condition in a conditional generator expression.
34
35       Available boolean expressions are:
36
37   Logical Operators
38       $<BOOL:string>
39              Converts string to 0 or 1. Evaluates to 0 if any of the  follow‐
40              ing is true:
41
42              · string is empty,
43
44              · string  is  a  case-insensitive equal of 0, FALSE, OFF, N, NO,
45                IGNORE, or NOTFOUND, or
46
47              · string ends in the suffix -NOTFOUND (case-sensitive).
48
49              Otherwise evaluates to 1.
50
51       $<AND:conditions>
52              where conditions is a comma-separated list  of  boolean  expres‐
53              sions.  Evaluates to 1 if all conditions are 1.  Otherwise eval‐
54              uates to 0.
55
56       $<OR:conditions>
57              where conditions is a comma-separated list  of  boolean  expres‐
58              sions.   Evaluates  to 1 if at least one of the conditions is 1.
59              Otherwise evaluates to 0.
60
61       $<NOT:condition>
62              0 if condition is 1, else 1.
63
64   String Comparisons
65       $<STREQUAL:string1,string2>
66              1 if string1 and string2 are equal, else 0.  The  comparison  is
67              case-sensitive.  For a case-insensitive comparison, combine with
68              a string transforming generator expression,
69
70                 $<STREQUAL:$<UPPER_CASE:${foo}>,"BAR"> # "1" if ${foo} is any of "BAR", "Bar", "bar", ...
71
72       $<EQUAL:value1,value2>
73              1 if value1 and value2 are numerically equal, else 0.
74
75       $<IN_LIST:string,list>
76              1 if string is member of the semicolon-separated list,  else  0.
77              Uses case-sensitive comparisons.
78
79       $<VERSION_LESS:v1,v2>
80              1 if v1 is a version less than v2, else 0.
81
82       $<VERSION_GREATER:v1,v2>
83              1 if v1 is a version greater than v2, else 0.
84
85       $<VERSION_EQUAL:v1,v2>
86              1 if v1 is the same version as v2, else 0.
87
88       $<VERSION_LESS_EQUAL:v1,v2>
89              1 if v1 is a version less than or equal to v2, else 0.
90
91       $<VERSION_GREATER_EQUAL:v1,v2>
92              1 if v1 is a version greater than or equal to v2, else 0.
93
94   Variable Queries
95       $<TARGET_EXISTS:target>
96              1 if target exists, else 0.
97
98       $<CONFIG:cfg>
99              1  if config is cfg, else 0. This is a case-insensitive compari‐
100              son.  The mapping in MAP_IMPORTED_CONFIG_<CONFIG> is  also  con‐
101              sidered by this expression when it is evaluated on a property on
102              an IMPORTED target.
103
104       $<PLATFORM_ID:platform_ids>
105              where platform_ids is a comma-separated list.  1 if the  CMake’s
106              platform id matches any one of the entries in platform_ids, oth‐
107              erwise 0.  See also the CMAKE_SYSTEM_NAME variable.
108
109       $<C_COMPILER_ID:compiler_ids>
110              where compiler_ids is a comma-separated list.  1 if the  CMake’s
111              compiler  id of the C compiler matches any one of the entries in
112              compiler_ids,  otherwise  0.   See  also  the  CMAKE_<LANG>_COM‐
113              PILER_ID variable.
114
115       $<CXX_COMPILER_ID:compiler_ids>
116              where  compiler_ids is a comma-separated list.  1 if the CMake’s
117              compiler id of the CXX compiler matches any one of  the  entries
118              in  compiler_ids,  otherwise  0.  See also the CMAKE_<LANG>_COM‐
119              PILER_ID variable.
120
121       $<CUDA_COMPILER_ID:compiler_ids>
122              where compiler_ids is a comma-separated list.  1 if the  CMake’s
123              compiler  id of the CUDA compiler matches any one of the entries
124              in compiler_ids, otherwise 0.  See  also  the  CMAKE_<LANG>_COM‐
125              PILER_ID variable.
126
127       $<OBJC_COMPILER_ID:compiler_ids>
128              where  compiler_ids is a comma-separated list.  1 if the CMake’s
129              compiler id of the Objective-C compiler matches any one  of  the
130              entries   in   compiler_ids,   otherwise   0.    See   also  the
131              CMAKE_<LANG>_COMPILER_ID variable.
132
133       $<OBJCXX_COMPILER_ID:compiler_ids>
134              where compiler_ids is a comma-separated list.  1 if the  CMake’s
135              compiler id of the Objective-C++ compiler matches any one of the
136              entries  in   compiler_ids,   otherwise   0.    See   also   the
137              CMAKE_<LANG>_COMPILER_ID variable.
138
139       $<Fortran_COMPILER_ID:compiler_ids>
140              where  compiler_ids is a comma-separated list.  1 if the CMake’s
141              compiler id of the Fortran  compiler  matches  any  one  of  the
142              entries   in   compiler_ids,   otherwise   0.    See   also  the
143              CMAKE_<LANG>_COMPILER_ID variable.
144
145       $<C_COMPILER_VERSION:version>
146              1 if the version of the C compiler matches version, otherwise 0.
147              See also the CMAKE_<LANG>_COMPILER_VERSION variable.
148
149       $<CXX_COMPILER_VERSION:version>
150              1  if the version of the CXX compiler matches version, otherwise
151              0.  See also the CMAKE_<LANG>_COMPILER_VERSION variable.
152
153       $<CUDA_COMPILER_VERSION:version>
154              1 if the version of the CXX compiler matches version,  otherwise
155              0.  See also the CMAKE_<LANG>_COMPILER_VERSION variable.
156
157       $<OBJC_COMPILER_VERSION:version>
158              1 if the version of the OBJC compiler matches version, otherwise
159              0.  See also the CMAKE_<LANG>_COMPILER_VERSION variable.
160
161       $<OBJCXX_COMPILER_VERSION:version>
162              1 if the version of the OBJCXX compiler matches version,  other‐
163              wise 0.  See also the CMAKE_<LANG>_COMPILER_VERSION variable.
164
165       $<Fortran_COMPILER_VERSION:version>
166              1 if the version of the Fortran compiler matches version, other‐
167              wise 0.  See also the CMAKE_<LANG>_COMPILER_VERSION variable.
168
169       $<TARGET_POLICY:policy>
170              1 if the policy was NEW when the ‘head’ target was created, else
171              0.   If the policy was not set, the warning message for the pol‐
172              icy will be emitted. This generator expression only works for  a
173              subset of policies.
174
175       $<COMPILE_FEATURES:features>
176              where features is a comma-spearated list.  Evaluates to 1 if all
177              of the features are available for the ‘head’ target, and 0  oth‐
178              erwise.  If  this  expression  is used while evaluating the link
179              implementation of a target and if  any  dependency  transitively
180              increases the required C_STANDARD or CXX_STANDARD for the ‘head’
181              target, an error is reported.  See the cmake-compile-features(7)
182              manual  for  information  on compile features and a list of sup‐
183              ported compilers.
184
185       $<COMPILE_LANG_AND_ID:language,compiler_ids>
186              1 when the language used for compilation unit  matches  language
187              and the CMake’s compiler id of the language compiler matches any
188              one of the entries in compiler_ids, otherwise 0. This expression
189              is  a  short form for the combination of $<COMPILE_LANGUAGE:lan‐
190              guage> and $<LANG_COMPILER_ID:compiler_ids>. This expression may
191              be  used  to  specify  compile options, compile definitions, and
192              include directories for source files of  a  particular  language
193              and compiler combination in a target. For example:
194
195                 add_executable(myapp main.cpp foo.c bar.cpp zot.cu)
196                 target_compile_definitions(myapp
197                   PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang>:COMPILING_CXX_WITH_CLANG>
198                           $<$<COMPILE_LANG_AND_ID:CXX,Intel>:COMPILING_CXX_WITH_INTEL>
199                           $<$<COMPILE_LANG_AND_ID:C,Clang>:COMPILING_C_WITH_CLANG>
200                 )
201
202              This specifies the use of different compile definitions based on
203              both the compiler id and compilation language. This example will
204              have a COMPILING_CXX_WITH_CLANG compile definition when Clang is
205              the CXX compiler, and COMPILING_CXX_WITH_INTEL when Intel is the
206              CXX  compiler.   Likewise  when  the C compiler is Clang it will
207              only see the  COMPILING_C_WITH_CLANG definition.
208
209              Without the COMPILE_LANG_AND_ID generator  expression  the  same
210              logic would be expressed as:
211
212                 target_compile_definitions(myapp
213                   PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:AppleClang,Clang>>:COMPILING_CXX_WITH_CLANG>
214                           $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Intel>>:COMPILING_CXX_WITH_INTEL>
215                           $<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:Clang>>:COMPILING_C_WITH_CLANG>
216                 )
217
218       $<COMPILE_LANGUAGE:languages>
219              1 when the language used for compilation unit matches any of the
220              entries in languages, otherwise 0.  This expression may be  used
221              to  specify  compile  options,  compile definitions, and include
222              directories for source files of a particular language in a  tar‐
223              get. For example:
224
225                 add_executable(myapp main.cpp foo.c bar.cpp zot.cu)
226                 target_compile_options(myapp
227                   PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
228                 )
229                 target_compile_definitions(myapp
230                   PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX>
231                           $<$<COMPILE_LANGUAGE:CUDA>:COMPILING_CUDA>
232                 )
233                 target_include_directories(myapp
234                   PRIVATE $<$<COMPILE_LANGUAGE:CXX,CUDA>:/opt/foo/headers>
235                 )
236
237              This  specifies  the  use of the -fno-exceptions compile option,
238              COMPILING_CXX compile definition, and cxx_headers include direc‐
239              tory  for  C++ only (compiler id checks elided).  It also speci‐
240              fies a COMPILING_CUDA compile definition for CUDA.
241
242              Note that with Visual Studio Generators and Xcode  there  is  no
243              way  to  represent  target-wide  compile  definitions or include
244              directories separately for C and CXX languages.  Also, with Vis‐
245              ual  Studio  Generators there is no way to represent target-wide
246              flags separately for C and CXX languages.  Under  these  genera‐
247              tors,  expressions  for both C and C++ sources will be evaluated
248              using CXX if there are any C++ sources and otherwise using C.  A
249              workaround  is to create separate libraries for each source file
250              language instead:
251
252                 add_library(myapp_c foo.c)
253                 add_library(myapp_cxx bar.cpp)
254                 target_compile_options(myapp_cxx PUBLIC -fno-exceptions)
255                 add_executable(myapp main.cpp)
256                 target_link_libraries(myapp myapp_c myapp_cxx)
257

STRING-VALUED GENERATOR EXPRESSIONS

259       These expressions expand to some string.  For example,
260
261          include_directories(/usr/include/$<CXX_COMPILER_ID>/)
262
263       expands to /usr/include/GNU/ or /usr/include/Clang/ etc,  depending  on
264       the compiler identifier.
265
266       String-valued  expressions may also be combined with other expressions.
267       Here an example for a string-valued expression within a boolean expres‐
268       sions within a conditional expression:
269
270          $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,4.2.0>:OLD_COMPILER>
271
272       expands  to OLD_COMPILER if the CMAKE_CXX_COMPILER_VERSION is less than
273       4.2.0.
274
275       And here two nested string-valued expressions:
276
277          -I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I>
278
279       generates a string of the entries  in  the  INCLUDE_DIRECTORIES  target
280       property with each entry preceded by -I.
281
282       Expanding  on  the previous example, if one first wants to check if the
283       INCLUDE_DIRECTORIES property is non-empty,  then  it  is  advisable  to
284       introduce a helper variable to keep the code readable:
285
286          set(prop "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>") # helper variable
287          $<$<BOOL:${prop}>:-I$<JOIN:${prop}, -I>>
288
289       The following string-valued generator expressions are available:
290
291   Escaped Characters
292       String  literals to escape the special meaning a character would other‐
293       wise have:
294
295       $<ANGLE-R>
296              A literal >. Used for example to compare strings that contain  a
297              >.
298
299       $<COMMA>
300              A literal ,. Used for example to compare strings which contain a
301              ,.
302
303       $<SEMICOLON>
304              A literal ;. Used to prevent list expansion on an argument  with
305              ;.
306
307   Conditional Expressions
308       Conditional  generator  expressions  depend on a boolean condition that
309       must be 0 or 1.
310
311       $<condition:true_string>
312              Evaluates to true_string if condition is 1.  Otherwise evaluates
313              to the empty string.
314
315       $<IF:condition,true_string,false_string>
316              Evaluates to true_string if condition is 1.  Otherwise evaluates
317              to false_string.
318
319       Typically, the  condition  is  a  boolean  generator  expression.   For
320       instance,
321
322          $<$<CONFIG:Debug>:DEBUG_MODE>
323
324       expands  to DEBUG_MODE when the Debug configuration is used, and other‐
325       wise expands to the empty string.
326
327   String Transformations
328       $<JOIN:list,string>
329              Joins the list with the content of string.
330
331       $<REMOVE_DUPLICATES:list>
332              Removes duplicated items in the given list.
333
334       $<FILTER:list,INCLUDE|EXCLUDE,regex>
335              Includes or removes items  from  list  that  match  the  regular
336              expression regex.
337
338       $<LOWER_CASE:string>
339              Content of string converted to lower case.
340
341       $<UPPER_CASE:string>
342              Content of string converted to upper case.
343
344       $<GENEX_EVAL:expr>
345              Content  of expr evaluated as a generator expression in the cur‐
346              rent context. This enables consumption of generator  expressions
347              whose evaluation results itself in generator expressions.
348
349       $<TARGET_GENEX_EVAL:tgt,expr>
350              Content  of expr evaluated as a generator expression in the con‐
351              text of tgt target. This enables consumption  of  custom  target
352              properties that themselves contain generator expressions.
353
354              Having  the capability to evaluate generator expressions is very
355              useful when you want to manage custom properties supporting gen‐
356              erator expressions.  For example:
357
358                 add_library(foo ...)
359
360                 set_property(TARGET foo PROPERTY
361                   CUSTOM_KEYS $<$<CONFIG:DEBUG>:FOO_EXTRA_THINGS>
362                 )
363
364                 add_custom_target(printFooKeys
365                   COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:foo,CUSTOM_KEYS>
366                 )
367
368              This  naive implementation of the printFooKeys custom command is
369              wrong because CUSTOM_KEYS target property is not  evaluated  and
370              the     content    is    passed    as    is    (i.e.    $<$<CON‐
371              FIG:DEBUG>:FOO_EXTRA_THINGS>).
372
373              To have the expected result (i.e. FOO_EXTRA_THINGS if config  is
374              Debug),  it is required to evaluate the output of $<TARGET_PROP‐
375              ERTY:foo,CUSTOM_KEYS>:
376
377                 add_custom_target(printFooKeys
378                   COMMAND ${CMAKE_COMMAND} -E
379                     echo $<TARGET_GENEX_EVAL:foo,$<TARGET_PROPERTY:foo,CUSTOM_KEYS>>
380                 )
381
382   Variable Queries
383       $<CONFIG>
384              Configuration name.
385
386       $<CONFIGURATION>
387              Configuration name.  Deprecated  since  CMake  3.0.  Use  CONFIG
388              instead.
389
390       $<PLATFORM_ID>
391              The current system’s CMake platform id.  See also the CMAKE_SYS‐
392              TEM_NAME variable.
393
394       $<C_COMPILER_ID>
395              The CMake’s compiler id of the C compiler used.   See  also  the
396              CMAKE_<LANG>_COMPILER_ID variable.
397
398       $<CXX_COMPILER_ID>
399              The  CMake’s compiler id of the CXX compiler used.  See also the
400              CMAKE_<LANG>_COMPILER_ID variable.
401
402       $<CUDA_COMPILER_ID>
403              The CMake’s compiler id of the CUDA compiler used.  See also the
404              CMAKE_<LANG>_COMPILER_ID variable.
405
406       $<OBJC_COMPILER_ID>
407              The CMake’s compiler id of the OBJC compiler used.  See also the
408              CMAKE_<LANG>_COMPILER_ID variable.
409
410       $<OBJCXX_COMPILER_ID>
411              The CMake’s compiler id of the OBJCXX compiler used.   See  also
412              the CMAKE_<LANG>_COMPILER_ID variable.
413
414       $<Fortran_COMPILER_ID>
415              The  CMake’s compiler id of the Fortran compiler used.  See also
416              the CMAKE_<LANG>_COMPILER_ID variable.
417
418       $<C_COMPILER_VERSION>
419              The  version  of  the   C   compiler   used.    See   also   the
420              CMAKE_<LANG>_COMPILER_VERSION variable.
421
422       $<CXX_COMPILER_VERSION>
423              The   version   of   the   CXX  compiler  used.   See  also  the
424              CMAKE_<LANG>_COMPILER_VERSION variable.
425
426       $<CUDA_COMPILER_VERSION>
427              The  version  of  the  CUDA  compiler  used.    See   also   the
428              CMAKE_<LANG>_COMPILER_VERSION variable.
429
430       $<OBJC_COMPILER_VERSION>
431              The   version   of   the  OBJC  compiler  used.   See  also  the
432              CMAKE_<LANG>_COMPILER_VERSION variable.
433
434       $<OBJCXX_COMPILER_VERSION>
435              The  version  of  the  OBJCXX  compiler  used.   See  also   the
436              CMAKE_<LANG>_COMPILER_VERSION variable.
437
438       $<Fortran_COMPILER_VERSION>
439              The  version  of  the  Fortran  compiler  used.   See  also  the
440              CMAKE_<LANG>_COMPILER_VERSION variable.
441
442       $<COMPILE_LANGUAGE>
443              The compile language of source  files  when  evaluating  compile
444              options.   See  the  related  boolean  expression $<COMPILE_LAN‐
445              GUAGE:language> for notes about the portability of this  genera‐
446              tor expression.
447
448   Target-Dependent Queries
449       $<TARGET_NAME_IF_EXISTS:tgt>
450              Expands  to  the tgt if the given target exists, an empty string
451              otherwise.
452
453       $<TARGET_FILE:tgt>
454              Full path to main file (.exe, .so.1.2, .a) where tgt is the name
455              of a target.
456
457       $<TARGET_FILE_BASE_NAME:tgt>
458              Base name of main file where tgt is the name of a target.
459
460              The  base  name  corresponds to the target file name (see $<TAR‐
461              GET_FILE_NAME:tgt>) without prefix and suffix. For  example,  if
462              target file name is libbase.so, the base name is base.
463
464              See  also  the  OUTPUT_NAME,  ARCHIVE_OUTPUT_NAME,  LIBRARY_OUT‐
465              PUT_NAME and RUNTIME_OUTPUT_NAME  target  properties  and  their
466              configuration   specific   variants   OUTPUT_NAME_<CONFIG>,  AR‐
467              CHIVE_OUTPUT_NAME_<CONFIG>,   LIBRARY_OUTPUT_NAME_<CONFIG>   and
468              RUNTIME_OUTPUT_NAME_<CONFIG>.
469
470              The  <CONFIG>_POSTFIX  and  DEBUG_POSTFIX  target properties can
471              also be considered.
472
473              Note that tgt is not added as a dependency of  the  target  this
474              expression is evaluated on.
475
476       $<TARGET_FILE_PREFIX:tgt>
477              Prefix of main file where tgt is the name of a target.
478
479              See also the PREFIX target property.
480
481              Note  that  tgt  is not added as a dependency of the target this
482              expression is evaluated on.
483
484       $<TARGET_FILE_SUFFIX:tgt>
485              Suffix of main file where tgt is the name of a target.
486
487              The suffix corresponds to the file extension (such as  “.so”  or
488              “.exe”).
489
490              See also the SUFFIX target property.
491
492              Note  that  tgt  is not added as a dependency of the target this
493              expression is evaluated on.
494
495       $<TARGET_FILE_NAME:tgt>
496              Name of main file (.exe, .so.1.2, .a).
497
498       $<TARGET_FILE_DIR:tgt>
499              Directory of main file (.exe, .so.1.2, .a).
500
501       $<TARGET_LINKER_FILE:tgt>
502              File used to link (.a, .lib, .so) where tgt is  the  name  of  a
503              target.
504
505       $<TARGET_LINKER_FILE_BASE_NAME:tgt>
506              Base  name  of file used to link where tgt is the name of a tar‐
507              get.
508
509              The base name corresponds to the target linker  file  name  (see
510              $<TARGET_LINKER_FILE_NAME:tgt>)  without  prefix and suffix. For
511              example, if target file name is  libbase.a,  the  base  name  is
512              base.
513
514              See  also the OUTPUT_NAME, ARCHIVE_OUTPUT_NAME, and LIBRARY_OUT‐
515              PUT_NAME target  properties  and  their  configuration  specific
516              variants  OUTPUT_NAME_<CONFIG>, ARCHIVE_OUTPUT_NAME_<CONFIG> and
517              LIBRARY_OUTPUT_NAME_<CONFIG>.
518
519              The <CONFIG>_POSTFIX and  DEBUG_POSTFIX  target  properties  can
520              also be considered.
521
522              Note  that  tgt  is not added as a dependency of the target this
523              expression is evaluated on.
524
525       $<TARGET_LINKER_FILE_PREFIX:tgt>
526              Prefix of file used to link where tgt is the name of a target.
527
528              See also the PREFIX and IMPORT_PREFIX target properties.
529
530              Note that tgt is not added as a dependency of  the  target  this
531              expression is evaluated on.
532
533       $<TARGET_LINKER_FILE_SUFFIX:tgt>
534              Suffix of file used to link where tgt is the name of a target.
535
536              The  suffix  corresponds to the file extension (such as “.so” or
537              “.lib”).
538
539              See also the SUFFIX and IMPORT_SUFFIX target properties.
540
541              Note that tgt is not added as a dependency of  the  target  this
542              expression is evaluated on.
543
544       $<TARGET_LINKER_FILE_NAME:tgt>
545              Name of file used to link (.a, .lib, .so).
546
547       $<TARGET_LINKER_FILE_DIR:tgt>
548              Directory of file used to link (.a, .lib, .so).
549
550       $<TARGET_SONAME_FILE:tgt>
551              File with soname (.so.3) where tgt is the name of a target.
552
553       $<TARGET_SONAME_FILE_NAME:tgt>
554              Name of file with soname (.so.3).
555
556       $<TARGET_SONAME_FILE_DIR:tgt>
557              Directory of with soname (.so.3).
558
559       $<TARGET_PDB_FILE:tgt>
560              Full  path  to the linker generated program database file (.pdb)
561              where tgt is the name of a target.
562
563              See also the PDB_NAME and PDB_OUTPUT_DIRECTORY target properties
564              and  their configuration specific variants PDB_NAME_<CONFIG> and
565              PDB_OUTPUT_DIRECTORY_<CONFIG>.
566
567       $<TARGET_PDB_FILE_BASE_NAME:tgt>
568              Base name of the linker generated program database  file  (.pdb)
569              where tgt is the name of a target.
570
571              The  base  name  corresponds  to  the  target PDB file name (see
572              $<TARGET_PDB_FILE_NAME:tgt>)  without  prefix  and  suffix.  For
573              example, if target file name is base.pdb, the base name is base.
574
575              See also the PDB_NAME target property and its configuration spe‐
576              cific variant PDB_NAME_<CONFIG>.
577
578              The <CONFIG>_POSTFIX and  DEBUG_POSTFIX  target  properties  can
579              also be considered.
580
581              Note  that  tgt  is not added as a dependency of the target this
582              expression is evaluated on.
583
584       $<TARGET_PDB_FILE_NAME:tgt>
585              Name of the linker generated program database file (.pdb).
586
587       $<TARGET_PDB_FILE_DIR:tgt>
588              Directory of the linker generated program database file (.pdb).
589
590       $<TARGET_BUNDLE_DIR:tgt>
591              Full path to the  bundle  directory  (my.app,  my.framework,  or
592              my.bundle) where tgt is the name of a target.
593
594       $<TARGET_BUNDLE_CONTENT_DIR:tgt>
595              Full  path to the bundle content directory where tgt is the name
596              of a target. For the macOS  SDK  it  leads  to  my.app/Contents,
597              my.framework,  or  my.bundle/Contents.  For all other SDKs (e.g.
598              iOS) it leads to my.app, my.framework, or my.bundle due  to  the
599              flat bundle structure.
600
601       $<TARGET_PROPERTY:tgt,prop>
602              Value of the property prop on the target tgt.
603
604              Note  that  tgt  is not added as a dependency of the target this
605              expression is evaluated on.
606
607       $<TARGET_PROPERTY:prop>
608              Value of the property prop on the target on which the  generator
609              expression  is evaluated. Note that for generator expressions in
610              Target Usage Requirements this is the value of the  property  on
611              the  consuming  target  rather  than  the  target specifying the
612              requirement.
613
614       $<INSTALL_PREFIX>
615              Content of the install prefix when the target  is  exported  via
616              install(EXPORT),  or  when  evaluated  in  INSTALL_NAME_DIR, and
617              empty otherwise.
618
619   Output-Related Expressions
620       $<TARGET_NAME:...>
621              Marks ... as being the name of a target.  This  is  required  if
622              exporting  targets  to  multiple dependent export sets.  The ...
623              must be a literal name of a target- it may not contain generator
624              expressions.
625
626       $<LINK_ONLY:...>
627              Content  of  ... except when evaluated in a link interface while
628              propagating Target Usage Requirements, in which case it  is  the
629              empty   string.    Intended   for   use   only   in   an  INTER‐
630              FACE_LINK_LIBRARIES  target  property,  perhaps  via  the   tar‐
631              get_link_libraries()  command, to specify private link dependen‐
632              cies without other usage requirements.
633
634       $<INSTALL_INTERFACE:...>
635              Content  of  ...   when   the   property   is   exported   using
636              install(EXPORT), and empty otherwise.
637
638       $<BUILD_INTERFACE:...>
639              Content  of ... when the property is exported using export(), or
640              when the target is used by another target in the same  buildsys‐
641              tem. Expands to the empty string otherwise.
642
643       $<MAKE_C_IDENTIFIER:...>
644              Content of ... converted to a C identifier.  The conversion fol‐
645              lows the same behavior as string(MAKE_C_IDENTIFIER).
646
647       $<TARGET_OBJECTS:objLib>
648              List of objects resulting from build of objLib.
649
650       $<SHELL_PATH:...>
651              Content of ... converted  to  shell  path  style.  For  example,
652              slashes are converted to backslashes in Windows shells and drive
653              letters are converted to posix paths in  MSYS  shells.  The  ...
654              must  be an absolute path.  The ... may be a semicolon-separated
655              list of paths, in which case each path is converted individually
656              and a result list is generated using the shell path separator (:
657              on POSIX and ; on Windows).  Be sure  to  enclose  the  argument
658              containing  this  genex in double quotes in CMake source code so
659              that ; does not split arguments.
660

DEBUGGING

662       Since generator expressions are  evaluated  during  generation  of  the
663       buildsystem,  and  not during processing of CMakeLists.txt files, it is
664       not possible to inspect their result with the message() command.
665
666       One possible way to generate debug messages is to add a custom target,
667
668          add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} -E echo "$<...>")
669
670       The shell command make genexdebug (invoked after  execution  of  cmake)
671       would then print the result of $<...>.
672
673       Another way is to write debug messages to a file:
674
675          file(GENERATE OUTPUT filename CONTENT "$<...>")
676
678       2000-2020 Kitware, Inc. and Contributors
679
680
681
682
6833.17.2                           Apr 28, 2020   CMAKE-GENERATOR-EXPRESSIONS(7)
Impressum