Skip to content

Commit

Permalink
Allow multiple sanitizers to be enabled at the same time (#4538)
Browse files Browse the repository at this point in the history
  • Loading branch information
dipinhora authored Nov 22, 2024
1 parent 6222d09 commit 0533298
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0533298

Please sign in to comment.