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
+5 -3
View File
@@ -58,11 +58,13 @@ bool cmProjectCommand(std::vector<std::string> const& args,
mf.SetProjectName(projectName);
cmPolicies::PolicyStatus cmp0180 = mf.GetPolicyStatus(cmPolicies::CMP0180);
std::string varName = cmStrCat(projectName, "_BINARY_DIR"_s);
bool nonCacheVarAlreadySet = mf.IsNormalDefinitionSet(varName);
mf.AddCacheDefinition(varName, mf.GetCurrentBinaryDirectory(),
"Value Computed by CMake", cmStateEnums::STATIC);
if (nonCacheVarAlreadySet) {
if (cmp0180 == cmPolicies::NEW || nonCacheVarAlreadySet) {
mf.AddDefinition(varName, mf.GetCurrentBinaryDirectory());
}
@@ -70,7 +72,7 @@ bool cmProjectCommand(std::vector<std::string> const& args,
nonCacheVarAlreadySet = mf.IsNormalDefinitionSet(varName);
mf.AddCacheDefinition(varName, mf.GetCurrentSourceDirectory(),
"Value Computed by CMake", cmStateEnums::STATIC);
if (nonCacheVarAlreadySet) {
if (cmp0180 == cmPolicies::NEW || nonCacheVarAlreadySet) {
mf.AddDefinition(varName, mf.GetCurrentSourceDirectory());
}
@@ -85,7 +87,7 @@ bool cmProjectCommand(std::vector<std::string> const& args,
nonCacheVarAlreadySet = mf.IsNormalDefinitionSet(varName);
mf.AddCacheDefinition(varName, mf.IsRootMakefile() ? "ON" : "OFF",
"Value Computed by CMake", cmStateEnums::STATIC);
if (nonCacheVarAlreadySet) {
if (cmp0180 == cmPolicies::NEW || nonCacheVarAlreadySet) {
mf.AddDefinition(varName, mf.IsRootMakefile() ? "ON" : "OFF");
}