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
This commit is contained in:
Sam Lantinga 2021-12-17 19:14:34 -08:00
parent c31a40246d
commit 881feca1f2
1 changed files with 2 additions and 2 deletions

View File

@ -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}")