CMP0184.rst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. CMP0184
  2. -------
  3. .. versionadded:: 4.0
  4. MSVC runtime checks flags are selected by an abstraction.
  5. Compilers targeting the MSVC ABI have flags to select the runtime checks.
  6. Runtime checks selection typically varies with build
  7. configuration.
  8. In CMake 3.31 and below, runtime checks flags are added to
  9. the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache entries by CMake
  10. automatically. This allows users to edit their cache entries to adjust the
  11. flags. However, the presence of such default flags is problematic for
  12. projects that want to choose different runtime checks programmatically.
  13. In particular, it requires string editing of the
  14. :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variables with knowledge of the
  15. CMake builtin defaults so they can be replaced.
  16. CMake 4.0 and above prefer to leave the runtime checks flags
  17. out of the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` values and instead
  18. offer a first-class abstraction. The
  19. :variable:`CMAKE_MSVC_RUNTIME_CHECKS` variable and
  20. :prop_tgt:`MSVC_RUNTIME_CHECKS` target property may be set to
  21. select the MSVC runtime checks. If they are not set, CMake
  22. enables runtime checks for the ``Debug`` configuration only using the default
  23. value ``$<$<CONFIG:Debug>:StackFrameErrorCheck;UninitializedVariable>``, if
  24. supported by the compiler, or an empty value otherwise.
  25. This policy provides compatibility with projects that have not been updated
  26. to be aware of the abstraction. The policy setting takes effect as of the
  27. first :command:`project` or :command:`enable_language` command that enables
  28. a language whose compiler targets the MSVC ABI.
  29. .. note::
  30. Once the policy has taken effect at the top of a project, that choice
  31. will be used throughout the tree. In projects that have nested projects
  32. in subdirectories, be sure to confirm if everything is working with the
  33. selected policy behavior.
  34. The ``OLD`` behavior for this policy is to place MSVC runtimes checks
  35. flags in the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache
  36. entries and ignore the :variable:`CMAKE_MSVC_RUNTIME_CHECKS`
  37. abstraction. The ``NEW`` behavior for this policy is to *not* place MSVC
  38. runtime checks flags in the default cache entries and use
  39. the abstraction instead.
  40. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.0
  41. .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
  42. .. include:: include/STANDARD_ADVICE.rst
  43. .. include:: include/DEPRECATED.rst