Skip to content

Commit 7c0e5a6

Browse files
committed
[doc]: Conditionally add ocaml_doc to ALL target
Add the ocaml_doc target to the default ALL build target, but only when LLVM_BUILD_DOCS is enabled. This addresses two issues: 1. It prevents the 'install' target from failing due to a missing ocamldoc output directory by ensuring docs are generated beforehand. 2. It avoids unnecessary build steps when documentation is not required (LLVM_BUILD_DOCS is OFF), saving build time.
1 parent 24c5926 commit 7c0e5a6

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

llvm/docs/CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,19 @@ if( NOT uses_ocaml LESS 0 AND LLVM_ENABLE_OCAMLDOC )
136136
list(APPEND odoc_files -load ${odoc_file})
137137
endforeach()
138138

139-
add_custom_target(ocaml_doc
140-
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
141-
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
142-
COMMAND ${OCAMLFIND} ocamldoc -d ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
143-
-sort -colorize-code -html ${odoc_files}
144-
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/_ocamldoc/style.css
145-
${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html)
139+
if(LLVM_BUILD_DOCS)
140+
add_custom_target(ocaml_doc ${OCAML_DOC_ADD_TO_ALL}
141+
COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
142+
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
143+
COMMAND ${OCAMLFIND} ocamldoc -d ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
144+
-sort -colorize-code -html ${odoc_files}
145+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/_ocamldoc/style.css
146+
${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html)
147+
add_dependencies(ocaml_doc ${doc_targets})
148+
endif()
146149

147-
add_dependencies(ocaml_doc ${doc_targets})
148150

149-
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
151+
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY AND LLVM_BUILD_DOCS)
150152
# ./ suffix is needed to copy the contents of html directory without
151153
# appending html/ into LLVM_INSTALL_OCAMLDOC_HTML_DIR.
152154
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html/.

0 commit comments

Comments
 (0)