CMake: Add DCHECK_ALWAYS_ON flag
Enables macros like ASSERT, UNIMPLEMENTED even in release builds.
Bug: b/126329018
Change-Id: I7d810862b16d85b0a4ffc6b39a655cc73d4c669a
Reviewed-on: https://swiftshader-review.googlesource.com/c/25557
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index d0804da..7a88e94 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -67,7 +67,8 @@
"args": [
"..",
"-DCMAKE_BUILD_TYPE=${input:buildType}",
- "-DWARNINGS_AS_ERRORS=1"
+ "-DWARNINGS_AS_ERRORS=1",
+ "-DDCHECK_ALWAYS_ON=1"
],
"options": {
"cwd": "${workspaceRoot}/build"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9ca4085..ca10ce9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,6 +77,7 @@
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)
+option (DCHECK_ALWAYS_ON "Check validation macros even in release builds" 0)
if(ARCH STREQUAL "arm")
set(DEFAULT_REACTOR_BACKEND "Subzero")
@@ -271,6 +272,10 @@
set_cpp_flag("-Werror") # Treat all warnings as errors
endif()
+ if(DCHECK_ALWAYS_ON)
+ set_cpp_flag("-DDCHECK_ALWAYS_ON")
+ endif()
+
# Disable pedanitc warnings
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set_cpp_flag("-Wno-ignored-attributes") # ignoring attributes on template argument 'X'