# CMP0164

Added in version 3.30.

`add_library()` rejects `SHARED` libraries when not supported by the platform.

In CMake 3.29 and below, on platforms that do not support shared libraries (`TARGET_SUPPORTS_SHARED_LIBS` is false), the `add_library()` command automatically converts `SHARED` libraries to `STATIC` libraries to help users build projects on such platforms. However, the semantics of shared and static libraries are different enough that such automatic conversion cannot work in general. Projects using shared libraries need to be ported to such platforms on a case-by-case basis.

In CMake 3.30 and above, `add_library()` prefers to reject creation of shared libraries on platforms that do not support them, and fail with a fatal error message. This policy provides compatibility for projects that happened to work with the automatic conversion to static libraries and have not been updated with an explicit port.

The `OLD` behavior for this policy is to implicitly create a static library with a developer warning. The `NEW` behavior for this policy is to fail.

This policy was introduced in CMake version 3.30. It may be set by `cmake_policy()` or `cmake_minimum_required()`. If it is not set, CMake does not warn about the behavior change, 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.