CMP0141.rst 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. CMP0141
  2. -------
  3. .. versionadded:: 3.25
  4. MSVC debug information format flags are selected by an abstraction.
  5. Compilers targeting the MSVC ABI have flags to select the debug information
  6. format. Debug information format selection typically varies with build
  7. configuration.
  8. In CMake 3.24 and below, debug information format 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 a different runtime library 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 3.25 and above prefer to leave the debug information format 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_DEBUG_INFORMATION_FORMAT` variable and
  20. :prop_tgt:`MSVC_DEBUG_INFORMATION_FORMAT` target property may be set to
  21. select the MSVC debug information format. If they are not set, CMake
  22. enables debug information in debug configurations using the default value
  23. ``$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>``, if supported by the
  24. compiler, and otherwise ``$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>``.
  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 debug information
  35. format flags in the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache
  36. entries and ignore the :variable:`CMAKE_MSVC_DEBUG_INFORMATION_FORMAT`
  37. abstraction. The ``NEW`` behavior for this policy is to *not* place MSVC
  38. debug information format flags in the default cache entries and use
  39. the abstraction instead.
  40. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.25
  41. .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
  42. .. include:: STANDARD_ADVICE.txt
  43. .. include:: DEPRECATED.txt