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