From 1a2f8dc08e2edc2040b821260071187409559619 Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Wed, 26 Mar 2025 15:31:37 +0300 Subject: CMake: Added support for Address Sanitizer To debug possible memory damages --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ce1e91..a0212c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,8 @@ if(WIN32) option(WITH_WINMMDRV "Build a WinMM MIDI driver" OFF) endif() +option(ENABLE_ADDRESS_SANITIZER "Enable the Address Sanitizer GCC feature" OFF) + if(NOT WIN32 AND NOT VITA AND NOT NINTENDO_3DS @@ -417,6 +419,11 @@ function(handle_options targetLib) target_compile_definitions(${targetLib} PRIVATE ADLMIDI_ENABLE_HQ_RESAMPLER) target_link_libraries(${targetLib} PUBLIC ${ZITA_RESAMPLER_LIBRARY}) endif() + + if(ENABLE_ADDRESS_SANITIZER) + target_compile_options(${targetLib} PUBLIC -fsanitize=address) + target_link_options(${targetLib} PUBLIC -fsanitize=address) + endif() endfunction() set(libADLMIDI_SOURCES -- cgit v1.2.3