Commit b5f1fe5004788aab863b425c73f4a7fd2edc2908

Anonymous Maarten 2022-06-15T06:17:59

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e65c3bb..3435f03 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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")
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 3f17d13..c213a2f 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -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@