Workaround for stack overhead with GCC+sanitizers

GCC compiler with address/undefined sanitizer seems to have more stack
overhead than clang.
So, we compile that combination with extra stack limit.

BUG=aomedia:2135
BUG=aomedia:2205

Change-Id: Ic317fbba2a254fbe6f928e01ee501af4f4c46acd
diff --git a/build/cmake/aom_configure.cmake b/build/cmake/aom_configure.cmake
index 295d57f..ce299b0 100644
--- a/build/cmake/aom_configure.cmake
+++ b/build/cmake/aom_configure.cmake
@@ -270,8 +270,17 @@
   add_compiler_flag_if_supported("-Wunused")
   add_compiler_flag_if_supported("-Wvla")
 
-  add_c_flag_if_supported("-Wstack-usage=100000")
-  add_cxx_flag_if_supported("-Wstack-usage=240000")
+  if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND "${SANITIZE}" MATCHES
+     "address|undefined")
+
+    # This combination has more stack overhead, so we account for it by
+    # providing higher stack limit than usual.
+    add_c_flag_if_supported("-Wstack-usage=170000")
+    add_cxx_flag_if_supported("-Wstack-usage=270000")
+  else()
+    add_c_flag_if_supported("-Wstack-usage=100000")
+    add_cxx_flag_if_supported("-Wstack-usage=240000")
+  endif()
 
   # TODO(jzern): this could be added as a cxx flags for test/*.cc only, avoiding
   # third_party.