CMAKE_MSVC_RUNTIME_CHECKS.rst 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. CMAKE_MSVC_RUNTIME_CHECKS
  2. -------------------------
  3. .. versionadded:: 4.0
  4. Select the list of enabled runtime checks when targeting the MSVC ABI.
  5. This variable is used to initialize the
  6. :prop_tgt:`MSVC_RUNTIME_CHECKS` property on all targets as they are
  7. created. It is also propagated by calls to the :command:`try_compile` command
  8. into the test project.
  9. The allowed values are:
  10. .. include:: ../prop_tgt/MSVC_RUNTIME_CHECKS-VALUES.txt
  11. Use :manual:`generator expressions <cmake-generator-expressions(7)>` to
  12. support per-configuration specification. For example, the code:
  13. .. code-block:: cmake
  14. set(CMAKE_MSVC_RUNTIME_CHECKS "$<$<CONFIG:Debug,RelWithDebInfo>:PossibleDataLoss;UninitializedVariable>")
  15. enables for the target ``foo`` the possible data loss and uninitialized variables checks
  16. for the ``Debug`` and ``RelWithDebInfo`` configurations.
  17. If this variable is not set, the :prop_tgt:`MSVC_RUNTIME_CHECKS`
  18. target property will not be set automatically. If that property is not set,
  19. CMake selects runtime checks using the default value
  20. ``$<$<CONFIG:Debug>:StackFrameErrorCheck;UninitializedVariable>``,
  21. if supported by the compiler, or empty value otherwise.
  22. .. note::
  23. This variable has effect only when policy :policy:`CMP0184` is set to ``NEW``
  24. prior to the first :command:`project` or :command:`enable_language` command
  25. that enables a language using a compiler targeting the MSVC ABI.