aboutsummaryrefslogtreecommitdiff
path: root/include/CMakeLists.txt
blob: d8a73872ba445cef46ca148c2e91df0fa284011f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
set(SANITIZER_HEADERS
  sanitizer/asan_interface.h
  sanitizer/common_interface_defs.h
  sanitizer/dfsan_interface.h
  sanitizer/linux_syscall_hooks.h
  sanitizer/lsan_interface.h
  sanitizer/msan_interface.h)

set(output_dir ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION}/include)

if(MSVC_IDE OR XCODE)
   set(other_output_dir ${LLVM_BINARY_DIR}/bin/lib/clang/${CLANG_VERSION}/include)
endif()

# Copy compiler-rt headers to the build tree.
set(out_files)
foreach( f ${SANITIZER_HEADERS} )
  set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} )
  set( dst ${output_dir}/${f} )
  add_custom_command(OUTPUT ${dst}
    DEPENDS ${src}
    COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
    COMMENT "Copying compiler-rt's ${f}...")
  list(APPEND out_files ${dst})

  if(other_output_dir)
   set(other_dst ${other_output_dir}/${f})
    add_custom_command(OUTPUT ${other_dst}
      DEPENDS ${src}
      COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${other_dst}
      COMMENT "Copying compiler-rt's ${f}...")    
    list(APPEND out_files ${other_dst})
  endif()
endforeach( f )

add_custom_target(compiler-rt-headers ALL DEPENDS ${out_files})
add_dependencies(compiler-rt compiler-rt-headers)

# Install sanitizer headers.
install(FILES ${SANITIZER_HEADERS}
  PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
  DESTINATION ${LIBCLANG_INSTALL_PATH}/include/sanitizer)