Fix some unreliable STREQUAL calls in CMakeLists.txt

These conditionals may fail if the variable they're checking isn't
defined at all. Adding quotes makes the comparison against an empty
string in this case, which avoids the syntax error.

Signed-off-by: Scott K Logan <logans@cottsay.net>
This commit is contained in:
Scott K Logan 2019-10-21 17:26:27 -07:00 committed by eboasson
parent 94e4c0915d
commit a3b35a2aa4

View file

@ -170,17 +170,17 @@ endif()
# the address sanitizer for ordinary debug builds; gcc is giving some grief on # the address sanitizer for ordinary debug builds; gcc is giving some grief on
# Travis, so don't enable it for gcc by default # Travis, so don't enable it for gcc by default
if(NOT USE_SANITIZER) if(NOT USE_SANITIZER)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND
NOT (${CMAKE_GENERATOR} STREQUAL "Xcode") AND NOT ("${CMAKE_GENERATOR}" STREQUAL "Xcode") AND
(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"
OR ${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang")) OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang"))
message(STATUS "Enabling address sanitizer; set USE_SANITIZER=none to prevent this") message(STATUS "Enabling address sanitizer; set USE_SANITIZER=none to prevent this")
set(USE_SANITIZER address) set(USE_SANITIZER address)
else() else()
set(USE_SANITIZER none) set(USE_SANITIZER none)
endif() endif()
endif() endif()
if(NOT (${USE_SANITIZER} STREQUAL "none")) if(NOT ("${USE_SANITIZER}" STREQUAL "none"))
message(STATUS "Sanitizer set to ${USE_SANITIZER}") message(STATUS "Sanitizer set to ${USE_SANITIZER}")
add_compile_options(-fno-omit-frame-pointer -fsanitize=${USE_SANITIZER}) add_compile_options(-fno-omit-frame-pointer -fsanitize=${USE_SANITIZER})
link_libraries(-fno-omit-frame-pointer -fsanitize=${USE_SANITIZER}) link_libraries(-fno-omit-frame-pointer -fsanitize=${USE_SANITIZER})