diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 448ba9d0e9..a6f46e2ea9 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -131,22 +131,22 @@ std::set cmDefinitions::ClosureKeys() const void cmDefinitions::ClosureKeys(std::set& defined, std::set& undefined) const { - // Consider local definitions. - for(MapType::const_iterator mi = this->Map.begin(); - mi != this->Map.end(); ++mi) - { - // Use this key if it is not already set or unset. - if(defined.find(mi->first) == defined.end() && - undefined.find(mi->first) == undefined.end()) - { - std::set& m = mi->second.Exists? defined : undefined; - m.insert(mi->first); - } - } + cmDefinitions const* up = this; - // Traverse parents. - if(cmDefinitions const* up = this->Up) + while (up) { - up->ClosureKeys(defined, undefined); + // Consider local definitions. + for(MapType::const_iterator mi = up->Map.begin(); + mi != up->Map.end(); ++mi) + { + // Use this key if it is not already set or unset. + if(defined.find(mi->first) == defined.end() && + undefined.find(mi->first) == undefined.end()) + { + std::set& m = mi->second.Exists? defined : undefined; + m.insert(mi->first); + } + } + up = up->Up; } }