CMakeLists.txt revision c3b30b378741f3ec0f4d615ef172b68e1cf97e39
1include_directories(..)
2
3set(LSAN_CFLAGS
4  ${SANITIZER_COMMON_CFLAGS})
5
6set(LSAN_COMMON_SOURCES
7  lsan_common.cc
8  lsan_common_linux.cc)
9
10set(LSAN_SOURCES
11  lsan_interceptors.cc
12  lsan_allocator.cc
13  lsan_thread.cc
14  lsan.cc)
15
16set(LSAN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
17
18# The common files need to build on every arch supported by ASan.
19# (Even if they build into dummy object files.)
20filter_available_targets(LSAN_COMMON_SUPPORTED_ARCH
21  x86_64 i386 powerpc64)
22
23# Architectures supported by the standalone LSan.
24filter_available_targets(LSAN_SUPPORTED_ARCH
25  x86_64)
26
27set(LSAN_RUNTIME_LIBRARIES)
28
29if(APPLE)
30  add_compiler_rt_osx_object_library(RTLSanCommon
31    ARCH ${LSAN_COMMON_SUPPORTED_ARCH}
32    SOURCES ${LSAN_COMMON_SOURCES}
33    CFLAGS ${LSAN_CFLAGS})
34elseif(NOT ANDROID)
35  foreach(arch ${LSAN_COMMON_SUPPORTED_ARCH})
36    add_compiler_rt_object_library(RTLSanCommon ${arch}
37      SOURCES ${LSAN_COMMON_SOURCES}
38      CFLAGS ${LSAN_CFLAGS})
39  endforeach()
40
41  foreach(arch ${LSAN_SUPPORTED_ARCH})
42    add_compiler_rt_static_runtime(clang_rt.lsan-${arch} ${arch}
43      SOURCES ${LSAN_SOURCES}
44              $<TARGET_OBJECTS:RTInterception.${arch}>
45              $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
46              $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
47              $<TARGET_OBJECTS:RTLSanCommon.${arch}>
48      CFLAGS ${LSAN_CFLAGS})
49    list(APPEND LSAN_RUNTIME_LIBRARIES clang_rt.lsan-${arch})
50  endforeach()
51endif()
52
53if (LLVM_INCLUDE_TESTS)
54  add_subdirectory(tests)
55endif()
56add_subdirectory(lit_tests)
57