diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index eaa175062b61..f862f2561bfd 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -143,13 +143,15 @@ if( NOT uses_ocaml LESS 0 )
     list(APPEND odoc_files -load ${odoc_file})
   endforeach()
 
-  add_custom_target(ocaml_doc
+  add_custom_command(OUTPUT BUILD_OCAML_DOCS
     COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
     COMMAND ${OCAMLFIND} ocamldoc -d ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
                                   -sort -colorize-code -html ${odoc_files}
     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/_ocamldoc/style.css
-                                     ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html)
+                                     ${CMAKE_CURRENT_BINARY_DIR}/ocamldoc/html
+    COMMENT "Creating documentation for OCaml bindings...")
+  add_custom_target(ocaml_doc ALL DEPENDS BUILD_OCAML_DOCS)
 
   add_dependencies(ocaml_doc ${doc_targets})
 
