OSDN Git Service

Add CMake flag to treat warnings as errors
authorBen Clayton <headlessclayton@gmail.com>
Tue, 19 Feb 2019 17:08:56 +0000 (17:08 +0000)
committerBen Clayton <bclayton@google.com>
Fri, 22 Feb 2019 16:36:38 +0000 (16:36 +0000)
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>
.vscode/tasks.json
CMakeLists.txt

index da01bff..d0804da 100644 (file)
@@ -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"
index 90fc09a..c1b38c8 100644 (file)
@@ -76,6 +76,7 @@ option (MSAN "Build with memory sanitizer" 0)
 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 @@ else()
         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'