On this page
CMP0128
New in version 3.22.
When this policy is set to NEW:
<LANG>_EXTENSIONSis initialized toCMAKE_<LANG>_EXTENSIONSif set, otherwise falling back toCMAKE_<LANG>_EXTENSIONS_DEFAULT.- Extensions are correctly enabled/disabled if
<LANG>_STANDARDis unset or satisfied by the default. - Standard mode-affecting flags aren't added unless necessary to achieve the specified mode.
The OLD behavior:
- Initializes
<LANG>_EXTENSIONStoCMAKE_<LANG>_EXTENSIONSif set, otherwise falling back toON. - Always adds a flag if
<LANG>_STANDARDis set and<LANG>_STANDARD_REQUIREDisOFF. If
<LANG>_STANDARDis unset:- Doesn't disable extensions even if
<LANG>_EXTENSIONSisOFF. - Fails to enable extensions if
<LANG>_EXTENSIONSisONexcept for theIARcompiler.
- Doesn't disable extensions even if
Code may need to be updated for the NEW behavior in the following cases:
If a standard mode flag previously overridden by CMake's and not used during compiler detection now takes effect due to CMake no longer adding one as the default detected is appropriate.
Such code should be converted to either:
- Use
<LANG>_STANDARDand<LANG>_EXTENSIONSinstead of manually adding flags. - Or ensure the manually-specified flags are used during compiler detection.
- Use
If extensions were disabled without
<LANG>_STANDARDbeing set CMake previously wouldn't actually disable extensions.Such code should be updated to not disable extensions if they are required.
If extensions were enabled/disabled when
<LANG>_STANDARDwas satisfied by the compiler's default CMake previously wouldn't actually enable/disable extensions.Such code should be updated to set the correct extensions mode.
If compiler flags affecting the standard mode are used during compiler detection (for example in a toolchain file using CMAKE_<LANG>_FLAGS_INIT) then they will affect the detected default standard and extensions.
Unlike many policies, CMake version 3.23.3 does not warn when the policy is not set and simply uses the OLD behavior. Use the cmake_policy() command to set it to OLD or NEW explicitly. See documentation of the CMAKE_POLICY_WARNING_CMP0128 variable to control the warning.
Note
The OLD behavior of a policy is deprecated by definition and may be removed in a future version of CMake.
© 2000–2022 Kitware, Inc. and Contributors
Licensed under the BSD 3-clause License.
https://cmake.org/cmake/help/v3.23/policy/CMP0128.html