]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: remove -DNDEBUG from CXXFLAGS of release builds 9975/head
authorKefu Chai <kchai@redhat.com>
Tue, 28 Jun 2016 04:57:21 +0000 (12:57 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 28 Jun 2016 05:26:40 +0000 (13:26 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/CMakeLists.txt

index df103872a45b5c55c1dd914f9dbe0a0622615c14..641fdb83a3a8327d140b8972537aed0431469495 100644 (file)
@@ -25,6 +25,16 @@ if(NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Default BUILD_TYPE is RelWithDebInfo, other options are: Debug, Release, and MinSizeRel." FORCE) 
 endif()
 
+if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
+  # we use assert(3) for testing, so scrub the -DNDEBUG defined by default
+  string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type_upper)
+  foreach(flags
+      CMAKE_CXX_FLAGS_${build_type_upper}
+      CMAKE_C_FLAGS_${build_type_upper})
+    string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " "${flags}" "${${flags}}")
+  endforeach()
+endif()
+
 include(CheckCCompilerFlag)
 CHECK_C_COMPILER_FLAG("-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=2 -Werror" HAS_FORTIFY_SOURCE)
 if(HAS_FORTIFY_SOURCE)