diff --git a/CMakeLists.txt b/CMakeLists.txt index a8243358d6d506eec7248f2363ac5159ac2f298d..83a3e454b909d0f3386b644814221537e23b50b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ option(PYBIND "python binding" ON) option(WERROR "Warning as error" OFF) option(TEST "Enable tests" ON) option(COVERAGE "Enable coverage" OFF) +option(ENABLE_ASAN "Enable ASan (adress sanitizer) for runtime analysis of memory use (over/underflow, memory leak, ...)" OFF) ############################################## # Import utils CMakeLists @@ -54,6 +55,19 @@ target_link_libraries(${module_name} cudnn ) +if( ${ENABLE_ASAN} ) + message("Building ${module_name}Â with ASAN.") + set(SANITIZE_FLAGS -fsanitize=address -fno-omit-frame-pointer) + target_link_libraries(${module_name} + PUBLIC + -fsanitize=address + ) + target_compile_options(${module_name} + PRIVATE + ${SANITIZE_FLAGS} + ) +endif() + if(TEST) target_link_libraries(${module_name} PUBLIC