MSVC: Add abstraction for runtime checks

Replace our hard-coded default for `/RTC1` with a first-class
abstraction to select runtime checks from an enumeration of logical
names.  Add a `MSVC_RUNTIME_CHECKS` target property and corresponding
`CMAKE_MSVC_RUNTIME_CHECKS` variable.

Removing the old default flag requires a policy because existing
projects may rely on string processing to edit them and choose
runtime checks under the old behavior.  Add policy CMP0184 to
provide compatibility.

Fixes: #26614
This commit is contained in:
AJIOB
2025-01-22 13:10:03 +03:00
committed by Brad King
parent 49dcd1ce5d
commit 2b2344b412
48 changed files with 599 additions and 22 deletions

View File

@@ -349,6 +349,7 @@ as needed to honor the state of the calling project:
* :policy:`CMP0155`
* :policy:`CMP0157`
* :policy:`CMP0181`
* :policy:`CMP0184`
.. versionadded:: 4.0
The current setting of :policy:`CMP0181` policy is propagated through to the
@@ -417,6 +418,11 @@ configuration:
propagated into the test project's build configuration when using the
:ref:`whole-project signature <Try Compiling Whole Projects>`.
.. versionadded:: 4.0
If :policy:`CMP0184` is set to ``NEW``, one can use
:variable:`CMAKE_MSVC_RUNTIME_CHECKS` to specify the enabled MSVC runtime
checks.
See Also
^^^^^^^^