From c282775205c856f10d8b9b9091db3a7eefec1630 Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Mon, 19 Sep 2022 21:00:48 +0800 Subject: [PATCH 1/3] cmake: fix linking asan --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2fd2e04..94c9042c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,6 +308,10 @@ endif() if(ENABLE_ASAN) list(APPEND COMPILE_OPTIONS_DEFAULT "-fsanitize=address;-fno-omit-frame-pointer") + # https://github.com/google/sanitizers/wiki/AddressSanitizer#using-addresssanitizer + # > In order to use AddressSanitizer you will need to + # > compile and link your program using clang with the -fsanitize=address switch. + update_cached_list(MK_LINK_LIBRARIES "-fsanitize=address") message(STATUS "已启用 Address Sanitize") endif() From 11dfcf3bdbfd11e0f3691e0839eff880cc3cf7c7 Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Mon, 19 Sep 2022 21:02:51 +0800 Subject: [PATCH 2/3] cmake: -Wl linking flags --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94c9042c..416ee8b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,7 +299,7 @@ if(ENABLE_FFMPEG) endif() if(ENABLE_MEM_DEBUG) - list(APPEND COMPILE_OPTIONS_DEFAULT + update_cached_list(MK_LINK_LIBRARIES "-Wl,-wrap,free;-Wl,-wrap,malloc;-Wl,-wrap,realloc;-Wl,-wrap,calloc") update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_MEM_DEBUG) message(STATUS "已启用内存调试功能") From 0c882d4d79c32d4da660db43a0621fd807bdf4ce Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Mon, 19 Sep 2022 21:15:20 +0800 Subject: [PATCH 3/3] cmake: fix include directory for assert.h --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 416ee8b8..cd326292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -417,6 +417,9 @@ endif() # for version.h include_directories(${CMAKE_CURRENT_BINARY_DIR}) +# for assert.h +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty) + add_subdirectory(3rdpart) add_subdirectory(src)