From dc57685ac3d28349fbb64472f0e34c8fd7e2eeb4 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Sat, 29 Feb 2020 11:53:33 -0500 Subject: [PATCH] Make sure USE_SANITIZER is not empty before foreach Signed-off-by: Christophe Bedard --- CMakeLists.txt | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2811e3a..fd7878f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,19 +173,21 @@ endif() # Make it easy to enable Clang's/gcc's analyzers set(USE_SANITIZER "" CACHE STRING "Sanitizers to enable on the build.") -foreach(san "${USE_SANITIZER}") - message(STATUS "Enabling sanitizer: '${san}'") +if(NOT("${USE_SANITIZER}" STREQUAL "")) + foreach(san "${USE_SANITIZER}") + message(STATUS "Enabling sanitizer: '${san}'") - if("${san}" STREQUAL address) - add_compile_options(-fno-omit-frame-pointer) - link_libraries(-fno-omit-frame-pointer) - endif() + if("${san}" STREQUAL address) + add_compile_options(-fno-omit-frame-pointer) + link_libraries(-fno-omit-frame-pointer) + endif() - if(NOT("${san}" STREQUAL "none")) - add_compile_options("-fsanitize=${san}") - link_libraries("-fsanitize=${san}") - endif() -endforeach() + if(NOT("${san}" STREQUAL "none")) + add_compile_options("-fsanitize=${san}") + link_libraries("-fsanitize=${san}") + endif() + endforeach() +endif() include(GNUInstallDirs)