1 #-----------------------
2 # CMake file for OpenCV docs
3 #-----------------------
5 if(BUILD_DOCS AND DOXYGEN_FOUND)
6 set(HAVE_DOC_GENERATOR TRUE)
8 set(HAVE_DOC_GENERATOR FALSE)
11 if(HAVE_DOC_GENERATOR)
13 # build lists of modules to be documented
17 foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO} ${OPENCV_MODULES_DISABLED_FORCE})
18 string(REGEX REPLACE "^opencv_" "" mod "${mod}")
19 if("${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${OpenCV_SOURCE_DIR}/modules/${mod}")
20 list(APPEND BASE_MODULES ${mod})
22 list(APPEND EXTRA_MODULES ${mod})
25 ocv_list_sort(BASE_MODULES)
26 ocv_list_sort(EXTRA_MODULES)
27 set(FIXED_ORDER_MODULES core imgproc imgcodecs videoio highgui video calib3d features2d objdetect ml flann photo stitching)
28 list(REMOVE_ITEM BASE_MODULES ${FIXED_ORDER_MODULES})
29 set(BASE_MODULES ${FIXED_ORDER_MODULES} ${BASE_MODULES})
30 endif(HAVE_DOC_GENERATOR)
32 # ========= Doxygen docs =========
34 if(BUILD_DOCS AND DOXYGEN_FOUND)
35 # not documented modules list
36 list(APPEND blacklist "ts" "java" "python2" "python3" "world" "contrib_world")
37 unset(CMAKE_DOXYGEN_TUTORIAL_CONTRIB_ROOT)
45 set(paths_hal_interface)
49 foreach(m ${BASE_MODULES} ${EXTRA_MODULES})
50 list(FIND blacklist ${m} _pos)
53 set(header_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/include")
54 if(EXISTS "${header_dir}")
55 list(APPEND paths_include "${header_dir}")
56 list(APPEND deps ${header_dir})
59 set(docs_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/doc")
60 if(EXISTS "${docs_dir}")
61 list(APPEND paths_doc "${docs_dir}")
62 list(APPEND deps ${docs_dir})
65 set(sample_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/samples")
66 if(EXISTS "${sample_dir}")
67 list(APPEND paths_sample "${sample_dir}")
68 list(APPEND deps ${sample_dir})
71 set(tutorial_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/tutorials")
72 if(EXISTS "${tutorial_dir}")
73 list(APPEND paths_tutorial "${tutorial_dir}")
74 list(APPEND deps ${tutorial_dir})
76 # tutorial reference entry
77 file(GLOB tutorials RELATIVE "${OPENCV_MODULE_opencv_${m}_LOCATION}" "${tutorial_dir}/*.markdown")
78 foreach (t ${tutorials})
79 if (NOT DEFINED CMAKE_DOXYGEN_TUTORIAL_CONTRIB_ROOT)
80 set(CMAKE_DOXYGEN_TUTORIAL_CONTRIB_ROOT "- @ref tutorial_contrib_root")
81 set(tutorial_contrib_root "${CMAKE_CURRENT_BINARY_DIR}/contrib_tutorials.markdown")
82 file(WRITE "${tutorial_contrib_root}"
83 "Tutorials for contrib modules {#tutorial_contrib_root}\n"
84 "=============================\n")
86 file(STRINGS "${OPENCV_MODULE_opencv_${m}_LOCATION}/${t}" tutorial_id LIMIT_COUNT 1 REGEX ".*{#[^}]+}")
87 string(REGEX REPLACE ".*{#([^}]+)}" "\\1" tutorial_id "${tutorial_id}")
88 file(APPEND "${tutorial_contrib_root}" "- ${m}. @subpage ${tutorial_id}\n")
91 # HAL replacement file
92 set(replacement_header "${OPENCV_MODULE_opencv_${m}_LOCATION}/src/hal_replacement.hpp")
93 if(EXISTS "${replacement_header}")
94 list(APPEND paths_hal_interface "${replacement_header}")
98 set(bib_file "${docs_dir}/${m}.bib")
99 if(EXISTS "${bib_file}")
100 set(paths_bib "${paths_bib} ${bib_file}")
101 list(APPEND deps ${bib_file})
104 # set(one_ref "@ref ${m} | ${m}\n")
105 set(one_ref "\t- ${m}. @ref ${m}\n")
106 list(FIND EXTRA_MODULES ${m} _pos)
108 set(refs_main "${refs_main}${one_ref}")
110 set(refs_extra "${refs_extra}${one_ref}")
116 # set(ref_header "Module name | Folder\n----------- | ------")
118 # set(refs_main "### Main modules\n${ref_header}\n${refs_main}")
121 # set(refs_extra "### Extra modules\n${ref_header}\n${refs_extra}")
124 set(refs_main "- Main modules:\n${refs_main}")
127 set(refs_extra "- Extra modules:\n${refs_extra}")
131 set(doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
132 set(rootfile "${CMAKE_CURRENT_BINARY_DIR}/root.markdown")
133 set(bibfile "${CMAKE_CURRENT_SOURCE_DIR}/opencv.bib")
134 set(faqfile "${CMAKE_CURRENT_SOURCE_DIR}/faq.markdown")
135 set(tutorial_path "${CMAKE_CURRENT_SOURCE_DIR}/tutorials")
136 set(tutorial_py_path "${CMAKE_CURRENT_SOURCE_DIR}/py_tutorials")
137 set(example_path "${CMAKE_SOURCE_DIR}/samples")
139 # set export variables
140 string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_INPUT_LIST "${rootfile} ; ${faqfile} ; ${paths_include} ; ${paths_hal_interface} ; ${paths_doc} ; ${tutorial_path} ; ${tutorial_py_path} ; ${paths_tutorial} ; ${tutorial_contrib_root}")
141 string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_IMAGE_PATH "${paths_doc} ; ${tutorial_path} ; ${tutorial_py_path} ; ${paths_tutorial}")
142 # TODO: remove paths_doc from EXAMPLE_PATH after face module tutorials/samples moved to separate folders
143 string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_EXAMPLE_PATH "${example_path} ; ${paths_doc} ; ${paths_sample}")
144 set(CMAKE_DOXYGEN_LAYOUT "${CMAKE_CURRENT_SOURCE_DIR}/DoxygenLayout.xml")
145 set(CMAKE_DOXYGEN_OUTPUT_PATH "doxygen")
146 set(CMAKE_DOXYGEN_MAIN_REFERENCE "${refs_main}")
147 set(CMAKE_DOXYGEN_EXTRA_REFERENCE "${refs_extra}")
148 set(CMAKE_EXTRA_BIB_FILES "${bibfile} ${paths_bib}")
149 if (CMAKE_DOXYGEN_GENERATE_QHP)
150 set(CMAKE_DOXYGEN_GENERATE_QHP "YES")
152 set(CMAKE_DOXYGEN_GENERATE_QHP "NO")
155 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/opencv.ico")
156 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/pattern.png")
157 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/acircles_pattern.png")
158 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/bodybg.png")
159 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty")
160 string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_HTML_FILES "${CMAKE_DOXYGEN_HTML_FILES}")
163 set(CMAKE_DOXYGEN_PLANTUML_SUPPORT "PLANTUML_JAR_PATH = ${PLANTUML_JAR}\n")
165 set(CMAKE_DOXYGEN_PLANTUML_SUPPORT "ALIASES += startuml{1}=\"@warning __No plantuml!__ \\n \\n @if DUMMY_PLANTUML_CODE\" enduml=\"@endif\"\n")
169 configure_file(Doxyfile.in ${doxyfile} @ONLY)
170 configure_file(root.markdown.in ${rootfile} @ONLY)
172 add_custom_target(doxygen
173 COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
174 DEPENDS ${doxyfile} ${rootfile} ${bibfile} ${deps}
176 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html
177 DESTINATION "${OPENCV_DOC_INSTALL_PATH}"
178 COMPONENT "docs" OPTIONAL