diff options
Diffstat (limited to 'modules/ECMEnableSanitizers.cmake')
-rw-r--r-- | modules/ECMEnableSanitizers.cmake | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake index 42d5fcb7..84f1819c 100644 --- a/modules/ECMEnableSanitizers.cmake +++ b/modules/ECMEnableSanitizers.cmake @@ -74,7 +74,6 @@ This is an example of usage:: Since 1.3.0. #]=======================================================================] -include(CheckLinkerFlag) # MACRO check_compiler_version #----------------------------- macro (check_compiler_version gcc_required_version clang_required_version msvc_required_version) @@ -148,24 +147,18 @@ if (ECM_ENABLE_SANITIZERS) string(TOLOWER ${CUR_SANITIZER} CUR_SANITIZER) # check option and enable appropriate flags enable_sanitizer_flags ( ${CUR_SANITIZER} ) - check_linker_flag(CXX "-l${XSAN_LINKER_FLAGS}" _HAVE_XSAN_LINKER_FLAGS) - if (_HAVE_XSAN_LINKER_FLAGS) - # TODO: GCC will not link pthread library if enabled ASan - if(CMAKE_C_COMPILER_ID MATCHES "Clang") - string(APPEND CMAKE_C_FLAGS " ${XSAN_COMPILE_FLAGS}") - endif() - string(APPEND CMAKE_CXX_FLAGS " ${XSAN_COMPILE_FLAGS}") - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - link_libraries(${XSAN_LINKER_FLAGS}) - endif() - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # TODO: GCC will not link pthread library if enabled ASan + if(CMAKE_C_COMPILER_ID MATCHES "Clang") + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XSAN_COMPILE_FLAGS}" ) + endif() + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XSAN_COMPILE_FLAGS}" ) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + link_libraries(${XSAN_LINKER_FLAGS}) + endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") string(REPLACE "-Wl,--no-undefined" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") string(REPLACE "-Wl,--no-undefined" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") - endif () - else() - message(STATUS "Tried to enable sanitizers -DECM_ENABLE_SANITIZERS=${ECM_ENABLE_SANITIZERS}, \ -but linker does not have sanitizer support") - endif() + endif () endforeach() else() message(STATUS "Tried to enable sanitizers (-DECM_ENABLE_SANITIZERS=${ECM_ENABLE_SANITIZERS}), \ |