From 881feca1f250be30b26cfb1a606bb62f6bf16c2e Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 17 Dec 2021 19:14:34 -0800
Subject: [PATCH] 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
---
CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 18519c798da..84de4d1dbe2 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}")