Add assert macros for asserts not included in release builds
This commit is contained in:
@@ -41,6 +41,9 @@ macro(compile_flags)
|
|||||||
"$<$<CONFIG:Debug>:-D_DEBUG>"
|
"$<$<CONFIG:Debug>:-D_DEBUG>"
|
||||||
"$<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>" # FORTIFY_SOURCE should only be used in non-debug builds (requires -O1+)
|
"$<$<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)
|
if(MINGW)
|
||||||
add_link_options(
|
add_link_options(
|
||||||
"$<$<NOT:$<CONFIG:Debug>>:-fstack-protector>" # Prevent undefined references when _FORTIFY_SOURCE > 0
|
"$<$<NOT:$<CONFIG:Debug>>:-fstack-protector>" # Prevent undefined references when _FORTIFY_SOURCE > 0
|
||||||
|
@@ -66,7 +66,7 @@ macro(test_compile_libbfd var libs)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (BFD_FOUND OR UNIX)
|
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")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||||
add_compile_options(-gline-tables-only)
|
add_compile_options(-gline-tables-only)
|
||||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
12
src/stdafx.h
12
src/stdafx.h
@@ -478,6 +478,18 @@ const char *assert_tile_info(uint32 tile);
|
|||||||
# define assert_msg_tile(expression, tile, ...)
|
# define assert_msg_tile(expression, tile, ...)
|
||||||
# define assert_tile(expression, tile)
|
# define assert_tile(expression, tile)
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(FEWER_ASSERTS)
|
||||||
|
# define WITH_FULL_ASSERTS
|
||||||
|
# define dbg_assert(expression) assert(expression)
|
||||||
|
# define dbg_assert_msg(expression, ...) assert_msg(expression, __VA_ARGS__)
|
||||||
|
# define dbg_assert_msg_tile(expression, tile, ...) assert_msg_tile(expression, tile, __VA_ARGS__)
|
||||||
|
# define dbg_assert_tile(expression, tile) assert_tile(expression, tile)
|
||||||
|
#else
|
||||||
|
# define dbg_assert(expression)
|
||||||
|
# define dbg_assert_msg(expression, ...)
|
||||||
|
# define dbg_assert_msg_tile(expression, tile, ...)
|
||||||
|
# define dbg_assert_tile(expression, tile)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(OPENBSD)
|
#if defined(OPENBSD)
|
||||||
/* OpenBSD uses strcasecmp(3) */
|
/* OpenBSD uses strcasecmp(3) */
|
||||||
|
Reference in New Issue
Block a user