From 77737e6ba2cd975ba78ad647a6353dcdda5a1eb0 Mon Sep 17 00:00:00 2001 From: Lars Bilke Date: Tue, 7 Nov 2023 11:47:50 +0100 Subject: [PATCH] [cmake] Pass only one sanitizer to TFEL, prefer ASAN. Multiple flags required to be passed whitespace-separated and this messes up CMake's external project builds. Could not get it to work. --- scripts/cmake/DependenciesExternalProject.cmake | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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