From 72be0db032dc1397d375a544af8ce4704ea5eb10 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Mon, 7 Dec 2020 16:38:34 +0200 Subject: [PATCH] Don't turn on sanitizer for non-debug builds --- CMakeLists.txt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4e2364..f30ca23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,14 +4,19 @@ project(asciiTeX C) set(CMAKE_CXX_STANDARD 11) -set(CMAKE_BUILD_TYPE Debug) +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug + CACHE STRING "Set build type (default Debug)" FORCE) +endif() -if (MSVC) - add_compile_options(/W4 /WX) -else() - add_compile_options(-Wall -Wextra -pedantic -Werror) # -Weverything - string(APPEND CMAKE_C_FLAGS_DEBUG " -fno-omit-frame-pointer -fsanitize=address,undefined") - string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -fsanitize=address,undefined") +if(CMAKE_BUILD_TYPE MATCHES Debug) + if (MSVC) + add_compile_options(/W4 /WX) + else() + add_compile_options(-Wall -Wextra -pedantic -Werror) # -Weverything + string(APPEND CMAKE_C_FLAGS_DEBUG " -fno-omit-frame-pointer -fsanitize=address,undefined") + string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -fsanitize=address,undefined") + endif() endif() add_executable (asciitex