From 4f639d64b8a36e275ff57d28612b5fecc20be963 Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Sat, 26 Jun 2021 11:55:01 -0400 Subject: [PATCH] Define NDEBUG in release mode --- cmake/setup_compiler_flags_gnu.cmake | 6 ++++++ cmake/setup_compiler_flags_intel.cmake | 6 ++++++ cmake/setup_compiler_flags_msvc.cmake | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/cmake/setup_compiler_flags_gnu.cmake b/cmake/setup_compiler_flags_gnu.cmake index ca26003cbe..737a90b821 100644 --- a/cmake/setup_compiler_flags_gnu.cmake +++ b/cmake/setup_compiler_flags_gnu.cmake @@ -187,6 +187,12 @@ IF (CMAKE_BUILD_TYPE MATCHES "Release") ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-funroll-all-loops") ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-fstrict-aliasing") + # + # Disable assert() in deal.II and user projects in release mode + # + LIST(APPEND DEAL_II_DEFINITIONS_RELEASE "NDEBUG") + LIST(APPEND DEAL_II_USER_DEFINITIONS_RELEASE "NDEBUG") + # # There are many places in the library where we create a new typedef and then # immediately use it in an Assert. Hence, only ignore unused typedefs in Release diff --git a/cmake/setup_compiler_flags_intel.cmake b/cmake/setup_compiler_flags_intel.cmake index 17b8fc959b..b83493f848 100644 --- a/cmake/setup_compiler_flags_intel.cmake +++ b/cmake/setup_compiler_flags_intel.cmake @@ -183,6 +183,12 @@ IF (CMAKE_BUILD_TYPE MATCHES "Release") ADD_FLAGS(DEAL_II_CXX_FLAGS_RELEASE "-O2") + # + # Disable assert() in deal.II and user projects in release mode + # + LIST(APPEND DEAL_II_DEFINITIONS_RELEASE "NDEBUG") + LIST(APPEND DEAL_II_USER_DEFINITIONS_RELEASE "NDEBUG") + # equivalent to -fno-strict-aliasing: ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-no-ansi-alias") diff --git a/cmake/setup_compiler_flags_msvc.cmake b/cmake/setup_compiler_flags_msvc.cmake index 32921fc03d..898b527306 100644 --- a/cmake/setup_compiler_flags_msvc.cmake +++ b/cmake/setup_compiler_flags_msvc.cmake @@ -99,6 +99,13 @@ IF (CMAKE_BUILD_TYPE MATCHES "Release") # General optimization flags: (very basic for now) # ADD_FLAGS(DEAL_II_CXX_FLAGS_RELEASE "/O2") + + # + # Disable assert() in deal.II and user projects in release mode + # + LIST(APPEND DEAL_II_DEFINITIONS_RELEASE "NDEBUG") + LIST(APPEND DEAL_II_USER_DEFINITIONS_RELEASE "NDEBUG") + ENDIF() -- 2.39.5