summaryrefslogtreecommitdiff
path: root/Source/cmOptionCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmOptionCommand.cxx')
-rw-r--r--Source/cmOptionCommand.cxx7
1 files changed, 7 insertions, 0 deletions
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index a58e2f8cc..bae67e04d 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -68,6 +68,13 @@ bool cmOptionCommand(std::vector<std::string> const& args,
bool init = cmIsOn(initialValue);
status.GetMakefile().AddCacheDefinition(args[0], init ? "ON" : "OFF",
args[1].c_str(), cmStateEnums::BOOL);
+ if (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0077) !=
+ cmPolicies::NEW &&
+ status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0126) ==
+ cmPolicies::NEW) {
+ // if there was a definition then remove it
+ status.GetMakefile().GetStateSnapshot().RemoveDefinition(args[0]);
+ }
if (checkAndWarn) {
const auto* existsAfterSet =