[CMake] Make append_if semantics similar to those used in LLVM
[blocksruntime.git] / lib / msan / CMakeLists.txt
blob47795e3c8b05c57f1175b9e6b5a04d41d6bfa59e
1 include_directories(..)
3 # Runtime library sources and build flags.
4 set(MSAN_RTL_SOURCES
5   msan.cc
6   msan_allocator.cc
7   msan_interceptors.cc
8   msan_linux.cc
9   msan_new_delete.cc
10   msan_report.cc
11   )
13 set(MSAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS})
14 append_no_rtti_flag(MSAN_RTL_CFLAGS)
15 append_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE MSAN_RTL_CFLAGS)
16 # Prevent clang from generating libc calls.
17 append_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding MSAN_RTL_CFLAGS)
19 # Static runtime library.
20 add_custom_target(msan)
21 set(arch "x86_64")
22 if(CAN_TARGET_${arch})
23   add_compiler_rt_static_runtime(clang_rt.msan-${arch} ${arch}
24     SOURCES ${MSAN_RTL_SOURCES}
25             $<TARGET_OBJECTS:RTInterception.${arch}>
26             $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
27             $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
28     CFLAGS ${MSAN_RTL_CFLAGS})
29   add_dependencies(msan clang_rt.msan-${arch})
30   if(UNIX)
31     add_sanitizer_rt_symbols(clang_rt.msan-${arch} msan.syms.extra)
32     add_dependencies(msan clang_rt.msan-${arch}-symbols)
33   endif()
34 endif()
36 add_compiler_rt_resource_file(msan_blacklist msan_blacklist.txt)
37 add_dependencies(msan msan_blacklist)
38 add_dependencies(compiler-rt msan)
40 if(COMPILER_RT_INCLUDE_TESTS)
41   add_subdirectory(tests)
42 endif()