Make sure USE_SANITIZER is not empty before foreach

Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com>
This commit is contained in:
Christophe Bedard 2020-02-29 11:53:33 -05:00 committed by eboasson
parent ca4b5a368f
commit dc57685ac3

View file

@ -173,19 +173,21 @@ endif()
# Make it easy to enable Clang's/gcc's analyzers # Make it easy to enable Clang's/gcc's analyzers
set(USE_SANITIZER "" CACHE STRING "Sanitizers to enable on the build.") set(USE_SANITIZER "" CACHE STRING "Sanitizers to enable on the build.")
foreach(san "${USE_SANITIZER}") if(NOT("${USE_SANITIZER}" STREQUAL ""))
message(STATUS "Enabling sanitizer: '${san}'") foreach(san "${USE_SANITIZER}")
message(STATUS "Enabling sanitizer: '${san}'")
if("${san}" STREQUAL address) if("${san}" STREQUAL address)
add_compile_options(-fno-omit-frame-pointer) add_compile_options(-fno-omit-frame-pointer)
link_libraries(-fno-omit-frame-pointer) link_libraries(-fno-omit-frame-pointer)
endif() endif()
if(NOT("${san}" STREQUAL "none")) if(NOT("${san}" STREQUAL "none"))
add_compile_options("-fsanitize=${san}") add_compile_options("-fsanitize=${san}")
link_libraries("-fsanitize=${san}") link_libraries("-fsanitize=${san}")
endif() endif()
endforeach() endforeach()
endif()
include(GNUInstallDirs) include(GNUInstallDirs)