1#----------------------- 2# CMake file for OpenCV docs 3#----------------------- 4 5if(BUILD_DOCS AND DOXYGEN_FOUND) 6 set(HAVE_DOC_GENERATOR TRUE) 7else() 8 set(HAVE_DOC_GENERATOR FALSE) 9endif() 10 11if(HAVE_DOC_GENERATOR) 12 project(opencv_docs) 13 # build lists of modules to be documented 14 set(BASE_MODULES "") 15 set(EXTRA_MODULES "") 16 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}) 21 else() 22 list(APPEND EXTRA_MODULES ${mod}) 23 endif() 24 endforeach() 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}) 30endif(HAVE_DOC_GENERATOR) 31 32# ========= Doxygen docs ========= 33 34if(BUILD_DOCS AND DOXYGEN_FOUND) 35 # not documented modules list 36 list(APPEND blacklist "ts" "java" "python2" "python3" "world" "contrib_world") 37 38 # gathering headers 39 set(paths_include) 40 set(paths_doc) 41 set(paths_bib) 42 set(paths_sample) 43 set(paths_tutorial) 44 set(refs_main) 45 set(refs_extra) 46 set(deps) 47 foreach(m ${BASE_MODULES} ${EXTRA_MODULES}) 48 list(FIND blacklist ${m} _pos) 49 if(${_pos} EQUAL -1) 50 # include folder 51 set(header_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/include") 52 if(EXISTS "${header_dir}") 53 list(APPEND paths_include "${header_dir}") 54 list(APPEND deps ${header_dir}) 55 endif() 56 # doc folder 57 set(docs_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/doc") 58 if(EXISTS "${docs_dir}") 59 list(APPEND paths_doc "${docs_dir}") 60 list(APPEND deps ${docs_dir}) 61 endif() 62 # sample folder 63 set(sample_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/samples") 64 if(EXISTS "${sample_dir}") 65 list(APPEND paths_sample "${sample_dir}") 66 list(APPEND deps ${sample_dir}) 67 endif() 68 # tutorial folder 69 set(tutorial_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/tutorials") 70 if(EXISTS "${tutorial_dir}") 71 list(APPEND paths_tutorial "${tutorial_dir}") 72 list(APPEND deps ${tutorial_dir}) 73 endif() 74 # BiBTeX file 75 set(bib_file "${docs_dir}/${m}.bib") 76 if(EXISTS "${bib_file}") 77 set(paths_bib "${paths_bib} ${bib_file}") 78 list(APPEND deps ${bib_file}) 79 endif() 80 # Reference entry 81 # set(one_ref "@ref ${m} | ${m}\n") 82 set(one_ref "\t- ${m}. @ref ${m}\n") 83 list(FIND EXTRA_MODULES ${m} _pos) 84 if(${_pos} EQUAL -1) 85 set(refs_main "${refs_main}${one_ref}") 86 else() 87 set(refs_extra "${refs_extra}${one_ref}") 88 endif() 89 endif() 90 endforeach() 91 92 # fix references 93 # set(ref_header "Module name | Folder\n----------- | ------") 94 # if(refs_main) 95 # set(refs_main "### Main modules\n${ref_header}\n${refs_main}") 96 # endif() 97 # if(refs_extra) 98 # set(refs_extra "### Extra modules\n${ref_header}\n${refs_extra}") 99 # endif() 100 if(refs_main) 101 set(refs_main "- Main modules:\n${refs_main}") 102 endif() 103 if(refs_extra) 104 set(refs_extra "- Extra modules:\n${refs_extra}") 105 endif() 106 107 # additional config 108 set(doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile") 109 set(rootfile "${CMAKE_CURRENT_BINARY_DIR}/root.markdown") 110 set(bibfile "${CMAKE_CURRENT_SOURCE_DIR}/opencv.bib") 111 set(faqfile "${CMAKE_CURRENT_SOURCE_DIR}/faq.markdown") 112 set(tutorial_path "${CMAKE_CURRENT_SOURCE_DIR}/tutorials") 113 set(tutorial_py_path "${CMAKE_CURRENT_SOURCE_DIR}/py_tutorials") 114 set(example_path "${CMAKE_SOURCE_DIR}/samples") 115 116 # set export variables 117 string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_INPUT_LIST "${rootfile} ; ${faqfile} ; ${paths_include} ; ${paths_doc} ; ${tutorial_path} ; ${tutorial_py_path} ; ${paths_tutorial}") 118 string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_IMAGE_PATH "${paths_doc} ; ${tutorial_path} ; ${tutorial_py_path} ; ${paths_tutorial}") 119 # TODO: remove paths_doc from EXAMPLE_PATH after face module tutorials/samples moved to separate folders 120 string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_EXAMPLE_PATH "${example_path} ; ${paths_doc} ; ${paths_sample}") 121 set(CMAKE_DOXYGEN_LAYOUT "${CMAKE_CURRENT_SOURCE_DIR}/DoxygenLayout.xml") 122 set(CMAKE_DOXYGEN_OUTPUT_PATH "doxygen") 123 set(CMAKE_DOXYGEN_MAIN_REFERENCE "${refs_main}") 124 set(CMAKE_DOXYGEN_EXTRA_REFERENCE "${refs_extra}") 125 set(CMAKE_EXTRA_BIB_FILES "${bibfile} ${paths_bib}") 126 if (CMAKE_DOXYGEN_GENERATE_QHP) 127 set(CMAKE_DOXYGEN_GENERATE_QHP "YES") 128 else() 129 set(CMAKE_DOXYGEN_GENERATE_QHP "NO") 130 endif() 131 132 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/opencv.ico") 133 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/pattern.png") 134 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/acircles_pattern.png") 135 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/bodybg.png") 136 list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty") 137 string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_HTML_FILES "${CMAKE_DOXYGEN_HTML_FILES}") 138 139 if(PLANTUML_JAR) 140 set(CMAKE_DOXYGEN_PLANTUML_SUPPORT "PLANTUML_JAR_PATH = ${PLANTUML_JAR}\n") 141 else() 142 set(CMAKE_DOXYGEN_PLANTUML_SUPPORT "ALIASES += startuml{1}=\"@warning __No plantuml!__ \\n \\n @if DUMMY_PLANTUML_CODE\" enduml=\"@endif\"\n") 143 endif() 144 145 # writing file 146 configure_file(Doxyfile.in ${doxyfile} @ONLY) 147 configure_file(root.markdown.in ${rootfile} @ONLY) 148 149 add_custom_target(doxygen 150 COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} 151 DEPENDS ${doxyfile} ${rootfile} ${bibfile} ${deps} 152 ) 153 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html 154 DESTINATION "${OPENCV_DOC_INSTALL_PATH}" 155 COMPONENT "docs" OPTIONAL 156 ) 157endif() 158