cmake: Allow integers for SDL_ASSERTIONS + fix -DSDL_ASSERTIONS=0

This commit is contained in:
Anonymous Maarten 2022-06-15 06:17:59 +02:00 committed by Sam Lantinga
parent 97711e99fe
commit b5f1fe5004
2 changed files with 10 additions and 5 deletions

View File

@ -517,15 +517,18 @@ file(GLOB SOURCE_FILES
${SDL2_SOURCE_DIR}/src/video/yuv2rgb/*.c)
if(SDL_ASSERTIONS STREQUAL "auto")
set(SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED 1)
if(SDL_ASSERTIONS MATCHES "^(auto|)$")
# Do nada - use optimization settings to determine the assertion level
elseif(SDL_ASSERTIONS STREQUAL "disabled")
set(SDL_DEFAULT_ASSERT_LEVEL )
set(SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED 0)
elseif(SDL_ASSERTIONS MATCHES "^(disabled|0)$")
set(SDL_DEFAULT_ASSERT_LEVEL 0)
elseif(SDL_ASSERTIONS STREQUAL "release")
elseif(SDL_ASSERTIONS MATCHES "^(release|1)$")
set(SDL_DEFAULT_ASSERT_LEVEL 1)
elseif(SDL_ASSERTIONS STREQUAL "enabled")
elseif(SDL_ASSERTIONS MATCHES "^(enabled|2)$")
set(SDL_DEFAULT_ASSERT_LEVEL 2)
elseif(SDL_ASSERTIONS STREQUAL "paranoid")
elseif(SDL_ASSERTIONS MATCHES "^(paranoid|3)$")
set(SDL_DEFAULT_ASSERT_LEVEL 3)
else()
message_error("unknown assertion level")

View File

@ -261,7 +261,9 @@
#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@
/* SDL internal assertion support */
#if @SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED@
#cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@
#endif
/* Allow disabling of core subsystems */
#cmakedefine SDL_ATOMIC_DISABLED @SDL_ATOMIC_DISABLED@