Skip to content

Commit

Permalink
[cmake] Pass only one sanitizer to TFEL, prefer ASAN.
Browse files Browse the repository at this point in the history
Multiple flags required to be passed whitespace-separated and this
messes up CMake's external project builds. Could not get it to work.
  • Loading branch information
bilke committed Nov 13, 2023
1 parent 45299cd commit 77737e6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions scripts/cmake/DependenciesExternalProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 77737e6

Please sign in to comment.