CMakeLists.txt revision 821f21b7cdd0bcc91102f08c8ee0773fd9273046
1# Build for the AddressSanitizer runtime support library.
2
3set(ASAN_SOURCES
4  asan_allocator.cc
5  asan_globals.cc
6  asan_interceptors.cc
7  asan_linux.cc
8  asan_mac.cc
9  asan_malloc_linux.cc
10  asan_malloc_mac.cc
11  asan_malloc_win.cc
12  asan_new_delete.cc
13  asan_poisoning.cc
14  asan_posix.cc
15  asan_printf.cc
16  asan_rtl.cc
17  asan_stack.cc
18  asan_stats.cc
19  asan_thread.cc
20  asan_thread_registry.cc
21  asan_win.cc
22  )
23
24include_directories(..)
25
26set(ASAN_CFLAGS "-fPIC -fno-exceptions -funwind-tables -fvisibility=hidden")
27
28set(ASAN_COMMON_DEFINITIONS
29	ASAN_HAS_EXCEPTIONS=1
30	ASAN_NEEDS_SEGV=1
31  )
32
33if(CAN_TARGET_X86_64)
34  add_library(clang_rt.asan-x86_64 STATIC
35    ${ASAN_SOURCES}
36    $<TARGET_OBJECTS:RTInterception.x86_64>
37    $<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
38    )
39	set_property(TARGET clang_rt.asan-x86_64 PROPERTY COMPILE_FLAGS
40		"${ASAN_CFLAGS} ${TARGET_X86_64_CFLAGS}")
41	set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
42		${ASAN_COMMON_DEFINITIONS})
43endif()
44if(CAN_TARGET_I386)
45  add_library(clang_rt.asan-i386 STATIC
46    ${ASAN_SOURCES}
47    $<TARGET_OBJECTS:RTInterception.i386>
48    $<TARGET_OBJECTS:RTSanitizerCommon.i386>
49    )
50  set_property(TARGET clang_rt.asan-i386 PROPERTY COMPILE_FLAGS
51		"${ASAN_CFLAGS} ${TARGET_I386_CFLAGS}")
52	set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
53		${ASAN_COMMON_DEFINITIONS})
54endif()
55
56if(LLVM_INCLUDE_TESTS)
57  add_subdirectory(tests)
58endif()
59