CMP0128.rst 2.6 KB

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