Merge topic 'project-vars-policy'

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

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9879
This commit is contained in:
Brad King
2024-10-09 13:20:40 +00:00
committed by Kitware Robot
16 changed files with 119 additions and 34 deletions
+4 -1
View File
@@ -549,7 +549,10 @@ class cmMakefile;
SELECT(POLICY, CMP0179, \
"De-duplication of static libraries on link lines keeps first " \
"occurrence.", \
3, 31, 0, cmPolicies::WARN)
3, 31, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0180, \
"project() always sets <PROJECT-NAME>_* as normal variables.", 3, \
31, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
+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");
}