From d96eb5528276a19d79116d842389f3ea165ef21b Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Thu, 20 May 2021 15:14:30 +0200 Subject: set(CACHE): do not remove normal variable Fixes: #22038 --- Source/cmMakefile.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/cmMakefile.cxx') diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4ffd47bec6..d7987c2662 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1962,10 +1962,10 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, } } this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type); - // if there was a definition then remove it - // The method cmFindBase::NormalizeFindResult also apply same workflow. - // See #22038 for problems raised by this behavior. - this->StateSnapshot.RemoveDefinition(name); + if (this->GetPolicyStatus(cmPolicies::CMP0126) != cmPolicies::NEW) { + // if there was a definition then remove it + this->StateSnapshot.RemoveDefinition(name); + } } void cmMakefile::MarkVariableAsUsed(const std::string& var) -- cgit v1.2.1