Merge pull request #1969 from wasphin/feature/fix-link-flags

cmake: 修正编译链接问题
This commit is contained in:
Xiaofeng Wang 2022-09-20 11:05:57 +08:00 committed by GitHub
commit b35d41b4b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -299,7 +299,7 @@ if(ENABLE_FFMPEG)
endif() endif()
if(ENABLE_MEM_DEBUG) 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") "-Wl,-wrap,free;-Wl,-wrap,malloc;-Wl,-wrap,realloc;-Wl,-wrap,calloc")
update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_MEM_DEBUG) update_cached_list(MK_COMPILE_DEFINITIONS ENABLE_MEM_DEBUG)
message(STATUS "已启用内存调试功能") message(STATUS "已启用内存调试功能")
@ -308,6 +308,10 @@ endif()
if(ENABLE_ASAN) if(ENABLE_ASAN)
list(APPEND COMPILE_OPTIONS_DEFAULT list(APPEND COMPILE_OPTIONS_DEFAULT
"-fsanitize=address;-fno-omit-frame-pointer") "-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") message(STATUS "已启用 Address Sanitize")
endif() endif()
@ -413,6 +417,9 @@ endif()
# for version.h # for version.h
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
# for assert.h
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
add_subdirectory(3rdpart) add_subdirectory(3rdpart)
add_subdirectory(src) add_subdirectory(src)