File: CMP0126.rst

package info (click to toggle)
cmake 4.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 152,344 kB
  • sloc: ansic: 403,894; cpp: 303,807; sh: 4,097; python: 3,582; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 108; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (39 lines) | stat: -rw-r--r-- 1,606 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
CMP0126
-------

.. versionadded:: 3.21

When this policy is set to ``NEW``, the :command:`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 of ``cmake -DMYVAR:STRING=blah``.

* The ``FORCE`` or ``INTERNAL`` keywords were used when setting the cache
  variable.

Note that the ``NEW`` behavior has an important difference to the similar
``NEW`` behavior of policy :policy:`CMP0077`.  The :command:`set(CACHE)`
command always sets the cache variable if it did not exist previously,
regardless of the ``CMP0126`` policy setting.  The :command:`option` command
will *not* set the cache variable if a non-cache variable of the same name
already exists and :policy:`CMP0077` is set to ``NEW``.

.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.21
.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn by default
.. include:: include/STANDARD_ADVICE.rst

See documentation of the
:variable:`CMAKE_POLICY_WARNING_CMP0126 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
variable to control the warning.

The :variable:`CMAKE_POLICY_DEFAULT_CMP0126 <CMAKE_POLICY_DEFAULT_CMP\<NNNN\>>`
variable may be used to set the policy for a third-party project in a
subdirectory without modifying it.

.. include:: include/DEPRECATED.rst