diff --git a/CMakeLists.txt b/CMakeLists.txt index ab9affa5f9..33c26f551a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,20 +37,23 @@ endif() if(PONY_USE_THREAD_SANITIZER) set(PONY_OUTPUT_SUFFIX "${PONY_OUTPUT_SUFFIX}-thread_sanitizer") - add_compile_options(-fsanitize=thread -DPONY_SANITIZER=\"thread\") - add_link_options(-fsanitize=thread -DPONY_SANITIZER=\"thread\") + list(APPEND PONY_SANITIZERS_ENABLED "thread") endif() if(PONY_USE_ADDRESS_SANITIZER) set(PONY_OUTPUT_SUFFIX "${PONY_OUTPUT_SUFFIX}-address_sanitizer") - add_compile_options(-fsanitize=address -DPONY_SANITIZER=\"address\") - add_link_options(-fsanitize=address -DPONY_SANITIZER=\"address\") + list(APPEND PONY_SANITIZERS_ENABLED "address") endif() if(PONY_USE_UNDEFINED_BEHAVIOR_SANITIZER) set(PONY_OUTPUT_SUFFIX "${PONY_OUTPUT_SUFFIX}-undefined_behavior_sanitizer") - add_compile_options(-fsanitize=undefined -DPONY_SANITIZER=\"undefined\") - add_link_options(-fsanitize=undefined -DPONY_SANITIZER=\"undefined\") + list(APPEND PONY_SANITIZERS_ENABLED "undefined") +endif() + +if(PONY_SANITIZERS_ENABLED) + list(JOIN PONY_SANITIZERS_ENABLED "," PONY_SANITIZERS_VALUE) + add_compile_options(-fsanitize=${PONY_SANITIZERS_VALUE} -DPONY_SANITIZER=\"${PONY_SANITIZERS_VALUE}\") + add_link_options(-fsanitize=${PONY_SANITIZERS_VALUE} -DPONY_SANITIZER=\"${PONY_SANITIZERS_VALUE}\") endif() if(PONY_USE_COVERAGE)