1CMP0128
2-------
3
4.. versionadded:: 3.22
5
6When this policy is set to ``NEW``:
7
8* :prop_tgt:`<LANG>_EXTENSIONS` is initialized to
9  :variable:`CMAKE_<LANG>_EXTENSIONS` if set, otherwise falling back to
10  :variable:`CMAKE_<LANG>_EXTENSIONS_DEFAULT`.
11
12* Extensions are correctly enabled/disabled if :prop_tgt:`<LANG>_STANDARD` is
13  unset or satisfied by the default.
14
15* Standard mode-affecting flags aren't added unless necessary to achieve the
16  specified mode.
17
18The ``OLD`` behavior:
19
20* Initializes :prop_tgt:`<LANG>_EXTENSIONS` to
21  :variable:`CMAKE_<LANG>_EXTENSIONS` if set, otherwise falling back to ``ON``.
22
23* Always adds a flag if :prop_tgt:`<LANG>_STANDARD` is set and
24  :prop_tgt:`<LANG>_STANDARD_REQUIRED` is ``OFF``.
25
26* If :prop_tgt:`<LANG>_STANDARD` is unset:
27
28  * Doesn't disable extensions even if :prop_tgt:`<LANG>_EXTENSIONS` is
29    ``OFF``.
30
31  * Fails to enable extensions if :prop_tgt:`<LANG>_EXTENSIONS` is ``ON``
32    except for the ``IAR`` compiler.
33
34Code may need to be updated for the ``NEW`` behavior in the following cases:
35
36* If a standard mode flag previously overridden by CMake's and not used during
37  compiler detection now takes effect due to CMake no longer adding one as the
38  default detected is appropriate.
39
40  Such code should be converted to either:
41
42  * Use :prop_tgt:`<LANG>_STANDARD` and :prop_tgt:`<LANG>_EXTENSIONS` instead
43    of manually adding flags.
44
45  * Or ensure the manually-specified flags are used during compiler detection.
46
47* If extensions were disabled without :prop_tgt:`<LANG>_STANDARD` being set
48  CMake previously wouldn't actually disable extensions.
49
50  Such code should be updated to not disable extensions if they are required.
51
52* If extensions were enabled/disabled when :prop_tgt:`<LANG>_STANDARD` was
53  satisfied by the compiler's default CMake previously wouldn't actually
54  enable/disable extensions.
55
56  Such code should be updated to set the correct extensions mode.
57
58If compiler flags affecting the standard mode are used during compiler
59detection (for example in :manual:`a toolchain file <cmake-toolchains(7)>`
60using :variable:`CMAKE_<LANG>_FLAGS_INIT`) then they will affect the detected
61default :variable:`standard <CMAKE_<LANG>_STANDARD_DEFAULT>` and
62:variable:`extensions <CMAKE_<LANG>_EXTENSIONS_DEFAULT>`.
63
64Unlike many policies, CMake version |release| does *not* warn when the policy
65is not set and simply uses the ``OLD`` behavior. Use the
66:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
67See documentation of the
68:variable:`CMAKE_POLICY_WARNING_CMP0128 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
69variable to control the warning.
70
71.. include:: DEPRECATED.txt
72