Skip to content

Commit

Permalink
Merge pull request #29 from aminya/msvc-sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Nov 23, 2021
2 parents 515e279 + 0b42ece commit dc4f03c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Sanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,29 @@ function(
","
LIST_OF_SANITIZERS)

elseif(MSVC)
if(${ENABLE_SANITIZER_ADDRESS})
list(APPEND SANITIZERS "address")
endif()
if(${ENABLE_SANITIZER_LEAK}
OR ${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR}
OR ${ENABLE_SANITIZER_THREAD}
OR ${ENABLE_SANITIZER_MEMORY})
message(WARNING "MSVC only supports address sanitizer")
endif()
endif()

if(LIST_OF_SANITIZERS)
if(NOT
"${LIST_OF_SANITIZERS}"
STREQUAL
"")
target_compile_options(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS})
target_link_options(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS})
if(NOT MSVC)
target_compile_options(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS})
target_link_options(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS})
else()
target_compile_options(${project_name} INTERFACE /fsanitize=${LIST_OF_SANITIZERS} /Zi /INCREMENTAL:NO)
endif()
endif()
endif()

Expand Down

0 comments on commit dc4f03c

Please sign in to comment.