From: Kefu Chai Date: Tue, 28 Jun 2016 04:57:21 +0000 (+0800) Subject: cmake: remove -DNDEBUG from CXXFLAGS of release builds X-Git-Tag: v11.0.1~932^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5130a3cc1ddfc816b50804620e576ac84ccf9ba6;p=ceph-ci.git cmake: remove -DNDEBUG from CXXFLAGS of release builds Signed-off-by: Kefu Chai --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df103872a45..641fdb83a3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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)