1 include_directories(..) 2 3 set(LSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS}) 4 append_no_rtti_flag(LSAN_CFLAGS) 5 6 set(LSAN_COMMON_SOURCES 7 lsan_common.cc 8 lsan_common_linux.cc) 9 10 set(LSAN_SOURCES 11 lsan.cc 12 lsan_allocator.cc 13 lsan_interceptors.cc 14 lsan_preinit.cc 15 lsan_thread.cc) 16 17 set(LSAN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 18 19 # The common files need to build on every arch supported by ASan. 20 # (Even if they build into dummy object files.) 21 filter_available_targets(LSAN_COMMON_SUPPORTED_ARCH 22 x86_64 i386 powerpc64 arm aarch64 mips) 23 24 add_custom_target(lsan) 25 26 if(APPLE) 27 foreach(os ${SANITIZER_COMMON_SUPPORTED_DARWIN_OS}) 28 add_compiler_rt_darwin_object_library(RTLSanCommon ${os} 29 ARCH ${LSAN_COMMON_SUPPORTED_ARCH} 30 SOURCES ${LSAN_COMMON_SOURCES} 31 CFLAGS ${LSAN_CFLAGS}) 32 endforeach() 33 elseif(NOT ANDROID) 34 foreach(arch ${LSAN_COMMON_SUPPORTED_ARCH}) 35 add_compiler_rt_object_library(RTLSanCommon ${arch} 36 SOURCES ${LSAN_COMMON_SOURCES} 37 CFLAGS ${LSAN_CFLAGS}) 38 endforeach() 39 40 foreach(arch ${LSAN_SUPPORTED_ARCH}) 41 add_compiler_rt_runtime(clang_rt.lsan-${arch} ${arch} STATIC 42 SOURCES ${LSAN_SOURCES} 43 $<TARGET_OBJECTS:RTInterception.${arch}> 44 $<TARGET_OBJECTS:RTSanitizerCommon.${arch}> 45 $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}> 46 $<TARGET_OBJECTS:RTLSanCommon.${arch}> 47 CFLAGS ${LSAN_CFLAGS}) 48 add_dependencies(lsan clang_rt.lsan-${arch}) 49 endforeach() 50 endif() 51 52 add_dependencies(compiler-rt lsan) 53