CMP0160 — CMake 4.2.6 Documentation

# CMP0160

Added in version 3.29.

More read-only target properties now error when trying to set them.

The `set_target_properties()` and `set_property()` commands are intended to error out on all read-only properties. However, CMake 3.28 and below only did this for the following properties:

- `HEADER_SETS`

- `INTERFACE_HEADER_SETS`

- `IMPORTED_GLOBAL`

- `MANUALLY_ADDED_DEPENDENCIES`

- `NAME`

- `TYPE`

This policy enforces the read-only nature of the following target properties:

- `ALIAS_GLOBAL`

- `BINARY_DIR`

- `CXX_MODULE_SETS`

- `IMPORTED`

- `INTERFACE_CXX_MODULE_SETS`

- `LOCATION`

- `LOCATION_<CONFIG>`

- `SOURCE_DIR`

The `OLD` behavior for this policy is to only error out for the properties `MANUALLY_ADDED_DEPENDENCIES`, `NAME`, and `TYPE`. The `NEW` behavior for this policy is to error out on all target properties that are documented as read-only.

This policy was introduced in CMake version 3.29. It may be set by `cmake_policy()` or `cmake_minimum_required()`. If it is not set, CMake warns, 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.