CMP0180ΒΆ
Added in version 3.31.
project()
always sets <PROJECT-NAME>_*
as normal variables.
In CMake 3.29 and below, the project()
command set
<PROJECT-NAME>_SOURCE_DIR
, <PROJECT-NAME>_BINARY_DIR
,
and <PROJECT-NAME>_IS_TOP_LEVEL
as cache entries, but not as
normal variables. CMake 3.30 started setting them as normal variables,
but only if they are already set as normal variables. This was needed to
preserve support for some FetchContent
use cases under policy
CMP0169
's NEW behavior, while also preserving behavior of nested
directories that call project()
with the same project name.
See release notes for 3.30.3, 3.30.4, and 3.30.5 for details.
CMake 3.31 and later prefer to always set <PROJECT-NAME>_SOURCE_DIR
,
<PROJECT-NAME>_BINARY_DIR
, and <PROJECT-NAME>_IS_TOP_LEVEL
, as both
cache entries and normal variables, regardless of what cache or normal
variables already exist. This policy provides compatibility for projects
that have not been updated to expect this behavior.
The OLD
behavior for this policy will only set normal variables for
<PROJECT-NAME>_SOURCE_DIR
, <PROJECT-NAME>_BINARY_DIR
, and
<PROJECT-NAME>_IS_TOP_LEVEL
if there is already a normal variable by that
name when project()
is called.
The NEW
behavior for this policy will always set normal variables for
<PROJECT-NAME>_SOURCE_DIR
, <PROJECT-NAME>_BINARY_DIR
, and
<PROJECT-NAME>_IS_TOP_LEVEL
when project()
is called.
This policy was introduced in CMake version 3.31.
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.