enable_language: Include unset variables in what to propagate.

Fixes: #28200
This commit is contained in:
Robert Maynard committed 2026-10-23 13:45:22 -04:00
1 parent a8d1b1c06b
commit c32f37df2c
4 files changed
+14 -5

No files matched your search

+4 -2
View File
@@ -79,7 +79,8 @@ cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end)
}
std::vector<std::string> cmDefinitions::ClosureKeys(StackIter begin,
StackIter end)
StackIter end,
UnsetKeys unsetKeys)
{
std::vector<std::string> defined;
std::unordered_set<cm::string_view> bound;
@@ -88,7 +89,8 @@ std::vector<std::string> cmDefinitions::ClosureKeys(StackIter begin,
defined.reserve(defined.size() + it->Map.size());
for (auto const& mi : it->Map) {
// Use this key if it is not already set or unset.
if (bound.emplace(mi.first.view()).second && mi.second.Value) {
if (bound.emplace(mi.first.view()).second &&
(unsetKeys == UnsetKeys::Include || mi.second.Value)) {
defined.push_back(*mi.first.str_if_stable());
}
}
+8 -1
View File
@@ -34,7 +34,14 @@ public:
static bool HasKey(std::string const& key, StackIter begin, StackIter end);
static std::vector<std::string> ClosureKeys(StackIter begin, StackIter end);
enum class UnsetKeys
{
Exclude,
Include,
};
static std::vector<std::string> ClosureKeys(
StackIter begin, StackIter end, UnsetKeys unsetKeys = UnsetKeys::Exclude);
static cmDefinitions MakeClosure(StackIter begin, StackIter end);
-1
View File
@@ -1159,7 +1159,6 @@ void cmGlobalGenerator::EnableLanguage(
cmStateSnapshot snapshot = mf->GetStateSnapshot();
bool warnCMP0220 = false;
for (std::string const& key : snapshot.LocalKeys()) {
// Should never need to propagate unsets
if (!key.empty()) {
if (mf->RaiseToRoot(key, snapshot.GetDefinition(key).GetCStr()) ==
cmStateSnapshot::WarnCMP0220::Yes) {
+2 -1
View File
@@ -417,7 +417,8 @@ std::vector<std::string> cmStateSnapshot::ClosureKeys() const
std::vector<std::string> cmStateSnapshot::LocalKeys() const
{
std::vector<std::string> keys = cmDefinitions::ClosureKeys(
this->Position->Vars, this->Position->ScopeParent->Vars);
this->Position->Vars, this->Position->ScopeParent->Vars,
cmDefinitions::UnsetKeys::Include);
// Remove keys that are the same in the parent scope to avoid propagating
// logic meant to restore variables back to their original value.