Commit 881feca1f250be30b26cfb1a606bb62f6bf16c2e

Sam Lantinga 2021-12-17T19:14:34

CMAKE: fixed cflags check for build type Martin Gerhardy wrote: If there is a variable named test, then cmake does variable-value comparison: if (test STREQUAL "") is equivalent to: if ("${test}" STREQUAL "") If there is no variable named test, then cmake does string literal comparison: if (test STREQUAL "") is equivalent to: if ("test" STREQUAL "") That means basically - the current stuff works - but is not how it should be done. Fixes https://github.com/libsdl-org/SDL/issues/2100

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 18519c7..84de4d1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2656,7 +2656,7 @@ if (SDL_ASAN)
   asan_check_add_debug_flag("leak")
   # The object size sanitizer has no effect on unoptimized builds on Clang,
   # but causes warnings.
-  if((NOT USE_CLANG) OR (CMAKE_BUILD_TYPE STREQUAL ""))
+  if((NOT USE_CLANG) OR ("${CMAKE_BUILD_TYPE}" STREQUAL ""))
     asan_check_add_debug_flag("object-size")
   endif()
 endif()
@@ -2685,7 +2685,7 @@ foreach(_OPT ${ALLOPTIONS})
   string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING)
   message_tested_option(${_OPT} ${_PADDING})
 endforeach()
-if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
   message(STATUS "")
   message(STATUS " CMAKE_C_FLAGS_DEBUG:   ${CMAKE_C_FLAGS_DEBUG}")
   message(STATUS " CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")