29 lines
879 B
CMake
29 lines
879 B
CMake
function(kubbe_apply_sanitizers target)
|
|
if(KUBBE_SANITIZER STREQUAL "none")
|
|
return()
|
|
endif()
|
|
|
|
if(MSVC)
|
|
message(FATAL_ERROR "Kubbe sanitizer preset '${KUBBE_SANITIZER}' is not configured for MSVC yet")
|
|
endif()
|
|
|
|
if(KUBBE_SANITIZER STREQUAL "address-undefined")
|
|
set(_kubbe_sanitizer_flags
|
|
-fsanitize=address,undefined
|
|
-fno-omit-frame-pointer
|
|
-fno-optimize-sibling-calls
|
|
)
|
|
elseif(KUBBE_SANITIZER STREQUAL "thread")
|
|
set(_kubbe_sanitizer_flags
|
|
-fsanitize=thread
|
|
-fno-omit-frame-pointer
|
|
)
|
|
else()
|
|
message(FATAL_ERROR "Unknown KUBBE_SANITIZER value: ${KUBBE_SANITIZER}")
|
|
endif()
|
|
|
|
target_compile_options(${target} INTERFACE ${_kubbe_sanitizer_flags})
|
|
target_link_options(${target} INTERFACE ${_kubbe_sanitizer_flags})
|
|
endfunction()
|
|
|