project: Always set <PROJECT-NAME>_* as normal variables

Re-introduce the behavior originally introduced in CMake 3.30.3 by
commit c1ece78d11 (project: non cache <project> prefix variables are
also created, 2024-08-27, v3.30.3~2^2), but this time with a policy for
compatibility.

Issue: #25714
Issue: #26243
This commit is contained in:
Craig Scott
2024-10-06 19:59:20 +11:00
committed by Brad King
parent ddf1d2944f
commit e5a9ccbcc8
16 changed files with 119 additions and 34 deletions
+10 -19
View File
@@ -44,27 +44,18 @@ Projects should not rely on ``<PROJECT-NAME>_SOURCE_DIR`` or
``<PROJECT-NAME>_BINARY_DIR`` holding a particular value outside of the scope
of the call to ``project()`` or one of its child scopes.
.. versionchanged:: 3.30.3
.. versionchanged:: 3.30
``<PROJECT-NAME>_SOURCE_DIR``, ``<PROJECT-NAME>_BINARY_DIR``, and
``<PROJECT-NAME>_IS_TOP_LEVEL`` are always set as non-cache variables by
``project(<PROJECT-NAME> ...)``.
``<PROJECT-NAME>_IS_TOP_LEVEL``, if already set as normal variables when
``project(<PROJECT-NAME> ...)`` is called, are updated by the call.
Cache entries by the same names are always set as before.
See release notes for 3.30.3, 3.30.4, and 3.30.5 for details.
.. versionchanged:: 3.30.4
The variables ``<PROJECT-NAME>_SOURCE_DIR``, ``<PROJECT-NAME>_BINARY_DIR``,
and ``<PROJECT-NAME>_IS_TOP_LEVEL`` are only set as non-cache variables if
they are already set as cache or non-cache variables when
``project(<PROJECT-NAME> ...)`` is called.
Note that this logic is flawed, as it can result in different behavior
between the first and subsequent runs because cache variables won't exist
on the first run, but they will on subsequent runs.
.. versionchanged:: 3.30.5
The variables ``<PROJECT-NAME>_SOURCE_DIR``, ``<PROJECT-NAME>_BINARY_DIR``,
and ``<PROJECT-NAME>_IS_TOP_LEVEL`` are only set as non-cache variables if
they are already set as non-cache variables when
``project(<PROJECT-NAME> ...)`` is called.
Unlike the flawed behavior of 3.30.4, non-cache variables will not be set
if only cache variables of the same name are set.
.. versionchanged:: 3.31
``<PROJECT-NAME>_SOURCE_DIR``, ``<PROJECT-NAME>_BINARY_DIR``, and
``<PROJECT-NAME>_IS_TOP_LEVEL`` are always set as normal variables by
``project(<PROJECT-NAME> ...)``. See policy :policy:`CMP0180`.
Cache entries by the same names are always set as before.
Options
^^^^^^^