2 # CMake file for OpenCV docs
5 file(GLOB FILES_DOC *.htm *.txt *.jpg *.png *.pdf)
6 file(GLOB FILES_DOC_VS vidsurv/*.doc)
7 file(GLOB FILES_TEX *.tex *.sty *.bib)
8 file(GLOB FILES_TEX_PICS pics/*.png pics/*.jpg)
10 if(BUILD_DOCS AND HAVE_SPHINX)
14 set(OPENCV2_BASE_MODULES core imgproc highgui video calib3d features2d objdetect ml flann gpu photo stitching nonfree contrib legacy)
16 # build lists of modules to be documented
17 set(OPENCV2_MODULES "")
18 set(OPENCV_MODULES "")
20 foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO} ${OPENCV_MODULES_DISABLED_FORCE})
21 string(REGEX REPLACE "^opencv_" "" mod "${mod}")
22 if("${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${OpenCV_SOURCE_DIR}/modules/${mod}")
23 list(APPEND OPENCV2_MODULES ${mod})
25 list(APPEND OPENCV_MODULES ${mod})
28 list(REMOVE_ITEM OPENCV2_MODULES ${OPENCV2_BASE_MODULES})
29 ocv_list_sort(OPENCV2_MODULES)
30 ocv_list_sort(OPENCV_MODULES)
32 # build lists of documentation files and generate table of contents for reference manual
33 set(OPENCV_FILES_REF "")
34 set(OPENCV_FILES_REF_PICT "")
35 set(OPENCV_REFMAN_TOC "")
37 foreach(mod ${OPENCV2_BASE_MODULES} ${OPENCV2_MODULES} ${OPENCV_MODULES})
38 file(GLOB_RECURSE _OPENCV_FILES_REF "${OPENCV_MODULE_opencv_${mod}_LOCATION}/doc/*.rst")
39 file(GLOB_RECURSE _OPENCV_FILES_REF_PICT "${OPENCV_MODULE_opencv_${mod}_LOCATION}/doc/*.png" "${OPENCV_MODULE_opencv_${mod}_LOCATION}/doc/*.jpg")
40 list(APPEND OPENCV_FILES_REF ${_OPENCV_FILES_REF})
41 list(APPEND OPENCV_FILES_REF_PICT ${_OPENCV_FILES_REF_PICT})
43 set(toc_file "${OPENCV_MODULE_opencv_${mod}_LOCATION}/doc/${mod}.rst")
44 if(EXISTS "${toc_file}")
45 file(RELATIVE_PATH toc_file "${OpenCV_SOURCE_DIR}/modules" "${toc_file}")
46 set(OPENCV_REFMAN_TOC "${OPENCV_REFMAN_TOC} ${toc_file}\r\n")
50 file(GLOB_RECURSE _OPENCV_FILES_REF "${OpenCV_SOURCE_DIR}/android/service/doc/*.rst")
51 file(GLOB_RECURSE _OPENCV_FILES_REF_PICT "${OpenCV_SOURCE_DIR}/android/service/doc/*.png" "${OpenCV_SOURCE_DIR}/android/service/doc/*.jpg")
52 list(APPEND OPENCV_FILES_REF ${_OPENCV_FILES_REF})
53 list(APPEND OPENCV_FILES_REF_PICT ${_OPENCV_FILES_REF_PICT})
55 configure_file("${OpenCV_SOURCE_DIR}/modules/refman.rst.in" "${OpenCV_SOURCE_DIR}/modules/refman.rst" IMMEDIATE @ONLY)
57 file(GLOB_RECURSE OPENCV_FILES_UG user_guide/*.rst)
58 file(GLOB_RECURSE OPENCV_FILES_TUT tutorials/*.rst)
59 file(GLOB_RECURSE OPENCV_FILES_TUT_PICT tutorials/*.png tutorials/*.jpg)
61 set(OPENCV_DOC_DEPS conf.py ${OPENCV_FILES_REF} ${OPENCV_FILES_REF_PICT}
62 ${OPENCV_FILES_UG} ${OPENCV_FILES_TUT} ${OPENCV_FILES_TUT_PICT})
65 add_custom_target(docs
66 COMMAND ${SPHINX_BUILD} -b latex -c ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. .
67 COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/pics ${CMAKE_CURRENT_BINARY_DIR}/doc/opencv1/pics
68 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty ${CMAKE_CURRENT_BINARY_DIR}
69 COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2manager.tex
70 COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex
71 COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex
72 COMMAND ${PDFLATEX_COMPILER} opencv2manager.tex
73 COMMAND ${PDFLATEX_COMPILER} opencv2manager.tex
74 COMMAND ${PDFLATEX_COMPILER} opencv_user.tex
75 COMMAND ${PDFLATEX_COMPILER} opencv_user.tex
76 COMMAND ${PDFLATEX_COMPILER} opencv_tutorials.tex
77 COMMAND ${PDFLATEX_COMPILER} opencv_tutorials.tex
78 DEPENDS ${OPENCV_DOC_DEPS}
79 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
80 COMMENT "Generating the PDF Manuals"
83 if(ENABLE_SOLUTION_FOLDERS)
84 set_target_properties(docs PROPERTIES FOLDER "documentation")
88 add_custom_target(html_docs
89 COMMAND ${SPHINX_BUILD} -b html -c ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ./_html
90 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty ${CMAKE_CURRENT_BINARY_DIR}
91 DEPENDS ${OPENCV_DOC_DEPS}
92 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
93 COMMENT "Generating Online Documentation"
96 if(ENABLE_SOLUTION_FOLDERS)
97 set_target_properties(html_docs PROPERTIES FOLDER "documentation")
101 install(FILES ${FILES_DOC} DESTINATION "${OPENCV_DOC_INSTALL_PATH}" COMPONENT main)
102 install(FILES ${FILES_DOC_VS} DESTINATION "${OPENCV_DOC_INSTALL_PATH}/vidsurv" COMPONENT main)