Index: cfe/trunk/lib/Headers/CMakeLists.txt =================================================================== --- cfe/trunk/lib/Headers/CMakeLists.txt +++ cfe/trunk/lib/Headers/CMakeLists.txt @@ -123,60 +123,51 @@ ) set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include) - -# Generate arm_neon.h -clang_tablegen(arm_neon.h -gen-arm-neon - -I ${CLANG_SOURCE_DIR}/include/clang/Basic/ - SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_neon.td) -# Generate arm_fp16.h -clang_tablegen(arm_fp16.h -gen-arm-fp16 - -I ${CLANG_SOURCE_DIR}/include/clang/Basic/ - SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_fp16.td) - set(out_files) -foreach( f ${files} ${cuda_wrapper_files} ) - set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} ) - set( dst ${output_dir}/${f} ) + +function(copy_header_to_output_dir src_dir file) + set(src ${src_dir}/${file}) + set(dst ${output_dir}/${file}) add_custom_command(OUTPUT ${dst} DEPENDS ${src} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} - COMMENT "Copying clang's ${f}...") + COMMENT "Copying clang's ${file}...") list(APPEND out_files ${dst}) + set(out_files ${out_files} PARENT_SCOPE) +endfunction(copy_header_to_output_dir) + +function(clang_generate_header td_option td_file out_file) + clang_tablegen(${out_file} ${td_option} + -I ${CLANG_SOURCE_DIR}/include/clang/Basic/ + SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/${td_file}) + + copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR} ${out_file}) + set(out_files ${out_files} PARENT_SCOPE) +endfunction(clang_generate_header) + + +# Copy header files from the source directory to the build directory +foreach( f ${files} ${cuda_wrapper_files} ) + copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f}) endforeach( f ) -add_custom_command(OUTPUT ${output_dir}/arm_neon.h - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h ${output_dir}/arm_neon.h - COMMENT "Copying clang's arm_neon.h...") -list(APPEND out_files ${output_dir}/arm_neon.h) -add_custom_command(OUTPUT ${output_dir}/arm_fp16.h - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h ${output_dir}/arm_fp16.h - COMMENT "Copying clang's arm_fp16.h...") -list(APPEND out_files ${output_dir}/arm_fp16.h) +# Generate header files and copy them to the build directory +# Generate arm_neon.h +clang_generate_header(-gen-arm-neon arm_neon.td arm_neon.h) +# Generate arm_fp16.h +clang_generate_header(-gen-arm-fp16 arm_fp16.td arm_fp16.h) add_custom_target(clang-headers ALL DEPENDS ${out_files}) set_target_properties(clang-headers PROPERTIES FOLDER "Misc" RUNTIME_OUTPUT_DIRECTORY "${output_dir}") -install( - FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h - COMPONENT clang-headers - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) - -install( - FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_fp16.h - COMPONENT clang-headers - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include) +set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}) install( - FILES ${cuda_wrapper_files} - COMPONENT clang-headers - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers) + DIRECTORY ${output_dir} + DESTINATION ${header_install_dir} + COMPONENT clang-headers) if (NOT LLVM_ENABLE_IDE) add_llvm_install_targets(install-clang-headers