Skip to content

Commit

Permalink
cmake: disable default NDEBUG differently
Browse files Browse the repository at this point in the history
Before this patch `NDEBUG` was force-disabled, preventing a build with
debug asserts disabled.

After this patch `NDEBUG` works again when passed as a custom build
option, e.g.: `-DCMAKE_C_FLAGS=-DNDEBUG`

Previously submitted as libressl#988, which was merged, but the commit vanished
from master and ended up missing from both 3.8.3 and 3.9.0 releases.
  • Loading branch information
vszakats committed Mar 11, 2024
1 parent 69449e7 commit 6664303
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

# Enable asserts regardless of build type
add_definitions(-UNDEBUG)
# Do not disable assertions based on CMAKE_BUILD_TYPE
foreach(_build_type "Release" "MinSizeRel" "RelWithDebInfo")
foreach(_lang C CXX)
string(TOUPPER "CMAKE_${_lang}_FLAGS_${_build_type}" _var)
string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " ${_var} "${${_var}}")
endforeach()
endforeach()

set(BUILD_NC true)

Expand Down

0 comments on commit 6664303

Please sign in to comment.