| .\" Man page generated from reStructuredText. |
| . |
| . |
| .nr rst2man-indent-level 0 |
| . |
| .de1 rstReportMargin |
| \\$1 \\n[an-margin] |
| level \\n[rst2man-indent-level] |
| level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] |
| - |
| \\n[rst2man-indent0] |
| \\n[rst2man-indent1] |
| \\n[rst2man-indent2] |
| .. |
| .de1 INDENT |
| .\" .rstReportMargin pre: |
| . RS \\$1 |
| . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] |
| . nr rst2man-indent-level +1 |
| .\" .rstReportMargin post: |
| .. |
| .de UNINDENT |
| . RE |
| .\" indent \\n[an-margin] |
| .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] |
| .nr rst2man-indent-level -1 |
| .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] |
| .in \\n[rst2man-indent\\n[rst2man-indent-level]]u |
| .. |
| .TH "CMAKE-GENERATOR-EXPRESSIONS" "7" "Jan 23, 2025" "3.31.5" "CMake" |
| .SH NAME |
| cmake-generator-expressions \- CMake Generator Expressions |
| .SH INTRODUCTION |
| .sp |
| Generator expressions are evaluated during build system generation to produce |
| information specific to each build configuration. They have the form |
| \fB$<...>\fP\&. For example: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| target_include_directories(tgt PRIVATE /opt/include/$<CXX_COMPILER_ID>) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| This would expand to \fB/opt/include/GNU\fP, \fB/opt/include/Clang\fP, etc. |
| depending on the C++ compiler used. |
| .sp |
| Generator expressions are allowed in the context of many target properties, |
| such as \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link', \X'tty: link #prop_tgt:INCLUDE_DIRECTORIES'\fI\%INCLUDE_DIRECTORIES\fP\X'tty: link', |
| \X'tty: link #prop_tgt:COMPILE_DEFINITIONS'\fI\%COMPILE_DEFINITIONS\fP\X'tty: link' and others. They may also be used when using |
| commands to populate those properties, such as \X'tty: link #command:target_link_libraries'\fI\%target_link_libraries()\fP\X'tty: link', |
| \X'tty: link #command:target_include_directories'\fI\%target_include_directories()\fP\X'tty: link', \X'tty: link #command:target_compile_definitions'\fI\%target_compile_definitions()\fP\X'tty: link' |
| and others. They enable conditional linking, conditional definitions used when |
| compiling, conditional include directories, and more. The conditions may be |
| based on the build configuration, target properties, platform information, |
| or any other queryable information. |
| .sp |
| Generator expressions can be nested: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| target_compile_definitions(tgt PRIVATE |
| $<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,4.2.0>:OLD_COMPILER> |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| The above would expand to \fBOLD_COMPILER\fP if the |
| \X'tty: link #variable:CMAKE_<LANG>_COMPILER_VERSION'\fI\%CMAKE_CXX_COMPILER_VERSION\fP\X'tty: link' is less |
| than 4.2.0. |
| .SH WHITESPACE AND QUOTING |
| .sp |
| Generator expressions are typically parsed after command arguments. |
| If a generator expression contains spaces, new lines, semicolons or |
| other characters that may be interpreted as command argument separators, |
| the whole expression should be surrounded by quotes when passed to a |
| command. Failure to do so may result in the expression being split and |
| it may no longer be recognized as a generator expression. |
| .sp |
| When using \X'tty: link #command:add_custom_command'\fI\%add_custom_command()\fP\X'tty: link' or \X'tty: link #command:add_custom_target'\fI\%add_custom_target()\fP\X'tty: link', |
| use the \fBVERBATIM\fP and \fBCOMMAND_EXPAND_LISTS\fP options to obtain robust |
| argument splitting and quoting. |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| # WRONG: Embedded space will be treated as an argument separator. |
| # This ends up not being seen as a generator expression at all. |
| add_custom_target(run_some_tool |
| COMMAND some_tool \-I$<JOIN:$<TARGET_PROPERTY:tgt,INCLUDE_DIRECTORIES>, \-I> |
| VERBATIM |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| # Better, but still not robust. Quotes prevent the space from splitting the |
| # expression. However, the tool will receive the expanded value as a single |
| # argument. |
| add_custom_target(run_some_tool |
| COMMAND some_tool \(dq\-I$<JOIN:$<TARGET_PROPERTY:tgt,INCLUDE_DIRECTORIES>, \-I>\(dq |
| VERBATIM |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| # Nearly correct. Using a semicolon to separate arguments and adding the |
| # COMMAND_EXPAND_LISTS option means that paths with spaces will be handled |
| # correctly. Quoting the whole expression ensures it is seen as a generator |
| # expression. But if the target property is empty, we will get a bare \-I |
| # with nothing after it. |
| add_custom_target(run_some_tool |
| COMMAND some_tool \(dq\-I$<JOIN:$<TARGET_PROPERTY:tgt,INCLUDE_DIRECTORIES>,;\-I>\(dq |
| COMMAND_EXPAND_LISTS |
| VERBATIM |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Using variables to build up a more complex generator expression is also a |
| good way to reduce errors and improve readability. The above example can be |
| improved further like so: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| # The $<BOOL:...> check prevents adding anything if the property is empty, |
| # assuming the property value cannot be one of CMake\(aqs false constants. |
| set(prop \(dq$<TARGET_PROPERTY:tgt,INCLUDE_DIRECTORIES>\(dq) |
| add_custom_target(run_some_tool |
| COMMAND some_tool \(dq$<$<BOOL:${prop}>:\-I$<JOIN:${prop},;\-I>>\(dq |
| COMMAND_EXPAND_LISTS |
| VERBATIM |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Finally, the above example can be expressed in a more simple and robust way |
| using an alternate generator expression: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_custom_target(run_some_tool |
| COMMAND some_tool \(dq$<LIST:TRANSFORM,$<TARGET_PROPERTY:tgt,INCLUDE_DIRECTORIES>,PREPEND,\-I>\(dq |
| COMMAND_EXPAND_LISTS |
| VERBATIM |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| A common mistake is to try to split a generator expression across multiple |
| lines with indenting: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| # WRONG: New lines and spaces all treated as argument separators, so the |
| # generator expression is split and not recognized correctly. |
| target_compile_definitions(tgt PRIVATE |
| $<$<AND: |
| $<CXX_COMPILER_ID:GNU>, |
| $<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,5> |
| >:HAVE_5_OR_LATER> |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Again, use helper variables with well\-chosen names to build up a readable |
| expression instead: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| set(is_gnu \(dq$<CXX_COMPILER_ID:GNU>\(dq) |
| set(v5_or_later \(dq$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,5>\(dq) |
| set(meet_requirements \(dq$<AND:${is_gnu},${v5_or_later}>\(dq) |
| target_compile_definitions(tgt PRIVATE |
| \(dq$<${meet_requirements}:HAVE_5_OR_LATER>\(dq |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .SH DEBUGGING |
| .sp |
| Since generator expressions are evaluated during generation of the buildsystem, |
| and not during processing of \fBCMakeLists.txt\fP files, it is not possible to |
| inspect their result with the \X'tty: link #command:message'\fI\%message()\fP\X'tty: link' command. One possible way |
| to generate debug messages is to add a custom target: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} \-E echo \(dq$<...>\(dq) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| After running \fBcmake\fP, you can then build the \fBgenexdebug\fP target to print |
| the result of the \fB$<...>\fP expression (i.e. run the command |
| \X'tty: link #cmdoption-cmake-build-t'\fI\%cmake \-\-build ... \-\-target genexdebug\fP\X'tty: link'). |
| .sp |
| Another way is to write debug messages to a file with \X'tty: link #generate'\fI\%file(GENERATE)\fP\X'tty: link': |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| file(GENERATE OUTPUT filename CONTENT \(dq$<...>\(dq) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .SH GENERATOR EXPRESSION REFERENCE |
| .sp |
| \fBNOTE:\fP |
| .INDENT 0.0 |
| .INDENT 3.5 |
| This reference deviates from most of the CMake documentation in that it |
| omits angular brackets \fB<...>\fP around placeholders like \fBcondition\fP, |
| \fBstring\fP, \fBtarget\fP, etc. This is to prevent an opportunity for those |
| placeholders to be misinterpreted as generator expressions. |
| .UNINDENT |
| .UNINDENT |
| .SS Conditional Expressions |
| .sp |
| A fundamental category of generator expressions relates to conditional logic. |
| Two forms of conditional generator expressions are supported: |
| .INDENT 0.0 |
| .TP |
| .B $<condition:true_string> |
| Evaluates to \fBtrue_string\fP if \fBcondition\fP is \fB1\fP, or an empty string |
| if \fBcondition\fP evaluates to \fB0\fP\&. Any other value for \fBcondition\fP |
| results in an error. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<IF:condition,true_string,false_string> |
| Added in version 3.8. |
| |
| .sp |
| Evaluates to \fBtrue_string\fP if \fBcondition\fP is \fB1\fP, or \fBfalse_string\fP |
| if \fBcondition\fP is \fB0\fP\&. Any other value for \fBcondition\fP results in an |
| error. |
| .sp |
| Added in version 3.28: This generator expression short\-circuits such that generator expressions in |
| \fBfalse_string\fP will not evaluate when \fBcondition\fP is \fB1\fP, and generator |
| expressions in \fBtrue_string\fP will not evaluate when condition is \fB0\fP\&. |
| |
| .UNINDENT |
| .sp |
| Typically, the \fBcondition\fP is itself a generator expression. For instance, |
| the following expression expands to \fBDEBUG_MODE\fP when the \fBDebug\fP |
| configuration is used, and the empty string for all other configurations: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<$<CONFIG:Debug>:DEBUG_MODE> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Boolean\-like \fBcondition\fP values other than \fB1\fP or \fB0\fP can be handled |
| by wrapping them with the \fB$<BOOL:...>\fP generator expression: |
| .INDENT 0.0 |
| .TP |
| .B $<BOOL:string> |
| Converts \fBstring\fP to \fB0\fP or \fB1\fP\&. Evaluates to \fB0\fP if any of the |
| following is true: |
| .INDENT 7.0 |
| .IP \(bu 2 |
| \fBstring\fP is empty, |
| .IP \(bu 2 |
| \fBstring\fP is a case\-insensitive equal of |
| \fB0\fP, \fBFALSE\fP, \fBOFF\fP, \fBN\fP, \fBNO\fP, \fBIGNORE\fP, or \fBNOTFOUND\fP, or |
| .IP \(bu 2 |
| \fBstring\fP ends in the suffix \fB\-NOTFOUND\fP (case\-sensitive). |
| .UNINDENT |
| .sp |
| Otherwise evaluates to \fB1\fP\&. |
| .UNINDENT |
| .sp |
| The \fB$<BOOL:...>\fP generator expression is often used when a \fBcondition\fP |
| is provided by a CMake variable: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<$<BOOL:${HAVE_SOME_FEATURE}>:\-DENABLE_SOME_FEATURE> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .SS Logical Operators |
| .sp |
| The common boolean logic operators are supported: |
| .INDENT 0.0 |
| .TP |
| .B $<AND:conditions> |
| where \fBconditions\fP is a comma\-separated list of boolean expressions, |
| all of which must evaluate to either \fB1\fP or \fB0\fP\&. The whole expression |
| evaluates to \fB1\fP if all conditions are \fB1\fP\&. If any condition is \fB0\fP, |
| the whole expression evaluates to \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OR:conditions> |
| where \fBconditions\fP is a comma\-separated list of boolean expressions. |
| all of which must evaluate to either \fB1\fP or \fB0\fP\&. The whole expression |
| evaluates to \fB1\fP if at least one of the \fBconditions\fP is \fB1\fP\&. If all |
| \fBconditions\fP evaluate to \fB0\fP, the whole expression evaluates to \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<NOT:condition> |
| \fBcondition\fP must be \fB0\fP or \fB1\fP\&. The result of the expression is |
| \fB0\fP if \fBcondition\fP is \fB1\fP, else \fB1\fP\&. |
| .UNINDENT |
| .sp |
| Added in version 3.28: Logical operators short\-circuit such that generator expressions in the |
| arguments list will not be evaluated once a return value can be determined. |
| |
| .SS Primary Comparison Expressions |
| .sp |
| CMake supports a variety of generator expressions that compare things. |
| This section covers the primary and most widely used comparison types. |
| Other more specific comparison types are documented in their own separate |
| sections further below. |
| .SS String Comparisons |
| .INDENT 0.0 |
| .TP |
| .B $<STREQUAL:string1,string2> |
| \fB1\fP if \fBstring1\fP and \fBstring2\fP are equal, else \fB0\fP\&. |
| The comparison is case\-sensitive. For a case\-insensitive comparison, |
| combine with a \fI\%string transforming generator expression\fP\&. For example, the following |
| evaluates to \fB1\fP if \fB${foo}\fP is any of \fBBAR\fP, \fBBar\fP, \fBbar\fP, etc. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<STREQUAL:$<UPPER_CASE:${foo}>,BAR> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<EQUAL:value1,value2> |
| \fB1\fP if \fBvalue1\fP and \fBvalue2\fP are numerically equal, else \fB0\fP\&. |
| .UNINDENT |
| .SS Version Comparisons |
| .INDENT 0.0 |
| .TP |
| .B $<VERSION_LESS:v1,v2> |
| \fB1\fP if \fBv1\fP is a version less than \fBv2\fP, else \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<VERSION_GREATER:v1,v2> |
| \fB1\fP if \fBv1\fP is a version greater than \fBv2\fP, else \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<VERSION_EQUAL:v1,v2> |
| \fB1\fP if \fBv1\fP is the same version as \fBv2\fP, else \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<VERSION_LESS_EQUAL:v1,v2> |
| Added in version 3.7. |
| |
| .sp |
| \fB1\fP if \fBv1\fP is a version less than or equal to \fBv2\fP, else \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<VERSION_GREATER_EQUAL:v1,v2> |
| Added in version 3.7. |
| |
| .sp |
| \fB1\fP if \fBv1\fP is a version greater than or equal to \fBv2\fP, else \fB0\fP\&. |
| .UNINDENT |
| .SS String Transformations |
| .INDENT 0.0 |
| .TP |
| .B $<LOWER_CASE:string> |
| Content of \fBstring\fP converted to lower case. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<UPPER_CASE:string> |
| Content of \fBstring\fP converted to upper case. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<MAKE_C_IDENTIFIER:...> |
| Content of \fB\&...\fP converted to a C identifier. The conversion follows the |
| same behavior as \X'tty: link #make-c-identifier'\fI\%string(MAKE_C_IDENTIFIER)\fP\X'tty: link'\&. |
| .UNINDENT |
| .SS List Expressions |
| .sp |
| Most of the expressions in this section are closely associated with the |
| \X'tty: link #command:list'\fI\%list()\fP\X'tty: link' command, providing the same capabilities, but in |
| the form of a generator expression. |
| .sp |
| In each of the following list\-related generator expressions, the \fBlist\fP |
| must not contain any commas if that generator expression expects something to |
| be provided after the \fBlist\fP\&. For example, the expression |
| \fB$<LIST:FIND,list,value>\fP requires a \fBvalue\fP after the \fBlist\fP\&. |
| Since a comma is used to separate the \fBlist\fP and the \fBvalue\fP, the \fBlist\fP |
| cannot itself contain a comma. This restriction does not apply to the |
| \X'tty: link #command:list'\fI\%list()\fP\X'tty: link' command, it is specific to the list\-handling generator |
| expressions only. |
| .SS List Comparisons |
| .INDENT 0.0 |
| .TP |
| .B $<IN_LIST:string,list> |
| Added in version 3.12. |
| |
| .sp |
| \fB1\fP if \fBstring\fP is an item in the semicolon\-separated \fBlist\fP, else \fB0\fP\&. |
| It uses case\-sensitive comparisons. |
| .UNINDENT |
| .SS List Queries |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:LENGTH,list> |
| Added in version 3.27. |
| |
| .sp |
| The number of items in the \fBlist\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:GET,list,index,...> |
| Added in version 3.27. |
| |
| .sp |
| Expands to the list of items specified by indices from the \fBlist\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:SUBLIST,list,begin,length> |
| Added in version 3.27. |
| |
| .sp |
| A sublist of the given \fBlist\fP\&. If \fBlength\fP is 0, an empty list |
| will be returned. If \fBlength\fP is \-1 or the list is smaller than |
| \fBbegin + length\fP, the remaining items of the list starting at |
| \fBbegin\fP will be returned. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:FIND,list,value> |
| Added in version 3.27. |
| |
| .sp |
| The index of the first item in \fBlist\fP with the specified \fBvalue\fP, |
| or \-1 if \fBvalue\fP is not in the \fBlist\fP\&. |
| .UNINDENT |
| .SS List Transformations |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:JOIN,list,glue> |
| Added in version 3.27. |
| |
| .sp |
| Converts \fBlist\fP to a single string with the content of the \fBglue\fP string |
| inserted between each item. This is conceptually the same operation as |
| \fI\%$<JOIN:list,glue>\fP, but the two have different behavior with regard |
| to empty items. \fB$<LIST:JOIN,list,glue>\fP preserves all empty items, |
| whereas \fI\%$<JOIN:list,glue>\fP drops all empty items from the list. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:APPEND,list,item,...> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP with each \fBitem\fP appended. Multiple items should be |
| separated by commas. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:PREPEND,list,item,...> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP with each \fBitem\fP inserted at the beginning. If there are |
| multiple items, they should be separated by commas, and the order of the |
| prepended items will be preserved. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:INSERT,list,index,item,...> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP with the \fBitem\fP (or multiple items) inserted at the specified |
| \fBindex\fP\&. Multiple items should be separated by commas. |
| .sp |
| It is an error to specify an out\-of\-range \fBindex\fP\&. Valid indexes are 0 to N, |
| where N is the length of the list, inclusive. An empty list has length 0. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:POP_BACK,list> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP with the last item removed. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:POP_FRONT,list> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP with the first item removed. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:REMOVE_ITEM,list,value,...> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP with all instances of the given \fBvalue\fP (or values) removed. |
| If multiple values are given, they should be separated by commas. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:REMOVE_AT,list,index,...> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP with the item at each given \fBindex\fP removed. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:REMOVE_DUPLICATES,list> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP with all duplicated items removed. The relative order of |
| items is preserved, but if duplicates are encountered, only the first |
| instance is preserved. The result is the same as |
| \fI\%$<REMOVE_DUPLICATES:list>\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:FILTER,list,INCLUDE|EXCLUDE,regex> |
| Added in version 3.27. |
| |
| .sp |
| A list of items from the \fBlist\fP which match (\fBINCLUDE\fP) or do not match |
| (\fBEXCLUDE\fP) the regular expression \fBregex\fP\&. The result is the same as |
| \fI\%$<FILTER:list,INCLUDE|EXCLUDE,regex>\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:TRANSFORM,list,ACTION[,SELECTOR]> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP transformed by applying an \fBACTION\fP to all or, by |
| specifying a \fBSELECTOR\fP, to the selected list items. |
| .sp |
| \fBNOTE:\fP |
| .INDENT 7.0 |
| .INDENT 3.5 |
| The \fBTRANSFORM\fP sub\-command does not change the number of items in the |
| list. If a \fBSELECTOR\fP is specified, only some items will be changed, |
| the other ones will remain the same as before the transformation. |
| .UNINDENT |
| .UNINDENT |
| .sp |
| \fBACTION\fP specifies the action to apply to the items of the list. |
| The actions have exactly the same semantics as for the |
| \X'tty: link #transform'\fI\%list(TRANSFORM)\fP\X'tty: link' command. \fBACTION\fP must be one of the following: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .INDENT 0.0 |
| .TP |
| .B \X'tty: link #transform-append'\fI\%APPEND\fP\X'tty: link', \X'tty: link #transform-append'\fI\%PREPEND\fP\X'tty: link' |
| Append, prepend specified value to each item of the list. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<LIST:TRANSFORM,list,(APPEND|PREPEND),value[,SELECTOR]> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .TP |
| .B \X'tty: link #transform-tolower'\fI\%TOLOWER\fP\X'tty: link', \X'tty: link #transform-tolower'\fI\%TOUPPER\fP\X'tty: link' |
| Convert each item of the list to lower, upper characters. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<LIST:TRANSFORM,list,(TOLOWER|TOUPPER)[,SELECTOR]> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .TP |
| .B \X'tty: link #transform-strip'\fI\%STRIP\fP\X'tty: link' |
| Remove leading and trailing spaces from each item of the list. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<LIST:TRANSFORM,list,STRIP[,SELECTOR]> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .TP |
| .B \X'tty: link #transform-replace'\fI\%REPLACE\fP\X'tty: link': |
| Match the regular expression as many times as possible and substitute |
| the replacement expression for the match for each item of the list. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<LIST:TRANSFORM,list,REPLACE,regular_expression,replace_expression[,SELECTOR]> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .sp |
| \fBSELECTOR\fP determines which items of the list will be transformed. |
| Only one type of selector can be specified at a time. When given, |
| \fBSELECTOR\fP must be one of the following: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .INDENT 0.0 |
| .TP |
| .B \fBAT\fP |
| Specify a list of indexes. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<LIST:TRANSFORM,list,ACTION,AT,index[,index...]> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .TP |
| .B \fBFOR\fP |
| Specify a range with, optionally, an increment used to iterate over the |
| range. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<LIST:TRANSFORM,list,ACTION,FOR,start,stop[,step]> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .TP |
| .B \fBREGEX\fP |
| Specify a regular expression. |
| Only items matching the regular expression will be transformed. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<LIST:TRANSFORM,list,ACTION,REGEX,regular_expression> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<JOIN:list,glue> |
| Joins the \fBlist\fP with the content of the \fBglue\fP string inserted between |
| each item. This is conceptually the same operation as |
| \fI\%$<LIST:JOIN,list,glue>\fP, but the two have |
| different behavior with regard to empty items. |
| \fI\%$<LIST:JOIN,list,glue>\fP preserves all empty items, |
| whereas \fB$<JOIN,list,glue>\fP drops all empty items from the list. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<REMOVE_DUPLICATES:list> |
| Added in version 3.15. |
| |
| .sp |
| Removes duplicated items in the given \fBlist\fP\&. The relative order of items |
| is preserved, and if duplicates are encountered, only the first instance is |
| retained. The result is the same as |
| \fI\%$<LIST:REMOVE_DUPLICATES,list>\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<FILTER:list,INCLUDE|EXCLUDE,regex> |
| Added in version 3.15. |
| |
| .sp |
| Includes or removes items from \fBlist\fP that match the regular expression |
| \fBregex\fP\&. The result is the same as |
| \fI\%$<LIST:FILTER,list,INCLUDE|EXCLUDE,regex>\fP\&. |
| .UNINDENT |
| .SS List Ordering |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:REVERSE,list> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP with the items in reverse order. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LIST:SORT,list[,(COMPARE:option|CASE:option|ORDER:option)]...> |
| Added in version 3.27. |
| |
| .sp |
| The \fBlist\fP sorted according to the specified options. |
| .sp |
| Use one of the \fBCOMPARE\fP options to select the comparison method |
| for sorting: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .INDENT 0.0 |
| .TP |
| .B \fBSTRING\fP |
| Sorts a list of strings alphabetically. |
| This is the default behavior if the \fBCOMPARE\fP option is not given. |
| .TP |
| .B \fBFILE_BASENAME\fP |
| Sorts a list of file paths by their basenames. |
| .TP |
| .B \fBNATURAL\fP |
| Sorts a list of strings using natural order (see the man page for |
| \fBstrverscmp(3)\fP), such that contiguous digits are compared as whole |
| numbers. For example, the following list \fB10.0 1.1 2.1 8.0 2.0 3.1\fP |
| will be sorted as \fB1.1 2.0 2.1 3.1 8.0 10.0\fP if the \fBNATURAL\fP |
| comparison is selected, whereas it will be sorted as |
| \fB1.1 10.0 2.0 2.1 3.1 8.0\fP with the \fBSTRING\fP comparison. |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Use one of the \fBCASE\fP options to select a case\-sensitive or |
| case\-insensitive sort mode: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .INDENT 0.0 |
| .TP |
| .B \fBSENSITIVE\fP |
| List items are sorted in a case\-sensitive manner. |
| This is the default behavior if the \fBCASE\fP option is not given. |
| .TP |
| .B \fBINSENSITIVE\fP |
| List items are sorted in a case\-insensitive manner. The order of |
| items which differ only by upper/lowercase is not specified. |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .sp |
| To control the sort order, one of the \fBORDER\fP options can be given: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .INDENT 0.0 |
| .TP |
| .B \fBASCENDING\fP |
| Sorts the list in ascending order. |
| This is the default behavior when the \fBORDER\fP option is not given. |
| .TP |
| .B \fBDESCENDING\fP |
| Sorts the list in descending order. |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Options can be specified in any order, but it is an error to specify the |
| same option multiple times. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<LIST:SORT,list,CASE:SENSITIVE,COMPARE:STRING,ORDER:DESCENDING> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .SS Path Expressions |
| .sp |
| Most of the expressions in this section are closely associated with the |
| \X'tty: link #command:cmake_path'\fI\%cmake_path()\fP\X'tty: link' command, providing the same capabilities, but in |
| the form of a generator expression. |
| .sp |
| For all generator expressions in this section, paths are expected to be in |
| cmake\-style format. The \fI\%$<PATH:CMAKE_PATH>\fP |
| generator expression can be used to convert a native path to a cmake\-style |
| one. |
| .SS Path Comparisons |
| .INDENT 0.0 |
| .TP |
| .B $<PATH_EQUAL:path1,path2> |
| Added in version 3.24. |
| |
| .sp |
| Compares the lexical representations of two paths. No normalization is |
| performed on either path. Returns \fB1\fP if the paths are equal, \fB0\fP |
| otherwise. |
| .sp |
| See \X'tty: link #path-compare'\fI\%cmake_path(COMPARE)\fP\X'tty: link' for more details. |
| .UNINDENT |
| .SS Path Queries |
| .sp |
| These expressions provide the generation\-time capabilities equivalent to the |
| \X'tty: link #path-query'\fI\%Query\fP\X'tty: link' options of the \X'tty: link #command:cmake_path'\fI\%cmake_path()\fP\X'tty: link' command. |
| All paths are expected to be in cmake\-style format. |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:HAS_*,path> |
| Added in version 3.24. |
| |
| .sp |
| The following operations return \fB1\fP if the particular path component is |
| present, \fB0\fP otherwise. See \X'tty: link #path-structure-and-terminology'\fI\%Path Structure And Terminology\fP\X'tty: link' for the |
| meaning of each path component. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<PATH:HAS_ROOT_NAME,path> |
| $<PATH:HAS_ROOT_DIRECTORY,path> |
| $<PATH:HAS_ROOT_PATH,path> |
| $<PATH:HAS_FILENAME,path> |
| $<PATH:HAS_EXTENSION,path> |
| $<PATH:HAS_STEM,path> |
| $<PATH:HAS_RELATIVE_PART,path> |
| $<PATH:HAS_PARENT_PATH,path> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Note the following special cases: |
| .INDENT 7.0 |
| .IP \(bu 2 |
| For \fBHAS_ROOT_PATH\fP, a true result will only be returned if at least one |
| of \fBroot\-name\fP or \fBroot\-directory\fP is non\-empty. |
| .IP \(bu 2 |
| For \fBHAS_PARENT_PATH\fP, the root directory is also considered to have a |
| parent, which will be itself. The result is true except if the path |
| consists of just a \X'tty: link #filename-def'\fI\%filename\fP\X'tty: link'\&. |
| .UNINDENT |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:IS_ABSOLUTE,path> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fB1\fP if the path is \X'tty: link #is-absolute'\fI\%absolute\fP\X'tty: link', \fB0\fP otherwise. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:IS_RELATIVE,path> |
| Added in version 3.24. |
| |
| .sp |
| This will return the opposite of \fBIS_ABSOLUTE\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:IS_PREFIX[,NORMALIZE],path,input> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fB1\fP if \fBpath\fP is the prefix of \fBinput\fP, \fB0\fP otherwise. |
| .sp |
| When the \fBNORMALIZE\fP option is specified, \fBpath\fP and \fBinput\fP are |
| \X'tty: link #normalization'\fI\%normalized\fP\X'tty: link' before the check. |
| .UNINDENT |
| .SS Path Decomposition |
| .sp |
| These expressions provide the generation\-time capabilities equivalent to the |
| \X'tty: link #path-decomposition'\fI\%Decomposition\fP\X'tty: link' options of the \X'tty: link #command:cmake_path'\fI\%cmake_path()\fP\X'tty: link' |
| command. All paths are expected to be in cmake\-style format. |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:GET_*,...> |
| Added in version 3.24. |
| |
| .sp |
| The following operations retrieve a different component or group of |
| components from a path. See \X'tty: link #path-structure-and-terminology'\fI\%Path Structure And Terminology\fP\X'tty: link' for the |
| meaning of each path component. |
| .sp |
| Changed in version 3.27: All operations now accept a list of paths as argument. When a list of paths |
| is specified, the operation will be applied to each path. |
| |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| $<PATH:GET_ROOT_NAME,path...> |
| $<PATH:GET_ROOT_DIRECTORY,path...> |
| $<PATH:GET_ROOT_PATH,path...> |
| $<PATH:GET_FILENAME,path...> |
| $<PATH:GET_EXTENSION[,LAST_ONLY],path...> |
| $<PATH:GET_STEM[,LAST_ONLY],path...> |
| $<PATH:GET_RELATIVE_PART,path...> |
| $<PATH:GET_PARENT_PATH,path...> |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| If a requested component is not present in the path, an empty string is |
| returned. |
| .UNINDENT |
| .SS Path Transformations |
| .sp |
| These expressions provide the generation\-time capabilities equivalent to the |
| \X'tty: link #path-modification'\fI\%Modification\fP\X'tty: link' and \X'tty: link #path-generation'\fI\%Generation\fP\X'tty: link' |
| options of the \X'tty: link #command:cmake_path'\fI\%cmake_path()\fP\X'tty: link' command. All paths are expected to be |
| in cmake\-style format. |
| .sp |
| Changed in version 3.27: All operations now accept a list of paths as argument. When a list of paths |
| is specified, the operation will be applied to each path. |
| |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:CMAKE_PATH[,NORMALIZE],path...> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fBpath\fP\&. If \fBpath\fP is a native path, it is converted into a |
| cmake\-style path with forward\-slashes (\fB/\fP). On Windows, the long filename |
| marker is taken into account. |
| .sp |
| When the \fBNORMALIZE\fP option is specified, the path is \X'tty: link #normalization'\fI\%normalized\fP\X'tty: link' after the conversion. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:APPEND,path...,input,...> |
| Added in version 3.24. |
| |
| .sp |
| Returns all the \fBinput\fP arguments appended to \fBpath\fP using \fB/\fP as the |
| \fBdirectory\-separator\fP\&. Depending on the \fBinput\fP, the value of \fBpath\fP |
| may be discarded. |
| .sp |
| See \X'tty: link #append'\fI\%cmake_path(APPEND)\fP\X'tty: link' for more details. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:REMOVE_FILENAME,path...> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fBpath\fP with filename component (as returned by |
| \fB$<PATH:GET_FILENAME>\fP) removed. After removal, any trailing |
| \fBdirectory\-separator\fP is left alone, if present. |
| .sp |
| See \X'tty: link #remove-filename'\fI\%cmake_path(REMOVE_FILENAME)\fP\X'tty: link' for more details. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:REPLACE_FILENAME,path...,input> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fBpath\fP with the filename component replaced by \fBinput\fP\&. If |
| \fBpath\fP has no filename component (i.e. \fB$<PATH:HAS_FILENAME>\fP returns |
| \fB0\fP), \fBpath\fP is unchanged. |
| .sp |
| See \X'tty: link #replace-filename'\fI\%cmake_path(REPLACE_FILENAME)\fP\X'tty: link' for more details. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:REMOVE_EXTENSION[,LAST_ONLY],path...> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fBpath\fP with the \X'tty: link #extension-def'\fI\%extension\fP\X'tty: link' removed, if any. |
| .sp |
| See \X'tty: link #remove-extension'\fI\%cmake_path(REMOVE_EXTENSION)\fP\X'tty: link' for more details. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:REPLACE_EXTENSION[,LAST_ONLY],path...,input> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fBpath\fP with the \X'tty: link #extension-def'\fI\%extension\fP\X'tty: link' replaced by |
| \fBinput\fP, if any. |
| .sp |
| See \X'tty: link #replace-extension'\fI\%cmake_path(REPLACE_EXTENSION)\fP\X'tty: link' for more details. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:NORMAL_PATH,path...> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fBpath\fP normalized according to the steps described in |
| \X'tty: link #normalization'\fI\%Normalization\fP\X'tty: link'\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:RELATIVE_PATH,path...,base_directory> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fBpath\fP, modified to make it relative to the \fBbase_directory\fP |
| argument. |
| .sp |
| See \X'tty: link #cmake-path-relative-path'\fI\%cmake_path(RELATIVE_PATH)\fP\X'tty: link' for more |
| details. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PATH:ABSOLUTE_PATH[,NORMALIZE],path...,base_directory> |
| Added in version 3.24. |
| |
| .sp |
| Returns \fBpath\fP as absolute. If \fBpath\fP is a relative path |
| (\fB$<PATH:IS_RELATIVE>\fP returns \fB1\fP), it is evaluated relative to the |
| given base directory specified by \fBbase_directory\fP argument. |
| .sp |
| When the \fBNORMALIZE\fP option is specified, the path is |
| \X'tty: link #normalization'\fI\%normalized\fP\X'tty: link' after the path computation. |
| .sp |
| See \X'tty: link #absolute-path'\fI\%cmake_path(ABSOLUTE_PATH)\fP\X'tty: link' for more details. |
| .UNINDENT |
| .SS Shell Paths |
| .INDENT 0.0 |
| .TP |
| .B $<SHELL_PATH:...> |
| Added in version 3.4. |
| |
| .sp |
| Content of \fB\&...\fP 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 \fB\&...\fP must be an absolute path. |
| .sp |
| Added in version 3.14: The \fB\&...\fP may be a \X'tty: link #cmake-language-lists'\fI\%semicolon\-separated list\fP\X'tty: link' |
| of paths, in which case each path is converted individually and a result |
| list is generated using the shell path separator (\fB:\fP on POSIX and |
| \fB;\fP on Windows). Be sure to enclose the argument containing this genex |
| in double quotes in CMake source code so that \fB;\fP does not split arguments. |
| |
| .UNINDENT |
| .SS Configuration Expressions |
| .INDENT 0.0 |
| .TP |
| .B $<CONFIG> |
| Configuration name. Use this instead of the deprecated \fI\%CONFIGURATION\fP |
| generator expression. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CONFIG:cfgs> |
| \fB1\fP if config is any one of the entries in comma\-separated list |
| \fBcfgs\fP, else \fB0\fP\&. This is a case\-insensitive comparison. The mapping in |
| \X'tty: link #prop_tgt:MAP_IMPORTED_CONFIG_<CONFIG>'\fI\%MAP_IMPORTED_CONFIG_<CONFIG>\fP\X'tty: link' is also considered by this |
| expression when it is evaluated on a property of an \X'tty: link #prop_tgt:IMPORTED'\fI\%IMPORTED\fP\X'tty: link' |
| target. |
| .sp |
| Changed in version 3.19: Multiple configurations can be specified for \fBcfgs\fP\&. |
| CMake 3.18 and earlier only accepted a single configuration. |
| |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OUTPUT_CONFIG:...> |
| Added in version 3.20. |
| |
| .sp |
| Only valid in \X'tty: link #command:add_custom_command'\fI\%add_custom_command()\fP\X'tty: link' and \X'tty: link #command:add_custom_target'\fI\%add_custom_target()\fP\X'tty: link' |
| as the outer\-most generator expression in an argument. |
| With the \X'tty: link #generator:Ninja Multi-Config'\fI\%Ninja Multi\-Config\fP\X'tty: link' generator, generator expressions |
| in \fB\&...\fP are evaluated using the custom command\(aqs \(dqoutput config\(dq. |
| With other generators, the content of \fB\&...\fP is evaluated normally. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<COMMAND_CONFIG:...> |
| Added in version 3.20. |
| |
| .sp |
| Only valid in \X'tty: link #command:add_custom_command'\fI\%add_custom_command()\fP\X'tty: link' and \X'tty: link #command:add_custom_target'\fI\%add_custom_target()\fP\X'tty: link' |
| as the outer\-most generator expression in an argument. |
| With the \X'tty: link #generator:Ninja Multi-Config'\fI\%Ninja Multi\-Config\fP\X'tty: link' generator, generator expressions |
| in \fB\&...\fP are evaluated using the custom command\(aqs \(dqcommand config\(dq. |
| With other generators, the content of \fB\&...\fP is evaluated normally. |
| .UNINDENT |
| .SS Toolchain And Language Expressions |
| .SS Platform |
| .INDENT 0.0 |
| .TP |
| .B $<PLATFORM_ID> |
| The current system\(aqs CMake platform id. |
| See also the \X'tty: link #variable:CMAKE_SYSTEM_NAME'\fI\%CMAKE_SYSTEM_NAME\fP\X'tty: link' variable. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<PLATFORM_ID:platform_ids> |
| \fB1\fP if CMake\(aqs platform id matches any one of the entries in |
| comma\-separated list \fBplatform_ids\fP, otherwise \fB0\fP\&. |
| See also the \X'tty: link #variable:CMAKE_SYSTEM_NAME'\fI\%CMAKE_SYSTEM_NAME\fP\X'tty: link' variable. |
| .UNINDENT |
| .SS Compiler Version |
| .sp |
| See also the \X'tty: link #variable:CMAKE_<LANG>_COMPILER_VERSION'\fI\%CMAKE_<LANG>_COMPILER_VERSION\fP\X'tty: link' variable, which is |
| closely related to the expressions in this sub\-section. |
| .INDENT 0.0 |
| .TP |
| .B $<C_COMPILER_VERSION> |
| The version of the C compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<C_COMPILER_VERSION:version> |
| \fB1\fP if the version of the C compiler matches \fBversion\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CXX_COMPILER_VERSION> |
| The version of the CXX compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CXX_COMPILER_VERSION:version> |
| \fB1\fP if the version of the C++ compiler matches \fBversion\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CUDA_COMPILER_VERSION> |
| Added in version 3.15. |
| |
| .sp |
| The version of the CUDA compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CUDA_COMPILER_VERSION:version> |
| Added in version 3.15. |
| |
| .sp |
| \fB1\fP if the version of the C++ compiler matches \fBversion\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJC_COMPILER_VERSION> |
| Added in version 3.16. |
| |
| .sp |
| The version of the Objective\-C compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJC_COMPILER_VERSION:version> |
| Added in version 3.16. |
| |
| .sp |
| \fB1\fP if the version of the Objective\-C compiler matches \fBversion\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJCXX_COMPILER_VERSION> |
| Added in version 3.16. |
| |
| .sp |
| The version of the Objective\-C++ compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJCXX_COMPILER_VERSION:version> |
| Added in version 3.16. |
| |
| .sp |
| \fB1\fP if the version of the Objective\-C++ compiler matches \fBversion\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<Fortran_COMPILER_VERSION> |
| The version of the Fortran compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<Fortran_COMPILER_VERSION:version> |
| \fB1\fP if the version of the Fortran compiler matches \fBversion\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<HIP_COMPILER_VERSION> |
| Added in version 3.21. |
| |
| .sp |
| The version of the HIP compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<HIP_COMPILER_VERSION:version> |
| Added in version 3.21. |
| |
| .sp |
| \fB1\fP if the version of the HIP compiler matches \fBversion\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<ISPC_COMPILER_VERSION> |
| Added in version 3.19. |
| |
| .sp |
| The version of the ISPC compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<ISPC_COMPILER_VERSION:version> |
| Added in version 3.19. |
| |
| .sp |
| \fB1\fP if the version of the ISPC compiler matches \fBversion\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .SS Compiler Language, ID, and Frontend\-Variant |
| .sp |
| See also the \X'tty: link #variable:CMAKE_<LANG>_COMPILER_ID'\fI\%CMAKE_<LANG>_COMPILER_ID\fP\X'tty: link' and |
| \X'tty: link #variable:CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT'\fI\%CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT\fP\X'tty: link' variables, which are closely |
| related to most of the expressions in this sub\-section. |
| .INDENT 0.0 |
| .TP |
| .B $<C_COMPILER_ID> |
| CMake\(aqs compiler id of the C compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<C_COMPILER_ID:compiler_ids> |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler id of the C compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .sp |
| Changed in version 3.15: Multiple \fBcompiler_ids\fP can be specified. |
| CMake 3.14 and earlier only accepted a single compiler ID. |
| |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CXX_COMPILER_ID> |
| CMake\(aqs compiler id of the C++ compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CXX_COMPILER_ID:compiler_ids> |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler id of the C++ compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .sp |
| Changed in version 3.15: Multiple \fBcompiler_ids\fP can be specified. |
| CMake 3.14 and earlier only accepted a single compiler ID. |
| |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CUDA_COMPILER_ID> |
| Added in version 3.15. |
| |
| .sp |
| CMake\(aqs compiler id of the CUDA compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CUDA_COMPILER_ID:compiler_ids> |
| Added in version 3.15. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler id of the CUDA compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJC_COMPILER_ID> |
| Added in version 3.16. |
| |
| .sp |
| CMake\(aqs compiler id of the Objective\-C compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJC_COMPILER_ID:compiler_ids> |
| Added in version 3.16. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler id of the Objective\-C compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJCXX_COMPILER_ID> |
| Added in version 3.16. |
| |
| .sp |
| CMake\(aqs compiler id of the Objective\-C++ compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJCXX_COMPILER_ID:compiler_ids> |
| Added in version 3.16. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler id of the Objective\-C++ compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<Fortran_COMPILER_ID> |
| CMake\(aqs compiler id of the Fortran compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<Fortran_COMPILER_ID:compiler_ids> |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler id of the Fortran compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .sp |
| Changed in version 3.15: Multiple \fBcompiler_ids\fP can be specified. |
| CMake 3.14 and earlier only accepted a single compiler ID. |
| |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<HIP_COMPILER_ID> |
| Added in version 3.21. |
| |
| .sp |
| CMake\(aqs compiler id of the HIP compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<HIP_COMPILER_ID:compiler_ids> |
| Added in version 3.21. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler id of the HIP compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<ISPC_COMPILER_ID> |
| Added in version 3.19. |
| |
| .sp |
| CMake\(aqs compiler id of the ISPC compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<ISPC_COMPILER_ID:compiler_ids> |
| Added in version 3.19. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler id of the ISPC compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<C_COMPILER_FRONTEND_VARIANT> |
| Added in version 3.30. |
| |
| .sp |
| CMake\(aqs compiler frontend variant of the C compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<C_COMPILER_FRONTEND_VARIANT:compiler_ids> |
| Added in version 3.30. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler frontend variant of the C compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CXX_COMPILER_FRONTEND_VARIANT> |
| Added in version 3.30. |
| |
| .sp |
| CMake\(aqs compiler frontend variant of the C++ compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CXX_COMPILER_FRONTEND_VARIANT:compiler_ids> |
| Added in version 3.30. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler frontend variant of the C++ compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CUDA_COMPILER_FRONTEND_VARIANT> |
| Added in version 3.30. |
| |
| .sp |
| CMake\(aqs compiler id of the CUDA compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<CUDA_COMPILER_FRONTEND_VARIANT:compiler_ids> |
| Added in version 3.30. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler frontend variant of the CUDA compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJC_COMPILER_FRONTEND_VARIANT> |
| Added in version 3.30. |
| |
| .sp |
| CMake\(aqs compiler frontend variant of the Objective\-C compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJC_COMPILER_FRONTEND_VARIANT:compiler_ids> |
| Added in version 3.30. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler frontend variant of the Objective\-C compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJCXX_COMPILER_FRONTEND_VARIANT> |
| Added in version 3.30. |
| |
| .sp |
| CMake\(aqs compiler frontend variant of the Objective\-C++ compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<OBJCXX_COMPILER_FRONTEND_VARIANT:compiler_ids> |
| Added in version 3.30. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler frontend variant of the Objective\-C++ compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<Fortran_COMPILER_FRONTEND_VARIANT> |
| Added in version 3.30. |
| |
| .sp |
| CMake\(aqs compiler id of the Fortran compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<Fortran_COMPILER_FRONTEND_VARIANT:compiler_ids> |
| Added in version 3.30. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler frontend variant of the Fortran compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<HIP_COMPILER_FRONTEND_VARIANT> |
| Added in version 3.30. |
| |
| .sp |
| CMake\(aqs compiler id of the HIP compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<HIP_COMPILER_FRONTEND_VARIANT:compiler_ids> |
| Added in version 3.30. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler frontend variant of the HIP compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<ISPC_COMPILER_FRONTEND_VARIANT> |
| Added in version 3.30. |
| |
| .sp |
| CMake\(aqs compiler id of the ISPC compiler used. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<ISPC_COMPILER_FRONTEND_VARIANT:compiler_ids> |
| Added in version 3.30. |
| |
| .sp |
| where \fBcompiler_ids\fP is a comma\-separated list. |
| \fB1\fP if CMake\(aqs compiler frontend variant of the ISPC compiler matches any one |
| of the entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<COMPILE_LANGUAGE> |
| Added in version 3.3. |
| |
| .sp |
| The compile language of source files when evaluating compile options. |
| See \fI\%the related boolean expression\fP |
| \fB$<COMPILE_LANGUAGE:language>\fP |
| for notes about the portability of this generator expression. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<COMPILE_LANGUAGE:languages> |
| Added in version 3.3. |
| |
| .sp |
| Changed in version 3.15: Multiple languages can be specified for \fBlanguages\fP\&. |
| CMake 3.14 and earlier only accepted a single language. |
| |
| .sp |
| \fB1\fP when the language used for compilation unit matches any of the |
| comma\-separated entries in \fBlanguages\fP, otherwise \fB0\fP\&. This expression |
| may be used to specify compile options, compile definitions, and include |
| directories for source files of a particular language in a target. For |
| example: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_executable(myapp main.cpp foo.c bar.cpp zot.cu) |
| target_compile_options(myapp |
| PRIVATE $<$<COMPILE_LANGUAGE:CXX>:\-fno\-exceptions> |
| ) |
| target_compile_definitions(myapp |
| PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX> |
| $<$<COMPILE_LANGUAGE:CUDA>:COMPILING_CUDA> |
| ) |
| target_include_directories(myapp |
| PRIVATE $<$<COMPILE_LANGUAGE:CXX,CUDA>:/opt/foo/headers> |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| This specifies the use of the \fB\-fno\-exceptions\fP compile option, |
| \fBCOMPILING_CXX\fP compile definition, and \fBcxx_headers\fP include |
| directory for C++ only (compiler id checks elided). It also specifies |
| a \fBCOMPILING_CUDA\fP compile definition for CUDA. |
| .sp |
| Note that with \X'tty: link #visual-studio-generators'\fI\%Visual Studio Generators\fP\X'tty: link' and \X'tty: link #generator:Xcode'\fI\%Xcode\fP\X'tty: link' there |
| is no way to represent target\-wide compile definitions or include directories |
| separately for \fBC\fP and \fBCXX\fP languages. |
| Also, with \X'tty: link #visual-studio-generators'\fI\%Visual Studio Generators\fP\X'tty: link' there is no way to represent |
| target\-wide flags separately for \fBC\fP and \fBCXX\fP languages. Under these |
| generators, expressions for both C and C++ sources will be evaluated |
| using \fBCXX\fP if there are any C++ sources and otherwise using \fBC\fP\&. |
| A workaround is to create separate libraries for each source file language |
| instead: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(myapp_c foo.c) |
| add_library(myapp_cxx bar.cpp) |
| target_compile_options(myapp_cxx PUBLIC \-fno\-exceptions) |
| add_executable(myapp main.cpp) |
| target_link_libraries(myapp myapp_c myapp_cxx) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<COMPILE_LANG_AND_ID:language,compiler_ids> |
| Added in version 3.15. |
| |
| .sp |
| \fB1\fP when the language used for compilation unit matches \fBlanguage\fP and |
| CMake\(aqs compiler id of the \fBlanguage\fP compiler matches any one of the |
| comma\-separated entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. This expression |
| is a short form for the combination of \fB$<COMPILE_LANGUAGE:language>\fP and |
| \fB$<LANG_COMPILER_ID:compiler_ids>\fP\&. This expression may be used to specify |
| compile options, compile definitions, and include directories for source |
| files of a particular language and compiler combination in a target. |
| For example: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_executable(myapp main.cpp foo.c bar.cpp zot.cu) |
| target_compile_definitions(myapp |
| PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang>:COMPILING_CXX_WITH_CLANG> |
| $<$<COMPILE_LANG_AND_ID:CXX,Intel>:COMPILING_CXX_WITH_INTEL> |
| $<$<COMPILE_LANG_AND_ID:C,Clang>:COMPILING_C_WITH_CLANG> |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| This specifies the use of different compile definitions based on both |
| the compiler id and compilation language. This example will have a |
| \fBCOMPILING_CXX_WITH_CLANG\fP compile definition when Clang is the CXX |
| compiler, and \fBCOMPILING_CXX_WITH_INTEL\fP when Intel is the CXX compiler. |
| Likewise, when the C compiler is Clang, it will only see the |
| \fBCOMPILING_C_WITH_CLANG\fP definition. |
| .sp |
| Without the \fBCOMPILE_LANG_AND_ID\fP generator expression, the same logic |
| would be expressed as: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| target_compile_definitions(myapp |
| PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:AppleClang,Clang>>:COMPILING_CXX_WITH_CLANG> |
| $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Intel>>:COMPILING_CXX_WITH_INTEL> |
| $<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:Clang>>:COMPILING_C_WITH_CLANG> |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .SS Compile Features |
| .INDENT 0.0 |
| .TP |
| .B $<COMPILE_FEATURES:features> |
| Added in version 3.1. |
| |
| .sp |
| where \fBfeatures\fP is a comma\-separated list. |
| Evaluates to \fB1\fP if all of the \fBfeatures\fP are available for the \(aqhead\(aq |
| target, and \fB0\fP otherwise. If this expression is used while evaluating |
| the link implementation of a target and if any dependency transitively |
| increases the required \X'tty: link #prop_tgt:C_STANDARD'\fI\%C_STANDARD\fP\X'tty: link' or \X'tty: link #prop_tgt:CXX_STANDARD'\fI\%CXX_STANDARD\fP\X'tty: link' |
| for the \(aqhead\(aq target, an error is reported. See the |
| \X'tty: link #manual:cmake-compile-features(7)'\fI\%cmake\-compile\-features(7)\fP\X'tty: link' manual for information on |
| compile features and a list of supported compilers. |
| .UNINDENT |
| .SS Compile Context |
| .INDENT 0.0 |
| .TP |
| .B $<COMPILE_ONLY:...> |
| Added in version 3.27. |
| |
| .sp |
| Content of \fB\&...\fP, when collecting |
| \X'tty: link #transitive-compile-properties'\fI\%transitive compile properties\fP\X'tty: link', |
| otherwise it is the empty string. This is intended for use in an |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link' and \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link' target |
| properties, typically populated via the \X'tty: link #command:target_link_libraries'\fI\%target_link_libraries()\fP\X'tty: link' command. |
| Provides compilation usage requirements without any linking requirements. |
| .sp |
| Use cases include header\-only usage where all usages are known to not have |
| linking requirements (e.g., all\-\fBinline\fP or C++ template libraries). |
| .sp |
| Note that for proper evaluation of this expression requires policy \X'tty: link #policy:CMP0099'\fI\%CMP0099\fP\X'tty: link' |
| to be set to \fINEW\fP\&. |
| .UNINDENT |
| .SS Linker Language And ID |
| .INDENT 0.0 |
| .TP |
| .B $<LINK_LANGUAGE> |
| Added in version 3.18. |
| |
| .sp |
| The link language of the target when evaluating link options. |
| See \fI\%the related boolean expression\fP \fB$<LINK_LANGUAGE:languages>\fP |
| for notes about the portability of this generator expression. |
| .sp |
| \fBNOTE:\fP |
| .INDENT 7.0 |
| .INDENT 3.5 |
| This generator expression is not supported by the link libraries |
| properties to avoid side\-effects due to the double evaluation of |
| these properties. |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LINK_LANGUAGE:languages> |
| Added in version 3.18. |
| |
| .sp |
| \fB1\fP when the language used for link step matches any of the comma\-separated |
| entries in \fBlanguages\fP, otherwise \fB0\fP\&. This expression may be used to |
| specify link libraries, link options, link directories and link dependencies |
| of a particular language in a target. For example: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(api_C ...) |
| add_library(api_CXX ...) |
| add_library(api INTERFACE) |
| target_link_options(api INTERFACE $<$<LINK_LANGUAGE:C>:\-opt_c> |
| $<$<LINK_LANGUAGE:CXX>:\-opt_cxx>) |
| target_link_libraries(api INTERFACE $<$<LINK_LANGUAGE:C>:api_C> |
| $<$<LINK_LANGUAGE:CXX>:api_CXX>) |
| |
| add_executable(myapp1 main.c) |
| target_link_options(myapp1 PRIVATE api) |
| |
| add_executable(myapp2 main.cpp) |
| target_link_options(myapp2 PRIVATE api) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| This specifies to use the \fBapi\fP target for linking targets \fBmyapp1\fP and |
| \fBmyapp2\fP\&. In practice, \fBmyapp1\fP will link with target \fBapi_C\fP and |
| option \fB\-opt_c\fP because it will use \fBC\fP as link language. And \fBmyapp2\fP |
| will link with \fBapi_CXX\fP and option \fB\-opt_cxx\fP because \fBCXX\fP will be |
| the link language. |
| .sp |
| \fBNOTE:\fP |
| .INDENT 7.0 |
| .INDENT 3.5 |
| To determine the link language of a target, it is required to collect, |
| transitively, all the targets which will be linked to it. So, for link |
| libraries properties, a double evaluation will be done. During the first |
| evaluation, \fB$<LINK_LANGUAGE:..>\fP expressions will always return \fB0\fP\&. |
| The link language computed after this first pass will be used to do the |
| second pass. To avoid inconsistency, it is required that the second pass |
| do not change the link language. Moreover, to avoid unexpected |
| side\-effects, it is required to specify complete entities as part of the |
| \fB$<LINK_LANGUAGE:..>\fP expression. For example: |
| .INDENT 0.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(lib STATIC file.cxx) |
| add_library(libother STATIC file.c) |
| |
| # bad usage |
| add_executable(myapp1 main.c) |
| target_link_libraries(myapp1 PRIVATE lib$<$<LINK_LANGUAGE:C>:other>) |
| |
| # correct usage |
| add_executable(myapp2 main.c) |
| target_link_libraries(myapp2 PRIVATE $<$<LINK_LANGUAGE:C>:libother>) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| In this example, for \fBmyapp1\fP, the first pass will, unexpectedly, |
| determine that the link language is \fBCXX\fP because the evaluation of the |
| generator expression will be an empty string so \fBmyapp1\fP will depends on |
| target \fBlib\fP which is \fBC++\fP\&. On the contrary, for \fBmyapp2\fP, the first |
| evaluation will give \fBC\fP as link language, so the second pass will |
| correctly add target \fBlibother\fP as link dependency. |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LINK_LANG_AND_ID:language,compiler_ids> |
| Added in version 3.18. |
| |
| .sp |
| \fB1\fP when the language used for link step matches \fBlanguage\fP and the |
| CMake\(aqs compiler id of the language linker matches any one of the comma\-separated |
| entries in \fBcompiler_ids\fP, otherwise \fB0\fP\&. This expression is a short form |
| for the combination of \fB$<LINK_LANGUAGE:language>\fP and |
| \fB$<LANG_COMPILER_ID:compiler_ids>\fP\&. This expression may be used to specify |
| link libraries, link options, link directories and link dependencies of a |
| particular language and linker combination in a target. For example: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(libC_Clang ...) |
| add_library(libCXX_Clang ...) |
| add_library(libC_Intel ...) |
| add_library(libCXX_Intel ...) |
| |
| add_executable(myapp main.c) |
| if (CXX_CONFIG) |
| target_sources(myapp PRIVATE file.cxx) |
| endif() |
| target_link_libraries(myapp |
| PRIVATE $<$<LINK_LANG_AND_ID:CXX,Clang,AppleClang>:libCXX_Clang> |
| $<$<LINK_LANG_AND_ID:C,Clang,AppleClang>:libC_Clang> |
| $<$<LINK_LANG_AND_ID:CXX,Intel>:libCXX_Intel> |
| $<$<LINK_LANG_AND_ID:C,Intel>:libC_Intel>) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| This specifies the use of different link libraries based on both the |
| compiler id and link language. This example will have target \fBlibCXX_Clang\fP |
| as link dependency when \fBClang\fP or \fBAppleClang\fP is the \fBCXX\fP |
| linker, and \fBlibCXX_Intel\fP when \fBIntel\fP is the \fBCXX\fP linker. |
| Likewise when the \fBC\fP linker is \fBClang\fP or \fBAppleClang\fP, target |
| \fBlibC_Clang\fP will be added as link dependency and \fBlibC_Intel\fP when |
| \fBIntel\fP is the \fBC\fP linker. |
| .sp |
| See \fI\%the note related to\fP |
| \fB$<LINK_LANGUAGE:language>\fP for constraints about the usage of this |
| generator expression. |
| .UNINDENT |
| .SS Link Features |
| .INDENT 0.0 |
| .TP |
| .B $<LINK_LIBRARY:feature,library\-list> |
| Added in version 3.24. |
| |
| .sp |
| Specify a set of libraries to link to a target, along with a \fBfeature\fP |
| which provides details about \fIhow\fP they should be linked. For example: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(lib1 STATIC ...) |
| add_library(lib2 ...) |
| target_link_libraries(lib2 PRIVATE \(dq$<LINK_LIBRARY:WHOLE_ARCHIVE,lib1>\(dq) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| This specifies that \fBlib2\fP should link to \fBlib1\fP and use the |
| \fBWHOLE_ARCHIVE\fP feature when doing so. |
| .sp |
| Feature names are case\-sensitive and may only contain letters, numbers and |
| underscores. Feature names defined in all uppercase are reserved for CMake\(aqs |
| own built\-in features. The pre\-defined built\-in library features are: |
| .INDENT 7.0 |
| .TP |
| .B \fBDEFAULT\fP |
| This feature corresponds to standard linking, essentially equivalent to |
| using no feature at all. It is typically only used with the |
| \X'tty: link #prop_tgt:LINK_LIBRARY_OVERRIDE'\fI\%LINK_LIBRARY_OVERRIDE\fP\X'tty: link' and |
| \X'tty: link #prop_tgt:LINK_LIBRARY_OVERRIDE_<LIBRARY>'\fI\%LINK_LIBRARY_OVERRIDE_<LIBRARY>\fP\X'tty: link' target properties. |
| .TP |
| .B \fBWHOLE_ARCHIVE\fP |
| Force inclusion of all members of a static library. This feature is only |
| supported for the following platforms, with limitations as noted: |
| .INDENT 7.0 |
| .IP \(bu 2 |
| Linux. |
| .IP \(bu 2 |
| All BSD variants. |
| .IP \(bu 2 |
| SunOS. |
| .IP \(bu 2 |
| All Apple variants. The library must be specified as a CMake target name, |
| a library file name (such as \fBlibfoo.a\fP), or a library file path (such as |
| \fB/path/to/libfoo.a\fP). Due to a limitation of the Apple linker, it |
| cannot be specified as a plain library name like \fBfoo\fP, where \fBfoo\fP |
| is not a CMake target. |
| .IP \(bu 2 |
| Windows. When using a MSVC or MSVC\-like toolchain, the MSVC version must |
| be greater than 1900. |
| .IP \(bu 2 |
| Cygwin. |
| .IP \(bu 2 |
| MSYS. |
| .UNINDENT |
| .TP |
| .B \fBFRAMEWORK\fP |
| This option tells the linker to search for the specified framework using |
| the \fB\-framework\fP linker option. It can only be used on Apple platforms, |
| and only with a linker that understands the option used (i.e. the linker |
| provided with Xcode, or one compatible with it). |
| .sp |
| The framework can be specified as a CMake framework target, a bare framework |
| name, or a file path. If a target is given, that target must have the |
| \X'tty: link #prop_tgt:FRAMEWORK'\fI\%FRAMEWORK\fP\X'tty: link' target property set to true. For a file path, if it |
| contains a directory part, that directory will be added as a framework |
| search path. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(lib SHARED ...) |
| target_link_libraries(lib PRIVATE \(dq$<LINK_LIBRARY:FRAMEWORK,/path/to/my_framework>\(dq) |
| |
| # The constructed linker command line will contain: |
| # \-F/path/to \-framework my_framework |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| File paths must conform to one of the following patterns (\fB*\fP is a |
| wildcard, and optional parts are shown as \fB[...]\fP): |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .INDENT 0.0 |
| .IP \(bu 2 |
| \fB[/path/to/]FwName[.framework]\fP |
| .IP \(bu 2 |
| \fB[/path/to/]FwName.framework/FwName[suffix]\fP |
| .IP \(bu 2 |
| \fB[/path/to/]FwName.framework/Versions/*/FwName[suffix]\fP |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Note that CMake recognizes and automatically handles framework targets, |
| even without using the \fI\%$<LINK_LIBRARY:FRAMEWORK,...>\fP expression. |
| The generator expression can still be used with a CMake target if the |
| project wants to be explicit about it, but it is not required to do so. |
| The linker command line may have some differences between using the |
| generator expression or not, but the final result should be the same. |
| On the other hand, if a file path is given, CMake will recognize some paths |
| automatically, but not all cases. The project may want to use |
| \fI\%$<LINK_LIBRARY:FRAMEWORK,...>\fP for file paths so that the expected |
| behavior is clear. |
| .sp |
| Added in version 3.25: The \X'tty: link #prop_tgt:FRAMEWORK_MULTI_CONFIG_POSTFIX_<CONFIG>'\fI\%FRAMEWORK_MULTI_CONFIG_POSTFIX_<CONFIG>\fP\X'tty: link' target property as |
| well as the \fBsuffix\fP of the framework library name are now supported by |
| the \fBFRAMEWORK\fP features. |
| |
| .TP |
| .B \fBNEEDED_FRAMEWORK\fP |
| This is similar to the \fBFRAMEWORK\fP feature, except it forces the linker |
| to link with the framework even if no symbols are used from it. It uses |
| the \fB\-needed_framework\fP option and has the same linker constraints as |
| \fBFRAMEWORK\fP\&. |
| .TP |
| .B \fBREEXPORT_FRAMEWORK\fP |
| This is similar to the \fBFRAMEWORK\fP feature, except it tells the linker |
| that the framework should be available to clients linking to the library |
| being created. It uses the \fB\-reexport_framework\fP option and has the |
| same linker constraints as \fBFRAMEWORK\fP\&. |
| .TP |
| .B \fBWEAK_FRAMEWORK\fP |
| This is similar to the \fBFRAMEWORK\fP feature, except it forces the linker |
| to mark the framework and all references to it as weak imports. It uses |
| the \fB\-weak_framework\fP option and has the same linker constraints as |
| \fBFRAMEWORK\fP\&. |
| .TP |
| .B \fBNEEDED_LIBRARY\fP |
| This is similar to the \fBNEEDED_FRAMEWORK\fP feature, except it is for use |
| with non\-framework targets or libraries (Apple platforms only). |
| It uses the \fB\-needed_library\fP or \fB\-needed\-l\fP option as appropriate, |
| and has the same linker constraints as \fBNEEDED_FRAMEWORK\fP\&. |
| .TP |
| .B \fBREEXPORT_LIBRARY\fP |
| This is similar to the \fBREEXPORT_FRAMEWORK\fP feature, except it is for use |
| with non\-framework targets or libraries (Apple platforms only). |
| It uses the \fB\-reexport_library\fP or \fB\-reexport\-l\fP option as appropriate, |
| and has the same linker constraints as \fBREEXPORT_FRAMEWORK\fP\&. |
| .TP |
| .B \fBWEAK_LIBRARY\fP |
| This is similar to the \fBWEAK_FRAMEWORK\fP feature, except it is for use |
| with non\-framework targets or libraries (Apple platforms only). |
| It uses the \fB\-weak_library\fP or \fB\-weak\-l\fP option as appropriate, |
| and has the same linker constraints as \fBWEAK_FRAMEWORK\fP\&. |
| .UNINDENT |
| .sp |
| Built\-in and custom library features are defined in terms of the following |
| variables: |
| .INDENT 7.0 |
| .IP \(bu 2 |
| \X'tty: link #variable:CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED'\fI\%CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED\fP\X'tty: link' |
| .IP \(bu 2 |
| \X'tty: link #variable:CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>'\fI\%CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>\fP\X'tty: link' |
| .IP \(bu 2 |
| \X'tty: link #variable:CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED'\fI\%CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED\fP\X'tty: link' |
| .IP \(bu 2 |
| \X'tty: link #variable:CMAKE_LINK_LIBRARY_USING_<FEATURE>'\fI\%CMAKE_LINK_LIBRARY_USING_<FEATURE>\fP\X'tty: link' |
| .UNINDENT |
| .sp |
| The value used for each of these variables is the value as set at the end of |
| the directory scope in which the target was created. The usage is as follows: |
| .INDENT 7.0 |
| .IP 1. 3 |
| If the language\-specific |
| \X'tty: link #variable:CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED'\fI\%CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED\fP\X'tty: link' variable |
| is true, the \fBfeature\fP must be defined by the corresponding |
| \X'tty: link #variable:CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>'\fI\%CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>\fP\X'tty: link' variable. |
| .IP 2. 3 |
| If no language\-specific \fBfeature\fP is supported, then the |
| \X'tty: link #variable:CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED'\fI\%CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED\fP\X'tty: link' variable must be |
| true and the \fBfeature\fP must be defined by the corresponding |
| \X'tty: link #variable:CMAKE_LINK_LIBRARY_USING_<FEATURE>'\fI\%CMAKE_LINK_LIBRARY_USING_<FEATURE>\fP\X'tty: link' variable. |
| .UNINDENT |
| .sp |
| The following limitations should be noted: |
| .INDENT 7.0 |
| .IP \(bu 2 |
| The \fBlibrary\-list\fP can specify CMake targets or libraries. |
| Any CMake target of type \X'tty: link #object-libraries'\fI\%OBJECT\fP\X'tty: link' |
| or \X'tty: link #interface-libraries'\fI\%INTERFACE\fP\X'tty: link' will ignore the feature aspect |
| of the expression and instead be linked in the standard way. |
| .IP \(bu 2 |
| The \fB$<LINK_LIBRARY:...>\fP generator expression can only be used to |
| specify link libraries. In practice, this means it can appear in the |
| \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link', \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link', and |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES_DIRECT'\fI\%INTERFACE_LINK_LIBRARIES_DIRECT\fP\X'tty: link' target properties, and be |
| specified in \X'tty: link #command:target_link_libraries'\fI\%target_link_libraries()\fP\X'tty: link' and \X'tty: link #command:link_libraries'\fI\%link_libraries()\fP\X'tty: link' |
| commands. |
| .IP \(bu 2 |
| If a \fB$<LINK_LIBRARY:...>\fP generator expression appears in the |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link' property of a target, it will be |
| included in the imported target generated by a \X'tty: link #export'\fI\%install(EXPORT)\fP\X'tty: link' |
| command. It is the responsibility of the environment consuming this |
| import to define the link feature used by this expression. |
| .IP \(bu 2 |
| Each target or library involved in the link step must have at most only |
| one kind of library feature. The absence of a feature is also incompatible |
| with all other features. For example: |
| .INDENT 2.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(lib1 ...) |
| add_library(lib2 ...) |
| add_library(lib3 ...) |
| |
| # lib1 will be associated with feature1 |
| target_link_libraries(lib2 PUBLIC \(dq$<LINK_LIBRARY:feature1,lib1>\(dq) |
| |
| # lib1 is being linked with no feature here. This conflicts with the |
| # use of feature1 in the line above and would result in an error. |
| target_link_libraries(lib3 PRIVATE lib1 lib2) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Where it isn\(aqt possible to use the same feature throughout a build for a |
| given target or library, the \X'tty: link #prop_tgt:LINK_LIBRARY_OVERRIDE'\fI\%LINK_LIBRARY_OVERRIDE\fP\X'tty: link' and |
| \X'tty: link #prop_tgt:LINK_LIBRARY_OVERRIDE_<LIBRARY>'\fI\%LINK_LIBRARY_OVERRIDE_<LIBRARY>\fP\X'tty: link' target properties can be |
| used to resolve such incompatibilities. |
| .IP \(bu 2 |
| The \fB$<LINK_LIBRARY:...>\fP generator expression does not guarantee |
| that the list of specified targets and libraries will be kept grouped |
| together. To manage constructs like \fB\-\-start\-group\fP and \fB\-\-end\-group\fP, |
| as supported by the GNU \fBld\fP linker, use the \fI\%LINK_GROUP\fP |
| generator expression instead. |
| .UNINDENT |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<LINK_GROUP:feature,library\-list> |
| Added in version 3.24. |
| |
| .sp |
| Specify a group of libraries to link to a target, along with a \fBfeature\fP |
| which defines how that group should be linked. For example: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(lib1 STATIC ...) |
| add_library(lib2 ...) |
| target_link_libraries(lib2 PRIVATE \(dq$<LINK_GROUP:RESCAN,lib1,external>\(dq) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| This specifies that \fBlib2\fP should link to \fBlib1\fP and \fBexternal\fP, and |
| that both of those two libraries should be included on the linker command |
| line according to the definition of the \fBRESCAN\fP feature. |
| .sp |
| Feature names are case\-sensitive and may only contain letters, numbers and |
| underscores. Feature names defined in all uppercase are reserved for CMake\(aqs |
| own built\-in features. Currently, there is only one pre\-defined built\-in |
| group feature: |
| .INDENT 7.0 |
| .TP |
| .B \fBRESCAN\fP |
| Some linkers are single\-pass only. For such linkers, circular references |
| between libraries typically result in unresolved symbols. This feature |
| instructs the linker to search the specified static libraries repeatedly |
| until no new undefined references are created. |
| .sp |
| Normally, a static library is searched only once in the order that it is |
| specified on the command line. If a symbol in that library is needed to |
| resolve an undefined symbol referred to by an object in a library that |
| appears later on the command line, the linker would not be able to resolve |
| that reference. By grouping the static libraries with the \fBRESCAN\fP |
| feature, they will all be searched repeatedly until all possible references |
| are resolved. This will use linker options like \fB\-\-start\-group\fP and |
| \fB\-\-end\-group\fP, or on SunOS, \fB\-z rescan\-start\fP and \fB\-z rescan\-end\fP\&. |
| .sp |
| Using this feature has a significant performance cost. It is best to use it |
| only when there are unavoidable circular references between two or more |
| static libraries. |
| .sp |
| This feature is available when using toolchains that target Linux, BSD, and |
| SunOS. It can also be used when targeting Windows platforms if the GNU |
| toolchain is used. |
| .UNINDENT |
| .sp |
| Built\-in and custom group features are defined in terms of the following |
| variables: |
| .INDENT 7.0 |
| .IP \(bu 2 |
| \X'tty: link #variable:CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED'\fI\%CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED\fP\X'tty: link' |
| .IP \(bu 2 |
| \X'tty: link #variable:CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>'\fI\%CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>\fP\X'tty: link' |
| .IP \(bu 2 |
| \X'tty: link #variable:CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED'\fI\%CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED\fP\X'tty: link' |
| .IP \(bu 2 |
| \X'tty: link #variable:CMAKE_LINK_GROUP_USING_<FEATURE>'\fI\%CMAKE_LINK_GROUP_USING_<FEATURE>\fP\X'tty: link' |
| .UNINDENT |
| .sp |
| The value used for each of these variables is the value as set at the end of |
| the directory scope in which the target was created. The usage is as follows: |
| .INDENT 7.0 |
| .IP 1. 3 |
| If the language\-specific |
| \X'tty: link #variable:CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED'\fI\%CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED\fP\X'tty: link' variable |
| is true, the \fBfeature\fP must be defined by the corresponding |
| \X'tty: link #variable:CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>'\fI\%CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>\fP\X'tty: link' variable. |
| .IP 2. 3 |
| If no language\-specific \fBfeature\fP is supported, then the |
| \X'tty: link #variable:CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED'\fI\%CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED\fP\X'tty: link' variable must be |
| true and the \fBfeature\fP must be defined by the corresponding |
| \X'tty: link #variable:CMAKE_LINK_GROUP_USING_<FEATURE>'\fI\%CMAKE_LINK_GROUP_USING_<FEATURE>\fP\X'tty: link' variable. |
| .UNINDENT |
| .sp |
| The \fBLINK_GROUP\fP generator expression is compatible with the |
| \fI\%LINK_LIBRARY\fP generator expression. The libraries involved in a |
| group can be specified using the \fI\%LINK_LIBRARY\fP generator expression. |
| .sp |
| Each target or external library involved in the link step is allowed to be |
| part of multiple groups, but only if all the groups involved specify the |
| same \fBfeature\fP\&. Such groups will not be merged on the linker command line, |
| the individual groups will still be preserved. Mixing different group |
| features for the same target or library is forbidden. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(lib1 ...) |
| add_library(lib2 ...) |
| add_library(lib3 ...) |
| add_library(lib4 ...) |
| add_library(lib5 ...) |
| |
| target_link_libraries(lib3 PUBLIC \(dq$<LINK_GROUP:feature1,lib1,lib2>\(dq) |
| target_link_libraries(lib4 PRIVATE \(dq$<LINK_GROUP:feature1,lib1,lib3>\(dq) |
| # lib4 will be linked with the groups {lib1,lib2} and {lib1,lib3}. |
| # Both groups specify the same feature, so this is fine. |
| |
| target_link_libraries(lib5 PRIVATE \(dq$<LINK_GROUP:feature2,lib1,lib3>\(dq) |
| # An error will be raised here because both lib1 and lib3 are part of two |
| # groups with different features. |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| When a target or an external library is involved in the link step as part of |
| a group and also as not part of any group, any occurrence of the non\-group |
| link item will be replaced by the groups it belongs to. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(lib1 ...) |
| add_library(lib2 ...) |
| add_library(lib3 ...) |
| add_library(lib4 ...) |
| |
| target_link_libraries(lib3 PUBLIC lib1) |
| |
| target_link_libraries(lib4 PRIVATE lib3 \(dq$<LINK_GROUP:feature1,lib1,lib2>\(dq) |
| # lib4 will only be linked with lib3 and the group {lib1,lib2} |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Because \fBlib1\fP is part of the group defined for \fBlib4\fP, that group then |
| gets applied back to the use of \fBlib1\fP for \fBlib3\fP\&. The end result will |
| be as though the linking relationship for \fBlib3\fP had been specified as: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| target_link_libraries(lib3 PUBLIC \(dq$<LINK_GROUP:feature1,lib1,lib2>\(dq) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Be aware that the precedence of the group over the non\-group link item can |
| result in circular dependencies between groups. If this occurs, a fatal |
| error is raised because circular dependencies are not allowed for groups. |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(lib1A ...) |
| add_library(lib1B ...) |
| add_library(lib2A ...) |
| add_library(lib2B ...) |
| add_library(lib3 ...) |
| |
| # Non\-group linking relationships, these are non\-circular so far |
| target_link_libraries(lib1A PUBLIC lib2A) |
| target_link_libraries(lib2B PUBLIC lib1B) |
| |
| # The addition of these groups creates circular dependencies |
| target_link_libraries(lib3 PRIVATE |
| \(dq$<LINK_GROUP:feat,lib1A,lib1B>\(dq |
| \(dq$<LINK_GROUP:feat,lib2A,lib2B>\(dq |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| Because of the groups defined for \fBlib3\fP, the linking relationships for |
| \fBlib1A\fP and \fBlib2B\fP effectively get expanded to the equivalent of: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| target_link_libraries(lib1A PUBLIC \(dq$<LINK_GROUP:feat,lib2A,lib2B>\(dq) |
| target_link_libraries(lib2B PUBLIC \(dq$<LINK_GROUP:feat,lib1A,lib1B>\(dq) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| This creates a circular dependency between groups: |
| \fBlib1A \-\-> lib2B \-\-> lib1A\fP\&. |
| .sp |
| The following limitations should also be noted: |
| .INDENT 7.0 |
| .IP \(bu 2 |
| The \fBlibrary\-list\fP can specify CMake targets or libraries. |
| Any CMake target of type \X'tty: link #object-libraries'\fI\%OBJECT\fP\X'tty: link' |
| or \X'tty: link #interface-libraries'\fI\%INTERFACE\fP\X'tty: link' will ignore the feature aspect |
| of the expression and instead be linked in the standard way. |
| .IP \(bu 2 |
| The \fB$<LINK_GROUP:...>\fP generator expression can only be used to |
| specify link libraries. In practice, this means it can appear in the |
| \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link', \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link',and |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES_DIRECT'\fI\%INTERFACE_LINK_LIBRARIES_DIRECT\fP\X'tty: link' target properties, and be |
| specified in \X'tty: link #command:target_link_libraries'\fI\%target_link_libraries()\fP\X'tty: link' and \X'tty: link #command:link_libraries'\fI\%link_libraries()\fP\X'tty: link' |
| commands. |
| .IP \(bu 2 |
| If a \fB$<LINK_GROUP:...>\fP generator expression appears in the |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link' property of a target, it will be |
| included in the imported target generated by a \X'tty: link #export'\fI\%install(EXPORT)\fP\X'tty: link' |
| command. It is the responsibility of the environment consuming this |
| import to define the link feature used by this expression. |
| .UNINDENT |
| .UNINDENT |
| .SS Link Context |
| .INDENT 0.0 |
| .TP |
| .B $<LINK_ONLY:...> |
| Added in version 3.1. |
| |
| .sp |
| Content of \fB\&...\fP, except while collecting usage requirements from |
| \X'tty: link #transitive-compile-properties'\fI\%transitive compile properties\fP\X'tty: link', |
| in which case it is the empty string. This is intended for use in an |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link' target property, typically populated |
| via the \X'tty: link #command:target_link_libraries'\fI\%target_link_libraries()\fP\X'tty: link' command, to specify private link |
| dependencies without other usage requirements such as include directories or |
| compile options. |
| .sp |
| Added in version 3.24: \fBLINK_ONLY\fP may also be used in a \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link' target |
| property. See policy \X'tty: link #policy:CMP0131'\fI\%CMP0131\fP\X'tty: link'\&. |
| |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<DEVICE_LINK:list> |
| Added in version 3.18. |
| |
| .sp |
| Returns the list if it is the device link step, an empty list otherwise. |
| The device link step is controlled by \X'tty: link #prop_tgt:CUDA_SEPARABLE_COMPILATION'\fI\%CUDA_SEPARABLE_COMPILATION\fP\X'tty: link' |
| and \X'tty: link #prop_tgt:CUDA_RESOLVE_DEVICE_SYMBOLS'\fI\%CUDA_RESOLVE_DEVICE_SYMBOLS\fP\X'tty: link' properties and |
| policy \X'tty: link #policy:CMP0105'\fI\%CMP0105\fP\X'tty: link'\&. This expression can only be used to specify link |
| options. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<HOST_LINK:list> |
| Added in version 3.18. |
| |
| .sp |
| Returns the list if it is the normal link step, an empty list otherwise. |
| This expression is mainly useful when a device link step is also involved |
| (see \fI\%$<DEVICE_LINK:list>\fP generator expression). This expression can |
| only be used to specify link options. |
| .UNINDENT |
| .SS Target\-Dependent Expressions |
| .SS Target Meta\-Data |
| .sp |
| These expressions look up information about a target. |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_EXISTS:tgt> |
| Added in version 3.12. |
| |
| .sp |
| \fB1\fP if \fBtgt\fP exists as a CMake target, else \fB0\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_NAME_IF_EXISTS:tgt> |
| Added in version 3.12. |
| |
| .sp |
| The target name \fBtgt\fP if the target exists, an empty string otherwise. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_NAME:tgt> |
| The target name \fBtgt\fP as written. This marks \fBtgt\fP as being the name |
| of a target inside a larger expression, which is required if exporting |
| targets to multiple dependent export sets. The \fBtgt\fP text must be a |
| literal name of a target; it may not contain generator expressions. |
| The target does not have to exist. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_POLICY:policy> |
| \fB1\fP if the \fBpolicy\fP was \fBNEW\fP when the \(aqhead\(aq target was created, |
| else \fB0\fP\&. If the \fBpolicy\fP was not set, the warning message for the policy |
| will be emitted. This generator expression only works for a subset of |
| policies. |
| .UNINDENT |
| .SS Target Properties |
| .sp |
| These expressions look up the values of |
| \X'tty: link #target-properties'\fI\%target properties\fP\X'tty: link'\&. |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_PROPERTY:tgt,prop> |
| Value of the property \fBprop\fP on the target \fBtgt\fP, or empty if |
| the property is not set. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .sp |
| Changed in version 3.26: When encountered during evaluation of \X'tty: link #target-usage-requirements'\fI\%Target Usage Requirements\fP\X'tty: link', |
| typically in an \fBINTERFACE_*\fP target property, lookup of the \fBtgt\fP |
| name occurs in the directory of the target specifying the requirement, |
| rather than the directory of the consuming target for which the |
| expression is being evaluated. |
| |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_PROPERTY:prop> |
| Value of the property \fBprop\fP on the target for which the expression |
| is being evaluated, or empty if the property is not set. |
| Note that for generator expressions in \X'tty: link #target-usage-requirements'\fI\%Target Usage Requirements\fP\X'tty: link' |
| this is the consuming target rather than the target specifying the |
| requirement. |
| .UNINDENT |
| .sp |
| The expressions have special evaluation rules for some properties: |
| .INDENT 0.0 |
| .TP |
| .B \X'tty: link #target-build-specification'\fI\%Target Build Specification Properties\fP\X'tty: link' |
| These evaluate as a \X'tty: link #cmake-language-lists'\fI\%semicolon\-separated list\fP\X'tty: link' |
| representing the union of the value on the target itself with the values |
| of the corresponding \X'tty: link #target-usage-requirements'\fI\%Target Usage Requirements\fP\X'tty: link' on targets named by |
| the target\(aqs \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link': |
| .INDENT 7.0 |
| .IP \(bu 2 |
| For \X'tty: link #target-compile-properties'\fI\%Target Compile Properties\fP\X'tty: link', evaluation of corresponding usage |
| requirements is transitive over the closure of the linked targets\(aq |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link' \fIexcluding\fP entries guarded by the |
| \fI\%LINK_ONLY\fP generator expression. |
| .IP \(bu 2 |
| For \X'tty: link #target-link-properties'\fI\%Target Link Properties\fP\X'tty: link', evaluation of corresponding usage |
| requirements is transitive over the closure of the linked targets\(aq |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link' \fIincluding\fP entries guarded by the |
| \fI\%LINK_ONLY\fP generator expression. See policy \X'tty: link #policy:CMP0166'\fI\%CMP0166\fP\X'tty: link'\&. |
| .UNINDENT |
| .sp |
| Evaluation of \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link' itself is not transitive. |
| .TP |
| .B \X'tty: link #target-usage-requirements'\fI\%Target Usage Requirement Properties\fP\X'tty: link' |
| These evaluate as a \X'tty: link #cmake-language-lists'\fI\%semicolon\-separated list\fP\X'tty: link' |
| representing the union of the value on the target itself with the values |
| of the same properties on targets named by the target\(aqs |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link': |
| .INDENT 7.0 |
| .IP \(bu 2 |
| For \X'tty: link #transitive-compile-properties'\fI\%Transitive Compile Properties\fP\X'tty: link', evaluation is transitive over |
| the closure of the target\(aqs \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link' |
| \fIexcluding\fP entries guarded by the \fI\%LINK_ONLY\fP generator expression. |
| .IP \(bu 2 |
| For \X'tty: link #transitive-link-properties'\fI\%Transitive Link Properties\fP\X'tty: link', evaluation is transitive over |
| the closure of the target\(aqs \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link' |
| \fIincluding\fP entries guarded by the \fI\%LINK_ONLY\fP generator expression. |
| See policy \X'tty: link #policy:CMP0166'\fI\%CMP0166\fP\X'tty: link'\&. |
| .UNINDENT |
| .sp |
| Evaluation of \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link' itself is not transitive. |
| .TP |
| .B \X'tty: link #custom-transitive-properties'\fI\%Custom Transitive Properties\fP\X'tty: link' |
| Added in version 3.30. |
| |
| .sp |
| These are processed during evaluation as follows: |
| .INDENT 7.0 |
| .IP \(bu 2 |
| Evaluation of \fI\%$<TARGET_PROPERTY:tgt,PROP>\fP for some property |
| \fBPROP\fP, named without an \fBINTERFACE_\fP prefix, |
| checks the \X'tty: link #prop_tgt:TRANSITIVE_COMPILE_PROPERTIES'\fI\%TRANSITIVE_COMPILE_PROPERTIES\fP\X'tty: link' |
| and \X'tty: link #prop_tgt:TRANSITIVE_LINK_PROPERTIES'\fI\%TRANSITIVE_LINK_PROPERTIES\fP\X'tty: link' properties on target \fBtgt\fP, |
| on targets named by its \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link', and on the |
| transitive closure of targets named by the linked targets\(aq |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link'\&. |
| .sp |
| If \fBPROP\fP is listed by one of those properties, then it evaluates as |
| a \X'tty: link #cmake-language-lists'\fI\%semicolon\-separated list\fP\X'tty: link' representing |
| the union of the value on the target itself with the values of the |
| corresponding \fBINTERFACE_PROP\fP on targets named by the target\(aqs |
| \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link': |
| .INDENT 2.0 |
| .IP \(bu 2 |
| If \fBPROP\fP is named by \X'tty: link #prop_tgt:TRANSITIVE_COMPILE_PROPERTIES'\fI\%TRANSITIVE_COMPILE_PROPERTIES\fP\X'tty: link', |
| evaluation of the corresponding \fBINTERFACE_PROP\fP is transitive over |
| the closure of the linked targets\(aq \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link', |
| excluding entries guarded by the \fI\%LINK_ONLY\fP generator expression. |
| .IP \(bu 2 |
| If \fBPROP\fP is named by \X'tty: link #prop_tgt:TRANSITIVE_LINK_PROPERTIES'\fI\%TRANSITIVE_LINK_PROPERTIES\fP\X'tty: link', |
| evaluation of the corresponding \fBINTERFACE_PROP\fP is transitive over |
| the closure of the linked targets\(aq \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link', |
| including entries guarded by the \fI\%LINK_ONLY\fP generator expression. |
| .UNINDENT |
| .IP \(bu 2 |
| Evaluation of \fI\%$<TARGET_PROPERTY:tgt,INTERFACE_PROP>\fP for some |
| property \fBINTERFACE_PROP\fP, named with an \fBINTERFACE_\fP prefix, |
| checks the \X'tty: link #prop_tgt:TRANSITIVE_COMPILE_PROPERTIES'\fI\%TRANSITIVE_COMPILE_PROPERTIES\fP\X'tty: link' |
| and \X'tty: link #prop_tgt:TRANSITIVE_LINK_PROPERTIES'\fI\%TRANSITIVE_LINK_PROPERTIES\fP\X'tty: link' properties on target \fBtgt\fP, |
| and on the transitive closure of targets named by its |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link'\&. |
| .sp |
| If the corresponding \fBPROP\fP is listed by one of those properties, |
| then \fBINTERFACE_PROP\fP evaluates as a |
| \X'tty: link #cmake-language-lists'\fI\%semicolon\-separated list\fP\X'tty: link' representing the |
| union of the value on the target itself with the value of the same |
| property on targets named by the target\(aqs |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link': |
| .INDENT 2.0 |
| .IP \(bu 2 |
| If \fBPROP\fP is named by \X'tty: link #prop_tgt:TRANSITIVE_COMPILE_PROPERTIES'\fI\%TRANSITIVE_COMPILE_PROPERTIES\fP\X'tty: link', |
| evaluation of the corresponding \fBINTERFACE_PROP\fP is transitive over |
| the closure of the target\(aqs \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link', |
| excluding entries guarded by the \fI\%LINK_ONLY\fP generator expression. |
| .IP \(bu 2 |
| If \fBPROP\fP is named by \X'tty: link #prop_tgt:TRANSITIVE_LINK_PROPERTIES'\fI\%TRANSITIVE_LINK_PROPERTIES\fP\X'tty: link', |
| evaluation of the corresponding \fBINTERFACE_PROP\fP is transitive over |
| the closure of the target\(aqs \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link', |
| including entries guarded by the \fI\%LINK_ONLY\fP generator expression. |
| .UNINDENT |
| .UNINDENT |
| .sp |
| If a \fBPROP\fP is named by both \X'tty: link #prop_tgt:TRANSITIVE_COMPILE_PROPERTIES'\fI\%TRANSITIVE_COMPILE_PROPERTIES\fP\X'tty: link' |
| and \X'tty: link #prop_tgt:TRANSITIVE_LINK_PROPERTIES'\fI\%TRANSITIVE_LINK_PROPERTIES\fP\X'tty: link', the latter takes precedence. |
| .TP |
| .B \X'tty: link #compatible-interface-properties'\fI\%Compatible Interface Properties\fP\X'tty: link' |
| These evaluate as a single value combined from the target itself, |
| from targets named by the target\(aqs \X'tty: link #prop_tgt:LINK_LIBRARIES'\fI\%LINK_LIBRARIES\fP\X'tty: link', and |
| from the transitive closure of the linked targets\(aq |
| \X'tty: link #prop_tgt:INTERFACE_LINK_LIBRARIES'\fI\%INTERFACE_LINK_LIBRARIES\fP\X'tty: link'\&. Values of a compatible |
| interface property from multiple targets combine based on the type |
| of compatibility required by the \fBCOMPATIBLE_INTERFACE_*\fP property |
| defining it. |
| .UNINDENT |
| .SS Target Artifacts |
| .sp |
| These expressions look up information about artifacts associated with |
| a given target \fBtgt\fP\&. Unless otherwise stated, this can be any |
| runtime artifact, namely: |
| .INDENT 0.0 |
| .IP \(bu 2 |
| An executable target created by \X'tty: link #command:add_executable'\fI\%add_executable()\fP\X'tty: link'\&. |
| .IP \(bu 2 |
| A shared library target (\fB\&.so\fP, \fB\&.dll\fP but not their \fB\&.lib\fP import |
| library) created by \X'tty: link #command:add_library'\fI\%add_library()\fP\X'tty: link'\&. |
| .IP \(bu 2 |
| A static library target created by \X'tty: link #command:add_library'\fI\%add_library()\fP\X'tty: link'\&. |
| .UNINDENT |
| .sp |
| In the following, the phrase \(dqthe \fBtgt\fP filename\(dq means the name of the |
| \fBtgt\fP binary file. This has to be distinguished from the phrase |
| \(dqthe target name\(dq, which is just the string \fBtgt\fP\&. |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_FILE:tgt> |
| Full path to the \fBtgt\fP binary file. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on, unless the expression is being used in |
| \X'tty: link #command:add_custom_command'\fI\%add_custom_command()\fP\X'tty: link' or \X'tty: link #command:add_custom_target'\fI\%add_custom_target()\fP\X'tty: link'\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_FILE_BASE_NAME:tgt> |
| Added in version 3.15. |
| |
| .sp |
| Base name of \fBtgt\fP, i.e. \fB$<TARGET_FILE_NAME:tgt>\fP without prefix and |
| suffix. |
| For example, if the \fBtgt\fP filename is \fBlibbase.so\fP, the base name is \fBbase\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:OUTPUT_NAME'\fI\%OUTPUT_NAME\fP\X'tty: link', \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME'\fI\%ARCHIVE_OUTPUT_NAME\fP\X'tty: link', |
| \X'tty: link #prop_tgt:LIBRARY_OUTPUT_NAME'\fI\%LIBRARY_OUTPUT_NAME\fP\X'tty: link' and \X'tty: link #prop_tgt:RUNTIME_OUTPUT_NAME'\fI\%RUNTIME_OUTPUT_NAME\fP\X'tty: link' |
| target properties and their configuration specific variants |
| \X'tty: link #prop_tgt:OUTPUT_NAME_<CONFIG>'\fI\%OUTPUT_NAME_<CONFIG>\fP\X'tty: link', \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME_<CONFIG>'\fI\%ARCHIVE_OUTPUT_NAME_<CONFIG>\fP\X'tty: link', |
| \X'tty: link #prop_tgt:LIBRARY_OUTPUT_NAME_<CONFIG>'\fI\%LIBRARY_OUTPUT_NAME_<CONFIG>\fP\X'tty: link' and |
| \X'tty: link #prop_tgt:RUNTIME_OUTPUT_NAME_<CONFIG>'\fI\%RUNTIME_OUTPUT_NAME_<CONFIG>\fP\X'tty: link'\&. |
| .sp |
| The \X'tty: link #prop_tgt:<CONFIG>_POSTFIX'\fI\%<CONFIG>_POSTFIX\fP\X'tty: link' and \X'tty: link #prop_tgt:DEBUG_POSTFIX'\fI\%DEBUG_POSTFIX\fP\X'tty: link' target |
| properties can also be considered. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_FILE_PREFIX:tgt> |
| Added in version 3.15. |
| |
| .sp |
| Prefix of the \fBtgt\fP filename (such as \fBlib\fP). |
| .sp |
| See also the \X'tty: link #prop_tgt:PREFIX'\fI\%PREFIX\fP\X'tty: link' target property. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_FILE_SUFFIX:tgt> |
| Added in version 3.15. |
| |
| .sp |
| Suffix of the \fBtgt\fP filename (extension such as \fB\&.so\fP or \fB\&.exe\fP). |
| .sp |
| See also the \X'tty: link #prop_tgt:SUFFIX'\fI\%SUFFIX\fP\X'tty: link' target property. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_FILE_NAME:tgt> |
| The \fBtgt\fP filename. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_FILE_DIR:tgt> |
| Directory of the \fBtgt\fP binary file. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_IMPORT_FILE:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Full path to the linker import file. On DLL platforms, it would be the |
| \fB\&.lib\fP file. For executables on AIX, and for shared libraries on macOS, |
| it could be, respectively, the \fB\&.imp\fP or \fB\&.tbd\fP import file, |
| depending on the value of the \X'tty: link #prop_tgt:ENABLE_EXPORTS'\fI\%ENABLE_EXPORTS\fP\X'tty: link' property. |
| .sp |
| This expands to an empty string when there is no import file associated |
| with the target. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_IMPORT_FILE_BASE_NAME:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Base name of the linker import file of the target \fBtgt\fP without prefix or |
| suffix. For example, if the target file name is \fBlibbase.tbd\fP, the base |
| name is \fBbase\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:OUTPUT_NAME'\fI\%OUTPUT_NAME\fP\X'tty: link' and \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME'\fI\%ARCHIVE_OUTPUT_NAME\fP\X'tty: link' |
| target properties and their configuration specific variants |
| \X'tty: link #prop_tgt:OUTPUT_NAME_<CONFIG>'\fI\%OUTPUT_NAME_<CONFIG>\fP\X'tty: link' and \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME_<CONFIG>'\fI\%ARCHIVE_OUTPUT_NAME_<CONFIG>\fP\X'tty: link'\&. |
| .sp |
| The \X'tty: link #prop_tgt:<CONFIG>_POSTFIX'\fI\%<CONFIG>_POSTFIX\fP\X'tty: link' and \X'tty: link #prop_tgt:DEBUG_POSTFIX'\fI\%DEBUG_POSTFIX\fP\X'tty: link' target |
| properties can also be considered. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_IMPORT_FILE_PREFIX:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Prefix of the import file of the target \fBtgt\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:IMPORT_PREFIX'\fI\%IMPORT_PREFIX\fP\X'tty: link' target property. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_IMPORT_FILE_SUFFIX:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Suffix of the import file of the target \fBtgt\fP\&. |
| .sp |
| The suffix corresponds to the file extension (such as \fB\&.lib\fP or \fB\&.tbd\fP). |
| .sp |
| See also the \X'tty: link #prop_tgt:IMPORT_SUFFIX'\fI\%IMPORT_SUFFIX\fP\X'tty: link' target property. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_IMPORT_FILE_NAME:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Name of the import file of the target \fBtgt\fP\&. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_IMPORT_FILE_DIR:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Directory of the import file of the target \fBtgt\fP\&. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_FILE:tgt> |
| File used when linking to the \fBtgt\fP target. This will usually |
| be the library that \fBtgt\fP represents (\fB\&.a\fP, \fB\&.lib\fP, \fB\&.so\fP), |
| but for a shared library on DLL platforms, it would be the \fB\&.lib\fP |
| import library associated with the DLL. |
| .sp |
| Added in version 3.27: On macOS, it could be the \fB\&.tbd\fP import file associated with the shared |
| library, depending on the value of the \X'tty: link #prop_tgt:ENABLE_EXPORTS'\fI\%ENABLE_EXPORTS\fP\X'tty: link' property. |
| |
| .sp |
| This generator expression is equivalent to |
| \fI\%$<TARGET_LINKER_LIBRARY_FILE>\fP or |
| \fI\%$<TARGET_LINKER_IMPORT_FILE>\fP generator expressions, depending on the |
| characteristics of the target and the platform. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_FILE_BASE_NAME:tgt> |
| Added in version 3.15. |
| |
| .sp |
| Base name of file used to link the target \fBtgt\fP, i.e. |
| \fI\%$<TARGET_LINKER_FILE_NAME:tgt>\fP without prefix and suffix. For |
| example, if target file name is \fBlibbase.a\fP, the base name is \fBbase\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:OUTPUT_NAME'\fI\%OUTPUT_NAME\fP\X'tty: link', \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME'\fI\%ARCHIVE_OUTPUT_NAME\fP\X'tty: link', |
| and \X'tty: link #prop_tgt:LIBRARY_OUTPUT_NAME'\fI\%LIBRARY_OUTPUT_NAME\fP\X'tty: link' target properties and their configuration |
| specific variants \X'tty: link #prop_tgt:OUTPUT_NAME_<CONFIG>'\fI\%OUTPUT_NAME_<CONFIG>\fP\X'tty: link', |
| \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME_<CONFIG>'\fI\%ARCHIVE_OUTPUT_NAME_<CONFIG>\fP\X'tty: link' and |
| \X'tty: link #prop_tgt:LIBRARY_OUTPUT_NAME_<CONFIG>'\fI\%LIBRARY_OUTPUT_NAME_<CONFIG>\fP\X'tty: link'\&. |
| .sp |
| The \X'tty: link #prop_tgt:<CONFIG>_POSTFIX'\fI\%<CONFIG>_POSTFIX\fP\X'tty: link' and \X'tty: link #prop_tgt:DEBUG_POSTFIX'\fI\%DEBUG_POSTFIX\fP\X'tty: link' target |
| properties can also be considered. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_FILE_PREFIX:tgt> |
| Added in version 3.15. |
| |
| .sp |
| Prefix of file used to link target \fBtgt\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:PREFIX'\fI\%PREFIX\fP\X'tty: link' and \X'tty: link #prop_tgt:IMPORT_PREFIX'\fI\%IMPORT_PREFIX\fP\X'tty: link' target |
| properties. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_FILE_SUFFIX:tgt> |
| Added in version 3.15. |
| |
| .sp |
| Suffix of file used to link where \fBtgt\fP is the name of a target. |
| .sp |
| The suffix corresponds to the file extension (such as \(dq.so\(dq or \(dq.lib\(dq). |
| .sp |
| See also the \X'tty: link #prop_tgt:SUFFIX'\fI\%SUFFIX\fP\X'tty: link' and \X'tty: link #prop_tgt:IMPORT_SUFFIX'\fI\%IMPORT_SUFFIX\fP\X'tty: link' target |
| properties. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_FILE_NAME:tgt> |
| Name of file used to link target \fBtgt\fP\&. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_FILE_DIR:tgt> |
| Directory of file used to link target \fBtgt\fP\&. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_LIBRARY_FILE:tgt> |
| Added in version 3.27. |
| |
| .sp |
| File used when linking o the \fBtgt\fP target is done using directly the |
| library, and not an import file. This will usually be the library that |
| \fBtgt\fP represents (\fB\&.a\fP, \fB\&.so\fP, \fB\&.dylib\fP). So, on DLL platforms, it |
| will be an empty string. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_LIBRARY_FILE_BASE_NAME:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Base name of library file used to link the target \fBtgt\fP, i.e. |
| \fI\%$<TARGET_LINKER_LIBRARY_FILE_NAME:tgt>\fP without prefix and suffix. |
| For example, if target file name is \fBlibbase.a\fP, the base name is \fBbase\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:OUTPUT_NAME'\fI\%OUTPUT_NAME\fP\X'tty: link', \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME'\fI\%ARCHIVE_OUTPUT_NAME\fP\X'tty: link', |
| and \X'tty: link #prop_tgt:LIBRARY_OUTPUT_NAME'\fI\%LIBRARY_OUTPUT_NAME\fP\X'tty: link' target properties and their configuration |
| specific variants \X'tty: link #prop_tgt:OUTPUT_NAME_<CONFIG>'\fI\%OUTPUT_NAME_<CONFIG>\fP\X'tty: link', |
| \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME_<CONFIG>'\fI\%ARCHIVE_OUTPUT_NAME_<CONFIG>\fP\X'tty: link' and |
| \X'tty: link #prop_tgt:LIBRARY_OUTPUT_NAME_<CONFIG>'\fI\%LIBRARY_OUTPUT_NAME_<CONFIG>\fP\X'tty: link'\&. |
| .sp |
| The \X'tty: link #prop_tgt:<CONFIG>_POSTFIX'\fI\%<CONFIG>_POSTFIX\fP\X'tty: link' and \X'tty: link #prop_tgt:DEBUG_POSTFIX'\fI\%DEBUG_POSTFIX\fP\X'tty: link' target |
| properties can also be considered. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_LIBRARY_FILE_PREFIX:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Prefix of the library file used to link target \fBtgt\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:PREFIX'\fI\%PREFIX\fP\X'tty: link' target property. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_LIBRARY_FILE_SUFFIX:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Suffix of the library file used to link target \fBtgt\fP\&. |
| .sp |
| The suffix corresponds to the file extension (such as \(dq.a\(dq or \(dq.dylib\(dq). |
| .sp |
| See also the \X'tty: link #prop_tgt:SUFFIX'\fI\%SUFFIX\fP\X'tty: link' target property. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_LIBRARY_FILE_NAME:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Name of the library file used to link target \fBtgt\fP\&. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_LIBRARY_FILE_DIR:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Directory of the library file used to link target \fBtgt\fP\&. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_IMPORT_FILE:tgt> |
| Added in version 3.27. |
| |
| .sp |
| File used when linking to the \fBtgt\fP target is done using an import |
| file. This will usually be the import file that \fBtgt\fP represents |
| (\fB\&.lib\fP, \fB\&.tbd\fP). So, when no import file is involved in the link step, |
| an empty string is returned. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_IMPORT_FILE_BASE_NAME:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Base name of the import file used to link the target \fBtgt\fP, i.e. |
| \fI\%$<TARGET_LINKER_IMPORT_FILE_NAME:tgt>\fP without prefix and suffix. |
| For example, if target file name is \fBlibbase.tbd\fP, the base name is \fBbase\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:OUTPUT_NAME'\fI\%OUTPUT_NAME\fP\X'tty: link' and \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME'\fI\%ARCHIVE_OUTPUT_NAME\fP\X'tty: link', |
| target properties and their configuration |
| specific variants \X'tty: link #prop_tgt:OUTPUT_NAME_<CONFIG>'\fI\%OUTPUT_NAME_<CONFIG>\fP\X'tty: link' and |
| \X'tty: link #prop_tgt:ARCHIVE_OUTPUT_NAME_<CONFIG>'\fI\%ARCHIVE_OUTPUT_NAME_<CONFIG>\fP\X'tty: link'\&. |
| .sp |
| The \X'tty: link #prop_tgt:<CONFIG>_POSTFIX'\fI\%<CONFIG>_POSTFIX\fP\X'tty: link' and \X'tty: link #prop_tgt:DEBUG_POSTFIX'\fI\%DEBUG_POSTFIX\fP\X'tty: link' target |
| properties can also be considered. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_IMPORT_FILE_PREFIX:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Prefix of the import file used to link target \fBtgt\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:IMPORT_PREFIX'\fI\%IMPORT_PREFIX\fP\X'tty: link' target property. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_IMPORT_FILE_SUFFIX:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Suffix of the import file used to link target \fBtgt\fP\&. |
| .sp |
| The suffix corresponds to the file extension (such as \(dq.lib\(dq or \(dq.tbd\(dq). |
| .sp |
| See also the \X'tty: link #prop_tgt:IMPORT_SUFFIX'\fI\%IMPORT_SUFFIX\fP\X'tty: link' target property. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_IMPORT_FILE_NAME:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Name of the import file used to link target \fBtgt\fP\&. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_LINKER_IMPORT_FILE_DIR:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Directory of the import file used to link target \fBtgt\fP\&. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_SONAME_FILE:tgt> |
| File with soname (\fB\&.so.3\fP) where \fBtgt\fP is the name of a target. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_SONAME_FILE_NAME:tgt> |
| Name of file with soname (\fB\&.so.3\fP). |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_SONAME_FILE_DIR:tgt> |
| Directory of file with soname (\fB\&.so.3\fP). |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_SONAME_IMPORT_FILE:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Import file with soname (\fB\&.3.tbd\fP) where \fBtgt\fP is the name of a target. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_SONAME_IMPORT_FILE_NAME:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Name of the import file with soname (\fB\&.3.tbd\fP). |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_SONAME_IMPORT_FILE_DIR:tgt> |
| Added in version 3.27. |
| |
| .sp |
| Directory of the import file with soname (\fB\&.3.tbd\fP). |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_PDB_FILE:tgt> |
| Added in version 3.1. |
| |
| .sp |
| Full path to the linker generated program database file (.pdb) |
| where \fBtgt\fP is the name of a target. |
| .sp |
| See also the \X'tty: link #prop_tgt:PDB_NAME'\fI\%PDB_NAME\fP\X'tty: link' and \X'tty: link #prop_tgt:PDB_OUTPUT_DIRECTORY'\fI\%PDB_OUTPUT_DIRECTORY\fP\X'tty: link' |
| target properties and their configuration specific variants |
| \X'tty: link #prop_tgt:PDB_NAME_<CONFIG>'\fI\%PDB_NAME_<CONFIG>\fP\X'tty: link' and \X'tty: link #prop_tgt:PDB_OUTPUT_DIRECTORY_<CONFIG>'\fI\%PDB_OUTPUT_DIRECTORY_<CONFIG>\fP\X'tty: link'\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_PDB_FILE_BASE_NAME:tgt> |
| Added in version 3.15. |
| |
| .sp |
| Base name of the linker generated program database file (.pdb) |
| where \fBtgt\fP is the name of a target. |
| .sp |
| The base name corresponds to the target PDB file name (see |
| \fB$<TARGET_PDB_FILE_NAME:tgt>\fP) without prefix and suffix. For example, |
| if target file name is \fBbase.pdb\fP, the base name is \fBbase\fP\&. |
| .sp |
| See also the \X'tty: link #prop_tgt:PDB_NAME'\fI\%PDB_NAME\fP\X'tty: link' target property and its configuration |
| specific variant \X'tty: link #prop_tgt:PDB_NAME_<CONFIG>'\fI\%PDB_NAME_<CONFIG>\fP\X'tty: link'\&. |
| .sp |
| The \X'tty: link #prop_tgt:<CONFIG>_POSTFIX'\fI\%<CONFIG>_POSTFIX\fP\X'tty: link' and \X'tty: link #prop_tgt:DEBUG_POSTFIX'\fI\%DEBUG_POSTFIX\fP\X'tty: link' target |
| properties can also be considered. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_PDB_FILE_NAME:tgt> |
| Added in version 3.1. |
| |
| .sp |
| Name of the linker generated program database file (.pdb). |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_PDB_FILE_DIR:tgt> |
| Added in version 3.1. |
| |
| .sp |
| Directory of the linker generated program database file (.pdb). |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_BUNDLE_DIR:tgt> |
| Added in version 3.9. |
| |
| .sp |
| Full path to the bundle directory (\fB/path/to/my.app\fP, |
| \fB/path/to/my.framework\fP, or \fB/path/to/my.bundle\fP), |
| where \fBtgt\fP is the name of a target. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_BUNDLE_DIR_NAME:tgt> |
| Added in version 3.24. |
| |
| .sp |
| Name of the bundle directory (\fBmy.app\fP, \fBmy.framework\fP, or |
| \fBmy.bundle\fP), where \fBtgt\fP is the name of a target. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_BUNDLE_CONTENT_DIR:tgt> |
| Added in version 3.9. |
| |
| .sp |
| Full path to the bundle content directory where \fBtgt\fP is the name of a |
| target. For the macOS SDK it leads to \fB/path/to/my.app/Contents\fP, |
| \fB/path/to/my.framework\fP, or \fB/path/to/my.bundle/Contents\fP\&. |
| For all other SDKs (e.g. iOS) it leads to \fB/path/to/my.app\fP, |
| \fB/path/to/my.framework\fP, or \fB/path/to/my.bundle\fP due to the flat |
| bundle structure. |
| .sp |
| Note that \fBtgt\fP is not added as a dependency of the target this |
| expression is evaluated on (see policy \X'tty: link #policy:CMP0112'\fI\%CMP0112\fP\X'tty: link'). |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_OBJECTS:tgt> |
| Added in version 3.1. |
| |
| .sp |
| List of objects resulting from building \fBtgt\fP\&. This would typically be |
| used on \X'tty: link #object-libraries'\fI\%object library\fP\X'tty: link' targets. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_RUNTIME_DLLS:tgt> |
| Added in version 3.21. |
| |
| .sp |
| List of DLLs that the target depends on at runtime. This is determined by |
| the locations of all the \fBSHARED\fP targets in the target\(aqs transitive |
| dependencies. If only the directories of the DLLs are needed, see the |
| \fI\%TARGET_RUNTIME_DLL_DIRS\fP generator expression. |
| Using this generator expression on targets other than |
| executables, \fBSHARED\fP libraries, and \fBMODULE\fP libraries is an error. |
| \fBOn non\-DLL platforms, this expression always evaluates to an empty string\fP\&. |
| .sp |
| This generator expression can be used to copy all of the DLLs that a target |
| depends on into its output directory in a \fBPOST_BUILD\fP custom command using |
| the \X'tty: link #cmdoption-cmake-E-arg-copy'\fI\%cmake \-E copy \-t\fP\X'tty: link' command. For example: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| find_package(foo CONFIG REQUIRED) # package generated by install(EXPORT) |
| |
| add_executable(exe main.c) |
| target_link_libraries(exe PRIVATE foo::foo foo::bar) |
| add_custom_command(TARGET exe POST_BUILD |
| COMMAND ${CMAKE_COMMAND} \-E copy \-t $<TARGET_FILE_DIR:exe> $<TARGET_RUNTIME_DLLS:exe> |
| COMMAND_EXPAND_LISTS |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| \fBNOTE:\fP |
| .INDENT 7.0 |
| .INDENT 3.5 |
| \X'tty: link #imported-targets'\fI\%Imported Targets\fP\X'tty: link' are supported only if they know the location |
| of their \fB\&.dll\fP files. An imported \fBSHARED\fP library must have |
| \X'tty: link #prop_tgt:IMPORTED_LOCATION'\fI\%IMPORTED_LOCATION\fP\X'tty: link' set to its \fB\&.dll\fP file. See the |
| \X'tty: link #add-library-imported-libraries'\fI\%add_library imported libraries\fP\X'tty: link' |
| section for details. Many \X'tty: link #find-modules'\fI\%Find Modules\fP\X'tty: link' produce imported targets |
| with the \fBUNKNOWN\fP type and therefore will be ignored. |
| .UNINDENT |
| .UNINDENT |
| .sp |
| On platforms that support runtime paths (\fBRPATH\fP), refer to the |
| \X'tty: link #prop_tgt:INSTALL_RPATH'\fI\%INSTALL_RPATH\fP\X'tty: link' target property. |
| On Apple platforms, refer to the \X'tty: link #prop_tgt:INSTALL_NAME_DIR'\fI\%INSTALL_NAME_DIR\fP\X'tty: link' target property. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_RUNTIME_DLL_DIRS:tgt> |
| Added in version 3.27. |
| |
| .sp |
| List of the directories which contain the DLLs that the target depends on at |
| runtime (see \fI\%TARGET_RUNTIME_DLLS\fP). This is determined by |
| the locations of all the \fBSHARED\fP targets in the target\(aqs transitive |
| dependencies. Using this generator expression on targets other than |
| executables, \fBSHARED\fP libraries, and \fBMODULE\fP libraries is an error. |
| \fBOn non\-DLL platforms, this expression always evaluates to an empty string\fP\&. |
| .sp |
| This generator expression can e.g. be used to create a batch file using |
| \X'tty: link #generate'\fI\%file(GENERATE)\fP\X'tty: link' which sets the PATH environment variable accordingly. |
| .UNINDENT |
| .SS Export And Install Expressions |
| .INDENT 0.0 |
| .TP |
| .B $<INSTALL_INTERFACE:...> |
| Content of \fB\&...\fP when the property is exported using |
| \X'tty: link #export'\fI\%install(EXPORT)\fP\X'tty: link', and empty otherwise. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<BUILD_INTERFACE:...> |
| Content of \fB\&...\fP when the property is exported using \X'tty: link #command:export'\fI\%export()\fP\X'tty: link', or |
| when the target is used by another target in the same buildsystem. Expands to |
| the empty string otherwise. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<BUILD_LOCAL_INTERFACE:...> |
| Added in version 3.26. |
| |
| .sp |
| Content of \fB\&...\fP when the target is used by another target in the same |
| buildsystem. Expands to the empty string otherwise. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<INSTALL_PREFIX> |
| Content of the install prefix when the target is exported via |
| \X'tty: link #export'\fI\%install(EXPORT)\fP\X'tty: link', or when evaluated in the |
| \X'tty: link #prop_tgt:INSTALL_NAME_DIR'\fI\%INSTALL_NAME_DIR\fP\X'tty: link' property or the \fBINSTALL_NAME_DIR\fP argument of |
| \X'tty: link #runtime-dependency-set'\fI\%install(RUNTIME_DEPENDENCY_SET)\fP\X'tty: link', and empty otherwise. |
| .sp |
| Changed in version 3.27: Evaluates to the content of the install prefix |
| in the code argument of \X'tty: link #code'\fI\%install(CODE)\fP\X'tty: link' or |
| the file argument of \X'tty: link #script'\fI\%install(SCRIPT)\fP\X'tty: link'\&. |
| |
| .UNINDENT |
| .SS Multi\-level Expression Evaluation |
| .INDENT 0.0 |
| .TP |
| .B $<GENEX_EVAL:expr> |
| Added in version 3.12. |
| |
| .sp |
| Content of \fBexpr\fP evaluated as a generator expression in the current |
| context. This enables consumption of generator expressions whose |
| evaluation results itself in generator expressions. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<TARGET_GENEX_EVAL:tgt,expr> |
| Added in version 3.12. |
| |
| .sp |
| Content of \fBexpr\fP evaluated as a generator expression in the context of |
| \fBtgt\fP target. This enables consumption of custom target properties that |
| themselves contain generator expressions. |
| .sp |
| Having the capability to evaluate generator expressions is very useful when |
| you want to manage custom properties supporting generator expressions. |
| For example: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_library(foo ...) |
| |
| set_property(TARGET foo PROPERTY |
| CUSTOM_KEYS $<$<CONFIG:DEBUG>:FOO_EXTRA_THINGS> |
| ) |
| |
| add_custom_target(printFooKeys |
| COMMAND ${CMAKE_COMMAND} \-E echo $<TARGET_PROPERTY:foo,CUSTOM_KEYS> |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .sp |
| This naive implementation of the \fBprintFooKeys\fP custom command is wrong |
| because \fBCUSTOM_KEYS\fP target property is not evaluated and the content |
| is passed as is (i.e. \fB$<$<CONFIG:DEBUG>:FOO_EXTRA_THINGS>\fP). |
| .sp |
| To have the expected result (i.e. \fBFOO_EXTRA_THINGS\fP if config is |
| \fBDebug\fP), it is required to evaluate the output of |
| \fB$<TARGET_PROPERTY:foo,CUSTOM_KEYS>\fP: |
| .INDENT 7.0 |
| .INDENT 3.5 |
| .sp |
| .nf |
| .ft C |
| add_custom_target(printFooKeys |
| COMMAND ${CMAKE_COMMAND} \-E |
| echo $<TARGET_GENEX_EVAL:foo,$<TARGET_PROPERTY:foo,CUSTOM_KEYS>> |
| ) |
| .ft P |
| .fi |
| .UNINDENT |
| .UNINDENT |
| .UNINDENT |
| .SS Escaped Characters |
| .sp |
| These expressions evaluate to specific string literals. Use them in place of |
| the actual string literal where you need to prevent them from having their |
| special meaning. |
| .INDENT 0.0 |
| .TP |
| .B $<ANGLE\-R> |
| A literal \fB>\fP\&. Used for example to compare strings that contain a \fB>\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<COMMA> |
| A literal \fB,\fP\&. Used for example to compare strings which contain a \fB,\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<SEMICOLON> |
| A literal \fB;\fP\&. Used to prevent list expansion on an argument with \fB;\fP\&. |
| .UNINDENT |
| .INDENT 0.0 |
| .TP |
| .B $<QUOTE> |
| Added in version 3.30. |
| |
| .sp |
| A literal \fB\(dq\fP\&. Used to allow string literal quotes inside a generator expression. |
| .UNINDENT |
| .SS Deprecated Expressions |
| .INDENT 0.0 |
| .TP |
| .B $<CONFIGURATION> |
| Configuration name. Deprecated since CMake 3.0. Use \fI\%CONFIG\fP instead. |
| .UNINDENT |
| .SH COPYRIGHT |
| 2000-2024 Kitware, Inc. and Contributors |
| .\" Generated by docutils manpage writer. |
| . |
| |