INTERFACE_LINK_LIBRARIES¶
List public interface libraries for a library.
This property contains the list of transitive link dependencies. When
the target is linked into another target using the
target_link_libraries()
command, the libraries listed (and
recursively their link interface libraries) will be provided to the
other target also. This property is overridden by the
LINK_INTERFACE_LIBRARIES
or
LINK_INTERFACE_LIBRARIES_<CONFIG>
property if policy
CMP0022
is OLD
or unset.
The value of this property is used by the generators when constructing
the link rule for a dependent target. A dependent target's direct
link dependencies, specified by its LINK_LIBRARIES
target
property, are linked first, followed by indirect dependencies from the
transitive closure of the direct dependencies'
INTERFACE_LINK_LIBRARIES
properties. See policy CMP0022
.
Contents of INTERFACE_LINK_LIBRARIES
may use "generator expressions"
with the syntax $<...>
. See the cmake-generator-expressions(7)
manual for available expressions. See the cmake-buildsystem(7)
manual for more on defining buildsystem properties.
Note
A call to target_link_libraries(<target> ...)
may update this
property on <target>
. If <target>
was not created in the same
directory as the call then target_link_libraries()
will wrap each
entry with the form ::@(directory-id);...;::@
, where the ::@
is
literal and the (directory-id)
is unspecified.
This tells the generators that the named libraries must be looked up in
the scope of the caller rather than in the scope in which the
<target>
was created. Valid directory ids are stripped on export
by the install(EXPORT)
and export()
commands.
INTERFACE_LINK_LIBRARIES
adds transitive link dependencies for a
target's dependents. In advanced use cases, one may update the
direct link dependencies of a target's dependents by using the
INTERFACE_LINK_LIBRARIES_DIRECT
and
INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE
target properties.
Handling Compiler Driver Differences¶
Added in version 3.32.
To pass options to the linker tool, each compiler driver has its own syntax.
The LINKER:
prefix and ,
separator can be used to specify, in a portable
way, options to pass to the linker tool. LINKER:
is replaced by the
appropriate driver option and ,
by the appropriate driver separator.
The driver prefix and driver separator are given by the values of the
CMAKE_<LANG>_LINKER_WRAPPER_FLAG
and
CMAKE_<LANG>_LINKER_WRAPPER_FLAG_SEP
variables.
For example, "LINKER:-z,defs"
becomes -Xlinker -z -Xlinker defs
for
Clang
and -Wl,-z,defs
for GNU GCC
.
The LINKER:
prefix supports, as an alternative syntax, specification of
arguments using the SHELL:
prefix and space as separator. The previous
example then becomes "LINKER:SHELL:-z defs"
.
Note
Specifying the SHELL:
prefix anywhere other than at the beginning of the
LINKER:
prefix is not supported.
Creating Relocatable Packages¶
Note that it is not advisable to populate the
INTERFACE_LINK_LIBRARIES
of a target with absolute paths to dependencies.
That would hard-code into installed packages the library file paths
for dependencies as found on the machine the package was made on.
See the Creating Relocatable Packages section of the
cmake-packages(7)
manual for discussion of additional care
that must be taken when specifying usage requirements while creating
packages for redistribution.