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.
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 that it is not advisable to populate the
INTERFACE_LINK_LIBRARIES
of a target with paths for dependencies.
That would hard-code into installed packages the include directory paths
for dependencies as found on the machine the package was made on.
That is, code like this is incorrect for targets which will be used to
generate cmake-packages(7)
:
target_link_libraries(mylib INTERFACE
${Boost_LIBRARIES};${OtherDep_LIBRARIES}
)
Dependencies must provide their own IMPORTED targets
which have their own IMPORTED_LOCATION
populated
appropriately. That way, when a consumer uses the installed package, the
consumer will run the appropriate find_package()
command to find
the dependencies on their own machine and populate the
IMPORTED targets with appropriate paths. See
Creating Packages for more. Note that many modules currently shipped
with CMake do not currently provide IMPORTED targets.