diff --git a/flang/docs/CMakeLists.txt b/flang/docs/CMakeLists.txt --- a/flang/docs/CMakeLists.txt +++ b/flang/docs/CMakeLists.txt @@ -95,7 +95,28 @@ include(AddSphinxTarget) if (SPHINX_FOUND) if (${SPHINX_OUTPUT_HTML}) - add_sphinx_target(html flang) + add_sphinx_target(html flang SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/Source") + + add_dependencies(docs-flang-html copy-flang-src-docs) + add_dependencies(docs-flang-html flang-doc) + + # Copies flang/docs/ to binary directory + # Sphinx requires all files to be in the same directory + # in order to process them into HTML, since FIRLangRef.md + # doesn't exist in src, the non-generated .md files need to be + # copied to the bin directory. + add_custom_target(copy-flang-src-docs + COMMAND "${CMAKE_COMMAND}" -E copy_directory + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}/Source") + + # Copies FIRLangRef into the same directory as the + # other .md files, so sphinx can use them + add_custom_command(TARGET docs-flang-html POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy + "${CMAKE_CURRENT_BINARY_DIR}/Dialect/FIRLangRef.md" + "${CMAKE_CURRENT_BINARY_DIR}/Source/FIRLangRef.md") + endif() if (${SPHINX_OUTPUT_MAN}) add_sphinx_target(man flang) diff --git a/flang/docs/_templates/indexsidebar.html b/flang/docs/_templates/indexsidebar.html --- a/flang/docs/_templates/indexsidebar.html +++ b/flang/docs/_templates/indexsidebar.html @@ -5,6 +5,7 @@