Add assert macros for asserts not included in release builds

This commit is contained in:
Jonathan G Rennison
2022-10-22 12:10:40 +01:00
parent 38571cf0da
commit 071ac374e8
3 changed files with 16 additions and 1 deletions

View File

@@ -41,6 +41,9 @@ macro(compile_flags)
"$<$<CONFIG:Debug>:-D_DEBUG>"
"$<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>" # FORTIFY_SOURCE should only be used in non-debug builds (requires -O1+)
)
if(CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-DFEWER_ASSERTS)
endif()
if(MINGW)
add_link_options(
"$<$<NOT:$<CONFIG:Debug>>:-fstack-protector>" # Prevent undefined references when _FORTIFY_SOURCE > 0

View File

@@ -66,7 +66,7 @@ macro(test_compile_libbfd var libs)
endif ()
if (BFD_FOUND OR UNIX)
if (NOT (CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO"))
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_compile_options(-gline-tables-only)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")