Author: Paul Kirth Date: 2024-06-14T11:35:19-07:00 New Revision: ade28a77ed17760bf2fde57c6571b69489b0bac0
URL: https://github.com/llvm/llvm-project/commit/ade28a77ed17760bf2fde57c6571b69489b0bac0 DIFF: https://github.com/llvm/llvm-project/commit/ade28a77ed17760bf2fde57c6571b69489b0bac0.diff LOG: [clang-doc][cmake] Copy assets to build directory (#95187) While we copy the asset files, like index.js, into the correct location in the install step, tests do not have access to those resources in the build directory. This patch copies the contents of the clang-doc/assets directory into the build folder, so that they can be used in testing. Pull Request: https://github.com/llvm/llvm-project/pull/95185 Added: Modified: clang-tools-extra/clang-doc/tool/CMakeLists.txt Removed: ################################################################################ diff --git a/clang-tools-extra/clang-doc/tool/CMakeLists.txt b/clang-tools-extra/clang-doc/tool/CMakeLists.txt index fb8317b272932..4944251245c6b 100644 --- a/clang-tools-extra/clang-doc/tool/CMakeLists.txt +++ b/clang-tools-extra/clang-doc/tool/CMakeLists.txt @@ -18,10 +18,38 @@ target_link_libraries(clang-doc clangDoc ) -install(FILES ../assets/clang-doc-default-stylesheet.css - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" - COMPONENT clang-doc) -install(FILES ../assets/index.js - DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" - COMPONENT clang-doc) +set(assets + index.js + clang-doc-default-stylesheet.css +) + +set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets") +set(resource_dir "${CMAKE_BINARY_DIR}/share/clang") +set(out_files) + +function(copy_files_to_dst src_dir dst_dir file) + set(src "${src_dir}/${file}") + set(dst "${dst_dir}/${file}") + add_custom_command(OUTPUT ${dst} + DEPENDS ${src} + COMMAND ${CMAKE_COMMAND} -E copy_if_ diff erent ${src} ${dst} + COMMENT "Copying ${file} to ${dst_dir}" + ) + list(APPEND out_files ${dst}) + set(out_files ${out_files} PARENT_SCOPE) +endfunction(copy_files_to_dst) + +foreach(f ${assets}) + install(FILES ${asset_dir}/${f} + DESTINATION "${CMAKE_INSTALL_DATADIR}/clang" + COMPONENT clang-doc) + copy_files_to_dst(${asset_dir} ${resource_dir} ${f}) +endforeach(f) + +add_custom_target(copy-clang-doc-assets + DEPENDS ${out_files} + COMMENT "Copying Clang-Doc Assets" +) +set_target_properties(copy-clang-doc-assets PROPERTIES FOLDER "Clang-Doc/Assets") +add_dependencies(clang-doc copy-clang-doc-assets) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits