Krzysztof Parzyszek 11e804fcab [clang-doc] Fix build break with BUILD_SHARED_LIBS=ON
The error message:

/usr/bin/ld: CMakeFiles/clang-doc.dir/ClangDocMain.cpp.o: undefined refe
rence to symbol '_Z20getMustacheHtmlFilesN4llvm9StringRefERN5clang3doc15
ClangDocContextE' /usr/bin/ld: /work/kparzysz/git/llvm.org/b/x86/./lib/l
ibclangDocSupport.so.21.0git: error adding symbols: DSO missing from com
mand line
collect2: error: ld returned 1 exit status
make[2]: *** [tools/clang/tools/extra/clang-doc/tool/CMakeFiles/clang-do
c.dir/build.make:107: bin/clang-doc] Error 1
2025-05-28 08:13:31 -05:00

65 lines
1.5 KiB
CMake

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
add_clang_tool(clang-doc
ClangDocMain.cpp
)
clang_target_link_libraries(clang-doc
PRIVATE
clangAST
clangASTMatchers
clangBasic
clangDocSupport
clangFrontend
clangTooling
clangToolingCore
)
target_link_libraries(clang-doc
PRIVATE
clangDoc
)
set(assets
index.js
mustache-index.js
clang-doc-default-stylesheet.css
clang-doc-mustache.css
class-template.mustache
comment-template.mustache
enum-template.mustache
function-template.mustache
namespace-template.mustache
template.mustache
)
set(asset_dir "${CMAKE_CURRENT_SOURCE_DIR}/../assets")
set(resource_dir "${LLVM_RUNTIME_OUTPUT_INTDIR}/../share/clang-doc")
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_different ${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-doc"
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)