CMP0165 — CMake 4.0.2-dirty Documentation

# CMP0165

Added in version 3.30.

`enable_language()` must not be called before `project()`.

In CMake 3.29 and below, if a project called `enable_language()` before the first call to `project()`, the language would be enabled but possibly using unset details that were expected to be set. In CMake 3.30 and above, `enable_language()` prefers to reject this case and stop with a fatal error instead if it detects that `project()` has not yet been called. This policy provides compatibility for projects that happened to work when `enable_language()` was called before `project()` and have not been updated to call these commands in the required order.

The `OLD` behavior for this policy is to allow `enable_language()` to be called before `project()`. The `NEW` behavior for this policy is to fail with a fatal error in such cases.

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 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.