mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
enable_language: Include unset variables in what to propagate.
Fixes: #28200
This commit is contained in:
4 files changed
+14
-5
No files matched your search
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user