COMPILE_WARNING_AS_ERROR: Add options to treat warnings as errors

Add `COMPILE_WARNING_AS_ERROR` target property and supporting
`CMAKE_COMPILE_WARNING_AS_ERROR` variable.

`COMPILE_WARNING_AS_ERROR` is initialized by
`CMAKE_COMPILE_WARNING_AS_ERROR`. It is a boolean variable. If it is
true, it expands to a different flag depending on the compiler such that
any warnings at compile will be treated as errors.

Supports compiler ids that I could find a relevant flag for.
This commit is contained in:
Martin Duffy
2022-04-21 15:29:05 -04:00
committed by Brad King
parent de802fc5a3
commit 76a08cd253
33 changed files with 167 additions and 27 deletions

View File

@@ -171,6 +171,7 @@ Properties on Targets
/prop_tgt/COMPILE_PDB_NAME_CONFIG
/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY
/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/prop_tgt/COMPILE_WARNING_AS_ERROR
/prop_tgt/CONFIG_OUTPUT_NAME
/prop_tgt/CONFIG_POSTFIX
/prop_tgt/CROSSCOMPILING_EMULATOR

View File

@@ -399,6 +399,7 @@ Variables that Control the Build
/variable/CMAKE_BUILD_WITH_INSTALL_RPATH
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/variable/CMAKE_COMPILE_WARNING_AS_ERROR
/variable/CMAKE_CONFIG_POSTFIX
/variable/CMAKE_CROSS_CONFIGS
/variable/CMAKE_CTEST_ARGUMENTS

View File

@@ -0,0 +1,10 @@
COMPILE_WARNING_AS_ERROR
------------------------
.. versionadded:: 3.24
Specify whether to treat warnings on compile as errors.
If enabled, adds a flag to treat warnings on compile as errors.
This property is initialized by the value of the variable
:variable:`CMAKE_COMPILE_WARNING_AS_ERROR` if it is set when a target is created.

View File

@@ -0,0 +1,8 @@
werror-property
---------------
* Added the Target Property :prop_tgt:`COMPILE_WARNING_AS_ERROR` and the
Variable :variable:`CMAKE_COMPILE_WARNING_AS_ERROR` which initializes the
Target Property. If :prop_tgt:`COMPILE_WARNING_AS_ERROR` is true, it expands
to a different flag depending on the compiler such that any warnings at
compile will be treated as errors.

View File

@@ -0,0 +1,9 @@
CMAKE_COMPILE_WARNING_AS_ERROR
------------------------------
.. versionadded:: 3.24
Specify whether to treat warnings on compile as errors.
This variable is used to initialize the
:prop_tgt:`COMPILE_WARNING_AS_ERROR` property on all the targets.