CMP0162.rst 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. CMP0162
  2. -------
  3. .. versionadded:: 3.30
  4. :ref:`Visual Studio Generators` add ``UseDebugLibraries`` indicators by default.
  5. The "Use Debug Libraries" setting in Visual Studio projects indicates what
  6. configurations are considered debug configurations. In standalone projects,
  7. this may affect MSBuild's default selection of MSVC runtime library,
  8. optimization flags, runtime checks, and similar settings. CMake typically
  9. generates all those settings explicitly based on the project's specification,
  10. so CMake 3.29 and below do not write any ``UseDebugLibraries`` indicators to
  11. ``.vcxproj`` files.
  12. CMake 3.30 and above prefer to write ``UseDebugLibraries`` indicators because
  13. they are useful for reference by both humans and tools, and may also affect
  14. the behavior of platform-specific SDKs. The indicator for each configuration
  15. of a target is determined as follows:
  16. * If the target compiles sources for a known MSVC runtime library
  17. (such as that specified by :prop_tgt:`MSVC_RUNTIME_LIBRARY`),
  18. then ``UseDebugLibraries`` is ``true`` for configurations that
  19. compile for a "Debug" runtime library, and ``false`` for others.
  20. * Otherwise, such as in targets created by :command:`add_custom_target`,
  21. ``UseDebugLibraries`` is ``true`` for the ``Debug`` configuration,
  22. and ``false`` for others.
  23. This policy provides compatibility for projects that have not been updated to
  24. expect the indicators. The policy setting is recorded by each target as it is
  25. created and used to determine the default behavior for that target's
  26. ``.vcxproj`` file.
  27. The ``OLD`` behavior for this policy is to not generate ``UseDebugLibraries``
  28. indicators by default. The ``NEW`` behavior for this policy is to generate
  29. ``UseDebugLibraries`` indicators by default.
  30. If the :variable:`CMAKE_VS_USE_DEBUG_LIBRARIES` variable and/or
  31. :prop_tgt:`VS_USE_DEBUG_LIBRARIES` target property is set, it explicitly
  32. controls ``UseDebugLibraries`` generation regardless of this policy.
  33. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.30
  34. .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
  35. .. include:: STANDARD_ADVICE.txt
  36. .. include:: DEPRECATED.txt