cmStandardLevelResolver: Avoid unnecessary flags, fix unset level logic

The changes are part of CMP0128.

When the standard level is unset:
* Flags are added if extension mode doesn't match the compiler's default.
  Previously logic only worked if LANG_EXTENSIONS was ON. Fixes #22224.
* The full flag is used. Previously CMAKE_LANG_EXTENSION_COMPILE_OPTION was
  used. This was only supported for IAR.

Otherwise:
* Avoid adding flags if not necessary per the detected compiler defaults.
* Fixed check for when the requested standard is older. It now matches the
  nearby comments.

I reworded the fallback comment as its logic was a bit difficult to wrap my
head around.
This commit is contained in:
Raul Tambre
2021-05-29 18:34:18 +03:00
parent 29e2b85171
commit 4a0485be7f
20 changed files with 376 additions and 25 deletions

View File

@@ -32,6 +32,8 @@ only for the policies that do not warn by default:
policy :policy:`CMP0116`.
* ``CMAKE_POLICY_WARNING_CMP0126`` controls the warning for
policy :policy:`CMP0126`.
* ``CMAKE_POLICY_WARNING_CMP0128`` controls the warning for
policy :policy:`CMP0128`.
This variable should not be set by a project in CMake code. Project
developers running CMake may set this variable in their cache to