mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 14:19:59 -05:00
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:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user