diff --git a/scripts/cmake/DependenciesExternalProject.cmake b/scripts/cmake/DependenciesExternalProject.cmake index bdae2ce746d..aab7f18f951 100644 --- a/scripts/cmake/DependenciesExternalProject.cmake +++ b/scripts/cmake/DependenciesExternalProject.cmake @@ -81,17 +81,19 @@ if(OGS_USE_MFRONT) ) endif() + # Only one flag supported, prefer ASAN if(ENABLE_ASAN) - list(APPEND _sanitize_flags -fsanitize=address) + set(_sanitize_flag -fsanitize=address) endif() - if(ENABLE_UBSAN) - list(APPEND _sanitize_flags -fsanitize=undefined) + if(ENABLE_UBSAN AND NOT DEFINED _sanitize_flag) + set(_sanitize_flag -fsanitize=undefined) + elseif(ENABLE_UBSAN AND DEFINED _sanitize_flag) + message(STATUS "MFront: ASAN enabled only! UBSAN is off.") endif() - if(DEFINED _sanitize_flags) - list(JOIN _sanitize_flags " " _sanitize_flags_string) + if(DEFINED _sanitize_flag) foreach(var CXX EXE_LINKER SHARED_LINKER MODULE_LINKER) list(APPEND _tfel_cmake_args - "-DCMAKE_${var}_FLAGS_INIT=${_sanitize_flags_string}" + "-DCMAKE_${var}_FLAGS_INIT=${_sanitize_flag}" ) endforeach() endif() @@ -103,7 +105,7 @@ if(OGS_USE_MFRONT) "-DCMAKE_POSITION_INDEPENDENT_CODE=ON" "-Denable-testing=OFF" ${_defaultCMakeArgs} - ${_tfel_cmake_args} + "${_tfel_cmake_args}" ) message( STATUS