summaryrefslogtreecommitdiffstats
path: root/Source/cmPolicies.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-09-10 20:59:45 (GMT)
committerBrad King <brad.king@kitware.com>2009-09-10 20:59:45 (GMT)
commitee2b446c953f278eefff44f964f6e39cdc0fff78 (patch)
tree0f4213c3893cd8f6e30c6c878230b4c8680e33c5 /Source/cmPolicies.cxx
parentafbe0883094afddb7cbaedcb8d89031ef503ed3b (diff)
downloadCMake-ee2b446c953f278eefff44f964f6e39cdc0fff78.zip
CMake-ee2b446c953f278eefff44f964f6e39cdc0fff78.tar.gz
CMake-ee2b446c953f278eefff44f964f6e39cdc0fff78.tar.bz2
Create CMake Policy CMP0015 to fix set(CACHE)
The set(CACHE) and option() commands should always expose the cache value. Previously we failed to expose the value when it was already set if a local variable definition hid it. When set to NEW, this policy tells the commands to always remove the local variable definition to expose the cache value. See issue #9008.
Diffstat (limited to 'Source/cmPolicies.cxx')
-rw-r--r--Source/cmPolicies.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 576ccd7..95bf972 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -399,6 +399,37 @@ cmPolicies::cmPolicies()
"The OLD behavior for this policy is to silently ignore the problem. "
"The NEW behavior for this policy is to report an error.",
2,7,20090902, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0015, "CMP0015",
+ "The set() CACHE mode and option() command make the cache value visible.",
+ "In CMake 2.6 and below the CACHE mode of the set() command and the "
+ "option() command did not expose the value from the named cache entry "
+ "if it was already set both in the cache and as a local variable. "
+ "This led to subtle differences between first and later configurations "
+ "because a conflicting local variable would be overridden only when the "
+ "cache value was first created. "
+ "For example, the code\n"
+ " set(x 1)\n"
+ " set(before ${x})\n"
+ " set(x 2 CACHE STRING \"X\")\n"
+ " set(after ${x})\n"
+ " message(STATUS \"${before},${after}\")\n"
+ "would print \"1,2\" on the first run and \"1,1\" on future runs."
+ "\n"
+ "CMake 2.8.0 and above prefer to expose the cache value in all cases by "
+ "removing the local variable definition, but this changes behavior in "
+ "subtle cases when the local variable has a different value than that "
+ "exposed from the cache. "
+ "The example above will always print \"1,2\"."
+ "\n"
+ "This policy determines whether the commands should always expose the "
+ "cache value. "
+ "The OLD behavior for this policy is to leave conflicting local "
+ "variable values untouched and hide the true cache value. "
+ "The NEW behavior for this policy is to always expose the cache value.",
+ 2,7,20090910, cmPolicies::WARN);
+
}
cmPolicies::~cmPolicies()