CMP0091.rst 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. CMP0091
  2. -------
  3. .. versionadded:: 3.15
  4. MSVC runtime library flags are selected by an abstraction.
  5. Compilers targeting the MSVC ABI have flags to select the MSVC runtime library.
  6. Runtime library selection typically varies with build configuration because
  7. there is a separate runtime library for Debug builds.
  8. In CMake 3.14 and below, MSVC runtime library selection 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.15 and above prefer to leave the MSVC runtime library selection flags
  17. out of the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` values and instead
  18. offer a first-class abstraction. The :variable:`CMAKE_MSVC_RUNTIME_LIBRARY`
  19. variable and :prop_tgt:`MSVC_RUNTIME_LIBRARY` target property may be set to
  20. select the MSVC runtime library. If they are not set then CMake uses the
  21. default value ``MultiThreaded$<$<CONFIG:Debug>:Debug>DLL`` which is
  22. equivalent to the original flags.
  23. This policy provides compatibility with projects that have not been updated
  24. to be aware of the abstraction. The policy setting takes effect as of the
  25. first :command:`project` or :command:`enable_language` command that enables
  26. a language whose compiler targets the MSVC ABI.
  27. .. note::
  28. Once the policy has taken effect at the top of a project, that choice
  29. must be used throughout the tree. In projects that have nested projects
  30. in subdirectories, be sure to convert everything together.
  31. The ``OLD`` behavior for this policy is to place MSVC runtime library
  32. flags in the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache
  33. entries and ignore the :variable:`CMAKE_MSVC_RUNTIME_LIBRARY` abstraction.
  34. The ``NEW`` behavior for this policy is to *not* place MSVC runtime
  35. library flags in the default cache entries and use the abstraction instead.
  36. This policy was introduced in CMake version 3.15. Use the
  37. :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
  38. Unlike many policies, CMake version |release| does *not* warn
  39. when this policy is not set and simply uses ``OLD`` behavior.
  40. .. include:: DEPRECATED.txt