CMP0131 — CMake 3.30.1 Documentation

# CMP0131

Added in version 3.24.

`LINK_LIBRARIES` supports the `$<LINK_ONLY:...>` generator expression.

CMake 3.23 and below documented the `$<LINK_ONLY:...>` generator expression only for use in `INTERFACE_LINK_LIBRARIES`. When used in `LINK_LIBRARIES`, the content guarded inside `$<LINK_ONLY:...>` was always used, even when collecting non-linking usage requirements such as `INTERFACE_COMPILE_DEFINITIONS`.

CMake 3.24 and above prefer to support `$<LINK_ONLY:...>`, when used in `LINK_LIBRARIES`, by using the guarded content only for link dependencies and not other usage requirements. This policy provides compatibility for projects that have not been updated to account for this change.

The `OLD` behavior for this policy is to use `LINK_LIBRARIES` content guarded by `$<LINK_ONLY:...>` even for non-linking usage requirements. The `NEW` behavior for this policy is to use the guarded content only for link dependencies.

This policy was introduced in CMake version 3.24. It may be set by `cmake_policy()` or `cmake_minimum_required()`. If it is not set, CMake does not warn, and uses `OLD` behavior.

Note

The `OLD` behavior of a policy is `deprecated by definition` and may be removed in a future version of CMake.