.\" Man page generated from reStructuredText. . .TH "CMAKE-GENERATOR-EXPRESSIONS" "7" "June 08, 2016" "3.0.2" "CMake" .SH NAME cmake-generator-expressions \- CMake Generator Expressions . .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 .. .SH INTRODUCTION .sp Generator expressions are evaluated during build system generation to produce information specific to each build configuration. .sp Generator expressions are allowed in the context of many target properties, such as \fBLINK_LIBRARIES\fP, \fBINCLUDE_DIRECTORIES\fP, \fBCOMPILE_DEFINITIONS\fP and others. They may also be used when using commands to populate those properties, such as \fBtarget_link_libraries()\fP, \fBtarget_include_directories()\fP, \fBtarget_compile_definitions()\fP and others. .sp This means that they enable conditional linking, conditional definitions used when compiling, and conditional include directories and more. The conditions may be based on the build configuration, target properties, platform information or any other queryable information. .SH LOGICAL EXPRESSIONS .sp Logical expressions are used to create conditional output. The basic expressions are the \fB0\fP and \fB1\fP expressions. Because other logical expressions evaluate to either \fB0\fP or \fB1\fP, they can be composed to create conditional output: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $<$:DEBUG_MODE> .ft P .fi .UNINDENT .UNINDENT .sp expands to \fBDEBUG_MODE\fP when the \fBDebug\fP configuration is used, and otherwise expands to nothing. .INDENT 0.0 .TP .B \fB$<0:...>\fP Empty string (ignores \fB\&...\fP) .TP .B \fB$<1:...>\fP Content of \fB\&...\fP .TP .B \fB$\fP \fB1\fP if the \fB\&...\fP is true, else \fB0\fP .TP .B \fB$\fP \fB1\fP if all \fB?\fP are \fB1\fP, else \fB0\fP .sp The \fB?\fP must always be either \fB0\fP or \fB1\fP in boolean expressions. .TP .B \fB$\fP \fB0\fP if all \fB?\fP are \fB0\fP, else \fB1\fP .TP .B \fB$\fP \fB0\fP if \fB?\fP is \fB1\fP, else \fB1\fP .TP .B \fB$\fP \fB1\fP if \fBa\fP is STREQUAL \fBb\fP, else \fB0\fP .TP .B \fB$\fP \fB1\fP if \fBa\fP is EQUAL \fBb\fP in a numeric comparison, else \fB0\fP .TP .B \fB$\fP \fB1\fP if config is \fBcfg\fP, else \fB0\fP\&. This is a case\-insensitive comparison. The mapping in \fBMAP_IMPORTED_CONFIG_\fP is also considered by this expression when it is evaluated on a property on an \fBIMPORTED\fP target. .TP .B \fB$\fP \fB1\fP if the CMake\-id of the platform matches \fBcomp\fP, otherwise \fB0\fP\&. .TP .B \fB$\fP \fB1\fP if the CMake\-id of the C compiler matches \fBcomp\fP, otherwise \fB0\fP\&. .TP .B \fB$\fP \fB1\fP if the CMake\-id of the CXX compiler matches \fBcomp\fP, otherwise \fB0\fP\&. .TP .B \fB$\fP \fB1\fP if \fBv1\fP is a version greater than \fBv2\fP, else \fB0\fP\&. .TP .B \fB$\fP \fB1\fP if \fBv1\fP is a version less than \fBv2\fP, else \fB0\fP\&. .TP .B \fB$\fP \fB1\fP if \fBv1\fP is the same version as \fBv2\fP, else \fB0\fP\&. .TP .B \fB$\fP \fB1\fP if the version of the C compiler matches \fBver\fP, otherwise \fB0\fP\&. .TP .B \fB$\fP \fB1\fP if the version of the CXX compiler matches \fBver\fP, otherwise \fB0\fP\&. .TP .B \fB$\fP \fB1\fP if the policy \fBpol\fP was NEW when the \(aqhead\(aq target was created, else \fB0\fP\&. If the policy was not set, the warning message for the policy will be emitted. This generator expression only works for a subset of policies. .UNINDENT .SH INFORMATIONAL EXPRESSIONS .sp These expressions expand to some information. The information may be used directly, eg: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include_directories(/usr/include/$/) .ft P .fi .UNINDENT .UNINDENT .sp expands to \fB/usr/include/GNU/\fP or \fB/usr/include/Clang/\fP etc, depending on the Id of the compiler. .sp These expressions may also may be combined with logical expressions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $<$,4.2.0>:OLD_COMPILER> .ft P .fi .UNINDENT .UNINDENT .sp expands to \fBOLD_COMPILER\fP if the \fBCMAKE_CXX_COMPILER_VERSION\fP is less than 4.2.0. .INDENT 0.0 .TP .B \fB$\fP Configuration name. Deprecated. Use \fBCONFIG\fP instead. .TP .B \fB$\fP Configuration name .TP .B \fB$\fP The CMake\-id of the platform .TP .B \fB$\fP The CMake\-id of the C compiler used. .TP .B \fB$\fP The CMake\-id of the CXX compiler used. .TP .B \fB$\fP The version of the C compiler used. .TP .B \fB$\fP The version of the CXX compiler used. .TP .B \fB$\fP Full path to main file (.exe, .so.1.2, .a) where \fBtgt\fP is the name of a target. .TP .B \fB$\fP Name of main file (.exe, .so.1.2, .a). .TP .B \fB$\fP Directory of main file (.exe, .so.1.2, .a). .TP .B \fB$\fP File used to link (.a, .lib, .so) where \fBtgt\fP is the name of a target. .TP .B \fB$\fP Name of file used to link (.a, .lib, .so). .TP .B \fB$\fP Directory of file used to link (.a, .lib, .so). .TP .B \fB$\fP File with soname (.so.3) where \fBtgt\fP is the name of a target. .TP .B \fB$\fP Name of file with soname (.so.3). .TP .B \fB$\fP Directory of with soname (.so.3). .TP .B \fB$\fP Value of the property \fBprop\fP on the target \fBtgt\fP\&. .sp Note that \fBtgt\fP is not added as a dependency of the target this expression is evaluated on. .TP .B \fB$\fP Value of the property \fBprop\fP on the target on which the generator expression is evaluated. .TP .B \fB$\fP Content of the install prefix when the target is exported via \fBinstall(EXPORT)\fP and empty otherwise. .UNINDENT .SH OUTPUT EXPRESSIONS .sp These expressions generate output, in some cases depending on an input. These expressions may be combined with other expressions for information or logical comparison: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-I$, \-I> .ft P .fi .UNINDENT .UNINDENT .sp generates a string of the entries in the \fBINCLUDE_DIRECTORIES\fP target property with each entry preceeded by \fB\-I\fP\&. Note that a more\-complete use in this situation would require first checking if the INCLUDE_DIRECTORIES property is non\-empty: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $<$>:\-I$, \-I>> .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .TP .B \fB$\fP Joins the list with the content of \fB\&...\fP .TP .B \fB$\fP A literal \fB>\fP\&. Used to compare strings which contain a \fB>\fP for example. .TP .B \fB$\fP A literal \fB,\fP\&. Used to compare strings which contain a \fB,\fP for example. .TP .B \fB$\fP A literal \fB;\fP\&. Used to prevent list expansion on an argument with \fB;\fP\&. .TP .B \fB$\fP Marks \fB\&...\fP as being the name of a target. This is required if exporting targets to multiple dependent export sets. The \fB\&...\fP must be a literal name of a target\- it may not contain generator expressions. .TP .B \fB$\fP Content of \fB\&...\fP when the property is exported using \fBinstall(EXPORT)\fP, and empty otherwise. .TP .B \fB$\fP Content of \fB\&...\fP when the property is exported using \fBexport()\fP, or when the target is used by another target in the same buildsystem. Expands to the empty string otherwise. .TP .B \fB$\fP Content of \fB\&...\fP converted to lower case. .TP .B \fB$\fP Content of \fB\&...\fP converted to upper case. .TP .B \fB$\fP Content of \fB\&...\fP converted to a C identifier. .UNINDENT .SH COPYRIGHT 2000-2014 Kitware, Inc. .\" Generated by docutils manpage writer. .