Add CMake flag to treat warnings as errors
Disabled by default by the request of Nicolas.
Bug: b/123933266
Change-Id: Ie1217dc6c96ec85c9daf8246de785c8729386634
Reviewed-on: https://swiftshader-review.googlesource.com/c/25015
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index da01bff..d0804da 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -66,7 +66,8 @@
"command": "cmake",
"args": [
"..",
- "-DCMAKE_BUILD_TYPE=${input:buildType}"
+ "-DCMAKE_BUILD_TYPE=${input:buildType}",
+ "-DWARNINGS_AS_ERRORS=1"
],
"options": {
"cwd": "${workspaceRoot}/build"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90fc09a..c1b38c8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -76,6 +76,7 @@
option (ASAN "Build with address sanitizer" 0)
option (TSAN "Build with thread sanitizer" 0)
option (UBSAN "Build with undefined behavior sanitizer" 0)
+option (WARNINGS_AS_ERRORS "Treat all warnings as errors" 0)
if(ARCH STREQUAL "arm")
set(DEFAULT_REACTOR_BACKEND "Subzero")
@@ -266,6 +267,10 @@
set_cpp_flag("-s" RELEASE)
endif()
+ if(WARNINGS_AS_ERRORS)
+ set_cpp_flag("-Werror") # Treat all warnings as errors
+ endif()
+
# Disable pedanitc warnings
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set_cpp_flag("-Wno-ignored-attributes") # ignoring attributes on template argument 'X'