From 2d783f5df86fa47a59672efe01b3be6cb04800db Mon Sep 17 00:00:00 2001 From: orbea Date: Wed, 9 Oct 2019 17:52:50 -0700 Subject: [PATCH] cmake: Fix ENABLE_ASAN with clang. Only -fsanitize=address is needed for asan to work with both gcc and clang. [170/196] Building CXX object CMakeFiles/vbamcore.dir/src/Util.cpp.o clang-9: warning: -lasan: 'linker' input unused [-Wunused-command-line-argument] [171/196] Linking CXX static library libvbamcore.a [172/196] Generating cmdtab.cpp, cmdhandlers.h, cmd-evtable.h [173/196] Generating wxvbam.xrs [174/196] Generating builtin-xrc.h samu: job failed: cd /tmp/visualboyadvance-m/build/src/wx && /tmp/visualboyadvance-m/build/bin2c wxvbam.xrs builtin-xrc.h builtin_xrs ==4845==Your application is linked against incompatible ASan runtimes. samu: subcommand failed --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0717148f..f7454d86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -495,10 +495,10 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) if(SANITIZER STREQUAL "on" OR SANITIZER STREQUAL "true") set(SANITIZER address) endif() - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "-lasan") - check_cxx_compiler_flag("-fsanitize=${SANITIZER} -lasan" ASAN_SUPPORT_FLAG) + list(PREPEND CMAKE_REQUIRED_LIBRARIES -fsanitize=${SANITIZER}) + check_cxx_compiler_flag("-fsanitize=${SANITIZER}" ASAN_SUPPORT_FLAG) if(${ASAN_SUPPORT_FLAG}) - set(MY_C_DBG_FLAGS ${MY_C_DBG_FLAGS} -fsanitize=${SANITIZER} -lasan) + list(PREPEND MY_C_DBG_FLAGS -fsanitize=${SANITIZER}) else() message(FATAL_ERROR "asan not available to compiler.") endif()