summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2021-11-09 18:34:06 (GMT)
committerRaul Tambre <raul@tambre.ee>2021-11-11 19:55:04 (GMT)
commite47dfce75d74de26ac6ee25625a44989312e29c1 (patch)
treeb0e802226f6ac38f6f0e3992719f6807355e6577 /Help
parent2ad300ebd73c6aca7189a9f8ea8d8ad61e9c3223 (diff)
downloadCMake-e47dfce75d74de26ac6ee25625a44989312e29c1.zip
CMake-e47dfce75d74de26ac6ee25625a44989312e29c1.tar.gz
CMake-e47dfce75d74de26ac6ee25625a44989312e29c1.tar.bz2
CMP0128: Enable/disable extensions if standard same as default
This was intended to be part of the initial MR (!6177), but accidentally went missing when debugging nightly failures on less common systems. Noticed during !6711 review as the comment about this behaviour didn't match the code. Documentation for CMP0128 is updated to remove a false case and note the two cases related to this. Fixes #22224.
Diffstat (limited to 'Help')
-rw-r--r--Help/policy/CMP0128.rst35
1 files changed, 13 insertions, 22 deletions
diff --git a/Help/policy/CMP0128.rst b/Help/policy/CMP0128.rst
index b894ce1..604a146 100644
--- a/Help/policy/CMP0128.rst
+++ b/Help/policy/CMP0128.rst
@@ -9,8 +9,8 @@ When this policy is set to ``NEW``:
:variable:`CMAKE_<LANG>_EXTENSIONS` if set, otherwise falling back to
:variable:`CMAKE_<LANG>_EXTENSIONS_DEFAULT`.
-* Extensions are correctly disabled/enabled if :prop_tgt:`<LANG>_STANDARD` is
- unset.
+* Extensions are correctly enabled/disabled if :prop_tgt:`<LANG>_STANDARD` is
+ unset or satisfied by the default.
* Standard mode-affecting flags aren't added unless necessary to achieve the
specified mode.
@@ -33,26 +33,6 @@ The ``OLD`` behavior:
Code may need to be updated for the ``NEW`` behavior in the following cases:
-* If :prop_tgt:`<LANG>_EXTENSIONS` matches
- :variable:`CMAKE_<LANG>_EXTENSIONS_DEFAULT` or is unset and the compiler's
- default satisfies :prop_tgt:`<LANG>_STANDARD` but the compiled code requires
- the exact standard specified.
- Such code should set :prop_tgt:`<LANG>_STANDARD_REQUIRED` to ``ON``.
-
- For example:
-
- .. code-block:: cmake
-
- cmake_minimum_required(VERSION |release|)
- project(example C)
-
- add_executable(exe main.c)
- set_property(TARGET exe PROPERTY C_STANDARD 99)
-
- If the compiler defaults to C11 then the standard specification for C99 is
- satisfied and CMake will pass no flags. ``main.c`` will no longer compile if
- it is incompatible with C11.
-
* 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.
@@ -64,6 +44,17 @@ Code may need to be updated for the ``NEW`` behavior in the following cases:
* Or ensure the manually-specified flags are used during compiler detection.
+* If extensions were disabled without :prop_tgt:`<LANG>_STANDARD` being 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 :prop_tgt:`<LANG>_STANDARD` was
+ 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 :manual:`a toolchain file <cmake-toolchains(7)>`
using :variable:`CMAKE_<LANG>_FLAGS_INIT`) then they will affect the detected