Skip to content

Commit

Permalink
CMakeLists.txt: build with sanitizer options
Browse files Browse the repository at this point in the history
  • Loading branch information
franz committed Nov 3, 2023
1 parent 982ffe4 commit db1af99
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,25 @@ endif()

if(ENABLE_ASAN)
set(CLConform_LIBRARIES "asan" ${CLConform_LIBRARIES})
if("${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "6.0.0")
list(APPEND SANITIZER_OPTIONS "-fsanitize=address")
else()
list(APPEND SANITIZER_OPTIONS "-fsanitize=address" "-fsanitize-recover=address")
endif()
list(APPEND SANITIZER_LIBS "asan")
endif()

if(ENABLE_TSAN)
set(CLConform_LIBRARIES "tsan" ${CLConform_LIBRARIES})
list(APPEND SANITIZER_OPTIONS "-fsanitize=thread")
list(APPEND SANITIZER_LIBS "tsan")
endif()

if(ENABLE_ASAN OR ENABLE_TSAN)
set(CLConform_LIBRARIES "${SANITIZER_LIBS}" ${CLConform_LIBRARIES})
if(SANITIZER_OPTIONS)
list(APPEND SANITIZER_OPTIONS "-fno-omit-frame-pointer")
add_compile_options(${SANITIZER_OPTIONS})
endif()
endif()

if(APPLE)
Expand Down

0 comments on commit db1af99

Please sign in to comment.