aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authormj-xmr <mjxmr@protonmail.com>2021-03-08 22:19:16 +0100
committermj-xmr <mjxmr@protonmail.com>2021-03-10 17:41:55 +0100
commit430b7586f6f6e1cbffba635171086b7cef87a3f6 (patch)
treea2c08ac0ee28213289601c8a00e939e5c8927331 /CMakeLists.txt
parentMerge pull request #7399 (diff)
downloadmonero-430b7586f6f6e1cbffba635171086b7cef87a3f6.tar.xz
Warnings: add warnings as errors: 'switch' & 'return-type'
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt7
1 files changed, 7 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49ac18c66..af056c49a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -744,6 +744,13 @@ else()
add_linker_flag_if_supported(-Wl,--high-entropy-va LD_SECURITY_FLAGS)
endif()
+ # Warnings, that when ignored are so severe, that they can segfault or even UB any application.
+ # Treat them as errors.
+ add_c_flag_if_supported( -Werror=switch C_SECURITY_FLAGS)
+ add_cxx_flag_if_supported(-Werror=switch CXX_SECURITY_FLAGS)
+ add_c_flag_if_supported( -Werror=return-type C_SECURITY_FLAGS)
+ add_cxx_flag_if_supported(-Werror=return-type CXX_SECURITY_FLAGS)
+
message(STATUS "Using C security hardening flags: ${C_SECURITY_FLAGS}")
message(STATUS "Using C++ security hardening flags: ${CXX_SECURITY_FLAGS}")
message(STATUS "Using linker security hardening flags: ${LD_SECURITY_FLAGS}")