CMakeLists.txt revision 6ebe45146a2d93eb010b9bb5ea34cb94c6900f83
1# Build for the undefined behavior sanitizer runtime support library.
2
3set(UBSAN_SOURCES
4  ubsan_diag.cc
5  ubsan_handlers.cc
6  ubsan_value.cc
7  )
8
9include_directories(..)
10
11set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
12
13set(UBSAN_RUNTIME_LIBRARIES)
14
15if(CAN_TARGET_X86_64)
16  add_library(clang_rt.ubsan-x86_64 STATIC ${UBSAN_SOURCES})
17  set_target_compile_flags(clang_rt.ubsan-x86_64
18    ${UBSAN_CFLAGS} ${TARGET_X86_64_CFLAGS}
19    )
20  list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan-x86_64)
21endif()
22
23if(CAN_TARGET_I386)
24  add_library(clang_rt.ubsan-i386 STATIC ${UBSAN_SOURCES})
25  set_target_compile_flags(clang_rt.ubsan-i386
26    ${UBSAN_CFLAGS} ${TARGET_I386_CFLAGS}
27    )
28  list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan-i386)
29endif()
30
31set_property(TARGET ${UBSAN_RUNTIME_LIBRARIES} APPEND PROPERTY
32  COMPILE_DEFINITIONS ${UBSAN_COMMON_DEFINITIONS})
33add_clang_compiler_rt_libraries(${UBSAN_RUNTIME_LIBRARIES})
34
35add_subdirectory(lit_tests)
36