CMP0117.rst 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. CMP0117
  2. -------
  3. .. versionadded:: 3.20
  4. MSVC RTTI flag ``/GR`` is not added to
  5. :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` by default.
  6. When using MSVC-like compilers in CMake 3.19 and below, the RTTI flag
  7. ``/GR`` is added to :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` by
  8. default. This behavior is left from support for MSVC versions from Visual
  9. Studio 2003 and below that did not enable RTTI by default. It is no longer
  10. necessary. Furthermore, it is problematic for projects that want to change
  11. to ``/GR-`` programmatically. In particular, it requires string editing of
  12. the :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` variable with knowledge
  13. of the CMake builtin default so it can be replaced.
  14. CMake 3.20 and above prefer to leave out ``/GR`` from the value of
  15. :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` by default.
  16. This policy provides compatibility with projects that have not been updated
  17. to expect the lack of the ``/GR`` flag. The policy setting takes effect as
  18. of the first :command:`project` or :command:`enable_language` command that
  19. initializes :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>`.
  20. .. note::
  21. Once the policy has taken effect at the top of a project for a given
  22. language, that choice must be used throughout the tree for that language.
  23. In projects that have nested projects in subdirectories, be sure to
  24. convert everything together.
  25. The ``OLD`` behavior for this policy is to place the MSVC ``/GR`` flag in the
  26. default :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` cache entry. The
  27. ``NEW`` behavior for this policy is to *not* place the MSVC ``/GR`` flag in
  28. the default cache entry.
  29. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.20
  30. .. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
  31. .. include:: include/STANDARD_ADVICE.rst
  32. .. include:: include/DEPRECATED.rst