CMP0126ΒΆ
New in version 3.21.
When this policy is set to NEW
, the set(CACHE)
command does not
remove any normal variable of the same name from the current scope.
The OLD
behavior removes any normal variable of the same name from the
current scope in the following situations:
No cache variable of that name existed previously.
A cache variable of that name existed previously, but it had no type. This can occur when the variable was set on the command line using a form like
cmake -DMYVAR=blah
instead ofcmake -DMYVAR:STRING=blah
.The
FORCE
orINTERNAL
keywords were used when setting the cache variable.
Note that the NEW
behavior has an important difference to the similar
NEW
behavior of policy CMP0077
. The set(CACHE)
command always sets the cache variable if it did not exist previously,
regardless of the CMP0126
policy setting. The option()
command
will not set the cache variable if a non-cache variable of the same name
already exists and CMP0077
is set to NEW
.
This policy was introduced in CMake version 3.21.
It may be set by cmake_policy()
or cmake_minimum_required()
.
If it is not set, CMake does not warn by default, and uses OLD
behavior.
See documentation of the
CMAKE_POLICY_WARNING_CMP0126
variable to control the warning.
The CMAKE_POLICY_DEFAULT_CMP0126
variable may be used to set the policy for a third-party project in a
subdirectory without modifying it.
Note
The OLD
behavior of a policy is
deprecated by definition
and may be removed in a future version of CMake.