diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index fe895cf1c01c..9deb608a5b00 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -170,49 +170,13 @@ endif() filter_available_targets(SANITIZER_COMMON_SUPPORTED_ARCH x86_64 i386 powerpc64 powerpc) -file(GLOB_RECURSE COMPILER_RT_HEADERS - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include" - "include/*.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 ${COMPILER_RT_HEADERS} ) - set( src ${CMAKE_CURRENT_SOURCE_DIR}/include/${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}) - -# Install compiler-rt headers. -install(DIRECTORY include/ - DESTINATION ${LIBCLANG_INSTALL_PATH}/include - FILES_MATCHING - PATTERN "*.h" - PATTERN ".svn" EXCLUDE - ) - # Add the public header's directory to the includes for all of compiler-rt. include_directories(include) +add_subdirectory(include) + +set(SANITIZER_COMMON_LIT_TEST_DEPS + clang clang-headers FileCheck count not llvm-nm llvm-symbolizer + compiler-rt-headers) add_subdirectory(lib) diff --git a/compiler-rt/include/CMakeLists.txt b/compiler-rt/include/CMakeLists.txt new file mode 100644 index 000000000000..700b5326b06c --- /dev/null +++ b/compiler-rt/include/CMakeLists.txt @@ -0,0 +1,39 @@ +set(SANITIZER_HEADERS + sanitizer/asan_interface.h + sanitizer/common_interface_defs.h + sanitizer/linux_syscall_hooks.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}) + +# Install sanitizer headers. +install(FILES ${SANITIZER_HEADERS} + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + DESTINATION ${LIBCLANG_INSTALL_PATH}/include/sanitizer) diff --git a/compiler-rt/lib/asan/lit_tests/CMakeLists.txt b/compiler-rt/lib/asan/lit_tests/CMakeLists.txt index 1609032d4670..eb033bd3e364 100644 --- a/compiler-rt/lib/asan/lit_tests/CMakeLists.txt +++ b/compiler-rt/lib/asan/lit_tests/CMakeLists.txt @@ -14,9 +14,8 @@ configure_lit_site_cfg( if(COMPILER_RT_CAN_EXECUTE_TESTS) # Run ASan tests only if we're sure we may produce working binaries. set(ASAN_TEST_DEPS - clang clang-headers FileCheck count not llvm-nm llvm-symbolizer - ${ASAN_RUNTIME_LIBRARIES} - ) + ${SANITIZER_COMMON_LIT_TEST_DEPS} + ${ASAN_RUNTIME_LIBRARIES}) set(ASAN_TEST_PARAMS asan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg ) diff --git a/compiler-rt/lib/msan/lit_tests/CMakeLists.txt b/compiler-rt/lib/msan/lit_tests/CMakeLists.txt index 62b21013ba7e..8d419de376ce 100644 --- a/compiler-rt/lib/msan/lit_tests/CMakeLists.txt +++ b/compiler-rt/lib/msan/lit_tests/CMakeLists.txt @@ -14,9 +14,8 @@ configure_lit_site_cfg( if(COMPILER_RT_CAN_EXECUTE_TESTS) # Run MSan tests only if we're sure we may produce working binaries. set(MSAN_TEST_DEPS - clang clang-headers FileCheck count not llvm-nm llvm-symbolizer - ${MSAN_RUNTIME_LIBRARIES} - ) + ${SANITIZER_COMMON_LIT_TEST_DEPS} + ${MSAN_RUNTIME_LIBRARIES}) set(MSAN_TEST_PARAMS msan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg ) diff --git a/compiler-rt/lib/tsan/lit_tests/CMakeLists.txt b/compiler-rt/lib/tsan/lit_tests/CMakeLists.txt index ff2508dd75af..53e5015d1bc4 100644 --- a/compiler-rt/lib/tsan/lit_tests/CMakeLists.txt +++ b/compiler-rt/lib/tsan/lit_tests/CMakeLists.txt @@ -11,9 +11,8 @@ configure_lit_site_cfg( if(COMPILER_RT_CAN_EXECUTE_TESTS) # Run TSan output tests only if we're sure we can produce working binaries. set(TSAN_TEST_DEPS - clang clang-headers FileCheck count not llvm-symbolizer - ${TSAN_RUNTIME_LIBRARIES} - ) + ${SANITIZER_COMMON_LIT_TEST_DEPS} + ${TSAN_RUNTIME_LIBRARIES}) set(TSAN_TEST_PARAMS tsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg ) diff --git a/compiler-rt/lib/ubsan/lit_tests/CMakeLists.txt b/compiler-rt/lib/ubsan/lit_tests/CMakeLists.txt index 565c523ceb49..7e1a13c782d2 100644 --- a/compiler-rt/lib/ubsan/lit_tests/CMakeLists.txt +++ b/compiler-rt/lib/ubsan/lit_tests/CMakeLists.txt @@ -7,9 +7,8 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS) # Run UBSan output tests only if we're sure that clang would produce # working binaries. set(UBSAN_TEST_DEPS - clang clang-headers FileCheck count not - ${UBSAN_RUNTIME_LIBRARIES} - ) + ${SANITIZER_COMMON_LIT_TEST_DEPS} + ${UBSAN_RUNTIME_LIBRARIES}) set(UBSAN_TEST_PARAMS ubsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg )