mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-12-26 11:17:44 +01:00
[cmake]: Add option for Address Sanitizer check
Change-Id: I91cf9111000d2e077dafd9871b965e864863e0bf Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
parent
c56c01494d
commit
0abeafe872
5 changed files with 16 additions and 4 deletions
|
|
@ -172,6 +172,13 @@ if(GCC)
|
|||
# for libary linking
|
||||
set(BEGIN_WHOLE_ARCHIVE -Wl,--whole-archive)
|
||||
set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive)
|
||||
|
||||
option(ASAN_CHECK "enable Address Sanitizer (Asan)" OFF)
|
||||
if(ASAN_CHECK)
|
||||
add_definitions(-fsanitize=address -static-libasan -g)
|
||||
set(ASAN_LIB libasan.a dl rt m)
|
||||
set(ASAN_BIN dl rt m)
|
||||
endif(ASAN_CHECK)
|
||||
endif(GCC)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ set(MPP_ABI_VERSION "1")
|
|||
add_library(${MPP_SHARED} SHARED ${MPP_SRC})
|
||||
set_target_properties(${MPP_SHARED} PROPERTIES FOLDER "mpp")
|
||||
set_target_properties(${MPP_SHARED} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
target_link_libraries(${MPP_SHARED} mpp_codec mpp_hal mpp_vproc
|
||||
target_link_libraries(${MPP_SHARED} mpp_codec mpp_hal mpp_vproc ${ASAN_LIB}
|
||||
${BEGIN_WHOLE_ARCHIVE} mpp_base ${END_WHOLE_ARCHIVE})
|
||||
set_target_properties(${MPP_SHARED} PROPERTIES C_VISIBILITY_PRESET default)
|
||||
set_target_properties(${MPP_SHARED} PROPERTIES CXX_VISIBILITY_PRESET default)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ macro(add_mpp_rc_test module)
|
|||
option(${test_tag} "Build rc ${module} unit test" ON)
|
||||
if(${test_tag})
|
||||
add_executable(${test_name} ${test_name}.c)
|
||||
target_link_libraries(${test_name} enc_rc mpp_base)
|
||||
target_link_libraries(${test_name} enc_rc mpp_base ${ASAN_LIB})
|
||||
set_target_properties(${test_name} PROPERTIES FOLDER "osal/test")
|
||||
add_test(NAME ${test_name} COMMAND ${test_name})
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ set_target_properties(${VPU_SHARED} PROPERTIES SOVERSION ${MPP_ABI_VERSION})
|
|||
endif()
|
||||
|
||||
# force dynamic link
|
||||
target_link_libraries(${VPU_SHARED} -Wl,-Bdynamic dl lib${MPP_SHARED}.so)
|
||||
target_link_libraries(${VPU_SHARED} ${ASAN_LIB}
|
||||
-Wl,-Bdynamic dl lib${MPP_SHARED}.so)
|
||||
|
||||
install(TARGETS ${VPU_SHARED} LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
|
|
|||
|
|
@ -57,7 +57,11 @@ macro(add_legacy_test module)
|
|||
option(${test_tag} "Build legacy ${module} unit test" ON)
|
||||
if(${test_tag})
|
||||
add_executable(${test_name} ${test_name}.c)
|
||||
target_link_libraries(${test_name} dl)
|
||||
if(ASAN_CHECK)
|
||||
target_link_libraries(${test_name} ${ASAN_LIB} pthread dl)
|
||||
else(ASAN_CHECK)
|
||||
target_link_libraries(${test_name} dl)
|
||||
endif(ASAN_CHECK)
|
||||
set_target_properties(${test_name} PROPERTIES FOLDER "test")
|
||||
install(TARGETS ${test_name} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue