From 39113c12046b7ed39e96e2146d87b024f604f1ca Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Tue, 7 Nov 2023 10:49:28 +0100 Subject: [PATCH] [cmake] Enable address and undef. beh. sanitizer for tfel. --- scripts/cmake/DependenciesExternalProject.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/cmake/DependenciesExternalProject.cmake b/scripts/cmake/DependenciesExternalProject.cmake index df4942d2676..bdae2ce746d 100644 --- a/scripts/cmake/DependenciesExternalProject.cmake +++ b/scripts/cmake/DependenciesExternalProject.cmake @@ -80,6 +80,22 @@ if(OGS_USE_MFRONT) "TFEL Python bindings disabled as Boosts Python library was not found." ) endif() + + if(ENABLE_ASAN) + list(APPEND _sanitize_flags -fsanitize=address) + endif() + if(ENABLE_UBSAN) + list(APPEND _sanitize_flags -fsanitize=undefined) + endif() + if(DEFINED _sanitize_flags) + list(JOIN _sanitize_flags " " _sanitize_flags_string) + foreach(var CXX EXE_LINKER SHARED_LINKER MODULE_LINKER) + list(APPEND _tfel_cmake_args + "-DCMAKE_${var}_FLAGS_INIT=${_sanitize_flags_string}" + ) + endforeach() + endif() + BuildExternalProject( TFEL ${_tfel_source} CMAKE_ARGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"