[flang][docs] Fix cmake warning when building documentation

CMake issues the following warning when configuring with 
documentation enabled.

Exactly one of PRE_BUILD, PRE_LINK, or POST_BUILD must be given.
Assuming
    POST_BUILD to preserve backward compatibility.

The offending add_custom_command call in flang/docs/CMakeLists.txt has
been fixed to ensure that this warning is not issued. The comment
describing the purpose of the command now provides more details.
This commit is contained in:
Tarun Prabhu 2026-01-14 11:24:37 -07:00 committed by GitHub
parent ef0680ba54
commit c205aa2257
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -129,11 +129,16 @@ if (LLVM_ENABLE_SPHINX)
"${FLANG_DOCS_HTML_DIR}/FlangCommandLineReference.rst"
DEPENDS flang-doc gen-FlangCommandLineReference.rst)
# Run Python preprocessing ONLY for HTML build
# This script prepends headers to FIRLangRef.md for proper formatting
add_custom_command(TARGET copy-flang-src-docs-html
# ${CMAKE_CURRENT_BINARY_DIR}/Dialect/FIRLangRef.md is generated by
# mlir-tblgen. The script executed in the command below adds some text to
# this document providing a brief overview of its contents in order to
# make it a bit more user-friendly. The result is written to
# ${FLANG_DOCS_HTML_DIR}/FIRLangRef.md. The original file in
# ${CMAKE_CURRENT_BINARY_DIR}/Dialect is *not* modified.
add_custom_command(TARGET copy-flang-src-docs-html POST_BUILD
COMMAND "${Python3_EXECUTABLE}"
ARGS "${FLANG_DOCS_HTML_DIR}/FIR/CreateFIRLangRef.py")
ARGS "${FLANG_DOCS_HTML_DIR}/FIR/CreateFIRLangRef.py"
BYPRODUCTS ${FLANG_DOCS_HTML_DIR}/FIRLangRef.md)
add_sphinx_target(html flang SOURCE_DIR "${FLANG_DOCS_HTML_DIR}")
add_dependencies(docs-flang-html copy-flang-src-docs-html)