aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViktor Szakats <commit@vsz.me>2024-03-11 15:31:14 +0000
committerViktor Szakats <commit@vsz.me>2024-03-11 15:35:13 +0000
commit6664303ae2d0407d06b77a21b26d6ae08b7535f1 (patch)
tree8dc3946b21c07de7d4460e9708842e08ef5f0f08
parent69449e791b5e99408a686fa68c2e5745a950162f (diff)
downloadportable-6664303ae2d0407d06b77a21b26d6ae08b7535f1.tar.gz
portable-6664303ae2d0407d06b77a21b26d6ae08b7535f1.tar.bz2
portable-6664303ae2d0407d06b77a21b26d6ae08b7535f1.zip
cmake: disable default NDEBUG differently
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 #988, which was merged, but the commit vanished from master and ended up missing from both 3.8.3 and 3.9.0 releases.
-rw-r--r--CMakeLists.txt9
1 files changed, 7 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dc14583..01a42fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -62,8 +62,13 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
62 STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") 62 STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
63endif() 63endif()
64 64
65# Enable asserts regardless of build type 65# Do not disable assertions based on CMAKE_BUILD_TYPE
66add_definitions(-UNDEBUG) 66foreach(_build_type "Release" "MinSizeRel" "RelWithDebInfo")
67 foreach(_lang C CXX)
68 string(TOUPPER "CMAKE_${_lang}_FLAGS_${_build_type}" _var)
69 string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )" " " ${_var} "${${_var}}")
70 endforeach()
71endforeach()
67 72
68set(BUILD_NC true) 73set(BUILD_NC true)
69 74