2014-10-09 18:04:00 +08:00
|
|
|
#-----------------------
|
2010-05-12 01:44:00 +08:00
|
|
|
# CMake file for OpenCV docs
|
2014-10-09 18:04:00 +08:00
|
|
|
#-----------------------
|
2010-05-12 01:44:00 +08:00
|
|
|
|
2015-02-12 21:51:26 +08:00
|
|
|
if(BUILD_DOCS AND DOXYGEN_FOUND)
|
|
|
|
set(HAVE_DOC_GENERATOR TRUE)
|
|
|
|
else()
|
|
|
|
set(HAVE_DOC_GENERATOR FALSE)
|
|
|
|
endif()
|
2010-05-12 01:44:00 +08:00
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
if(HAVE_DOC_GENERATOR)
|
2012-03-03 23:49:23 +08:00
|
|
|
project(opencv_docs)
|
2012-05-30 22:06:47 +08:00
|
|
|
# build lists of modules to be documented
|
2013-11-12 23:38:59 +08:00
|
|
|
set(BASE_MODULES "")
|
|
|
|
set(EXTRA_MODULES "")
|
2012-05-30 22:06:47 +08:00
|
|
|
|
|
|
|
foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO} ${OPENCV_MODULES_DISABLED_FORCE})
|
|
|
|
string(REGEX REPLACE "^opencv_" "" mod "${mod}")
|
|
|
|
if("${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${OpenCV_SOURCE_DIR}/modules/${mod}")
|
2013-11-12 23:38:59 +08:00
|
|
|
list(APPEND BASE_MODULES ${mod})
|
2012-05-30 22:06:47 +08:00
|
|
|
else()
|
2013-11-12 23:38:59 +08:00
|
|
|
list(APPEND EXTRA_MODULES ${mod})
|
2012-05-30 22:06:47 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2014-10-09 18:04:00 +08:00
|
|
|
ocv_list_sort(BASE_MODULES)
|
|
|
|
ocv_list_sort(EXTRA_MODULES)
|
2017-07-31 19:54:28 +08:00
|
|
|
set(FIXED_ORDER_MODULES core imgproc imgcodecs videoio highgui video calib3d features2d objdetect dnn ml flann photo stitching)
|
2013-11-12 23:38:59 +08:00
|
|
|
list(REMOVE_ITEM BASE_MODULES ${FIXED_ORDER_MODULES})
|
2014-10-09 18:04:00 +08:00
|
|
|
set(BASE_MODULES ${FIXED_ORDER_MODULES} ${BASE_MODULES})
|
|
|
|
endif(HAVE_DOC_GENERATOR)
|
2013-11-12 23:38:59 +08:00
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
# ========= Doxygen docs =========
|
2014-11-21 16:28:14 +08:00
|
|
|
|
2014-12-24 23:41:01 +08:00
|
|
|
if(BUILD_DOCS AND DOXYGEN_FOUND)
|
2014-11-21 16:28:14 +08:00
|
|
|
# not documented modules list
|
2017-10-19 22:34:59 +08:00
|
|
|
list(APPEND blacklist "ts" "java" "python2" "python3" "js" "world")
|
2015-08-14 23:05:17 +08:00
|
|
|
unset(CMAKE_DOXYGEN_TUTORIAL_CONTRIB_ROOT)
|
2017-09-25 21:52:07 +08:00
|
|
|
unset(CMAKE_DOXYGEN_TUTORIAL_JS_ROOT)
|
2014-10-31 23:09:19 +08:00
|
|
|
|
2017-10-17 08:07:31 +08:00
|
|
|
set(OPENCV_MATHJAX_RELPATH "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0" CACHE STRING "URI to a MathJax installation")
|
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
# gathering headers
|
2014-11-21 16:28:14 +08:00
|
|
|
set(paths_include)
|
|
|
|
set(paths_doc)
|
|
|
|
set(paths_bib)
|
2014-12-02 00:22:04 +08:00
|
|
|
set(paths_sample)
|
|
|
|
set(paths_tutorial)
|
2016-03-22 21:52:23 +08:00
|
|
|
set(paths_hal_interface)
|
2014-12-02 00:22:04 +08:00
|
|
|
set(refs_main)
|
|
|
|
set(refs_extra)
|
2014-11-26 19:21:08 +08:00
|
|
|
set(deps)
|
2014-11-21 16:28:14 +08:00
|
|
|
foreach(m ${BASE_MODULES} ${EXTRA_MODULES})
|
|
|
|
list(FIND blacklist ${m} _pos)
|
|
|
|
if(${_pos} EQUAL -1)
|
2014-11-26 19:21:08 +08:00
|
|
|
# include folder
|
2014-11-21 16:28:14 +08:00
|
|
|
set(header_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/include")
|
|
|
|
if(EXISTS "${header_dir}")
|
|
|
|
list(APPEND paths_include "${header_dir}")
|
2014-11-26 19:21:08 +08:00
|
|
|
list(APPEND deps ${header_dir})
|
2014-11-21 16:28:14 +08:00
|
|
|
endif()
|
2014-11-26 19:21:08 +08:00
|
|
|
# doc folder
|
2014-11-21 16:28:14 +08:00
|
|
|
set(docs_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/doc")
|
|
|
|
if(EXISTS "${docs_dir}")
|
|
|
|
list(APPEND paths_doc "${docs_dir}")
|
2014-11-26 19:21:08 +08:00
|
|
|
list(APPEND deps ${docs_dir})
|
|
|
|
endif()
|
2014-12-02 00:22:04 +08:00
|
|
|
# sample folder
|
|
|
|
set(sample_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/samples")
|
|
|
|
if(EXISTS "${sample_dir}")
|
|
|
|
list(APPEND paths_sample "${sample_dir}")
|
|
|
|
list(APPEND deps ${sample_dir})
|
|
|
|
endif()
|
|
|
|
# tutorial folder
|
|
|
|
set(tutorial_dir "${OPENCV_MODULE_opencv_${m}_LOCATION}/tutorials")
|
|
|
|
if(EXISTS "${tutorial_dir}")
|
|
|
|
list(APPEND paths_tutorial "${tutorial_dir}")
|
|
|
|
list(APPEND deps ${tutorial_dir})
|
2015-08-14 23:05:17 +08:00
|
|
|
|
|
|
|
# tutorial reference entry
|
|
|
|
file(GLOB tutorials RELATIVE "${OPENCV_MODULE_opencv_${m}_LOCATION}" "${tutorial_dir}/*.markdown")
|
|
|
|
foreach (t ${tutorials})
|
|
|
|
if (NOT DEFINED CMAKE_DOXYGEN_TUTORIAL_CONTRIB_ROOT)
|
|
|
|
set(CMAKE_DOXYGEN_TUTORIAL_CONTRIB_ROOT "- @ref tutorial_contrib_root")
|
|
|
|
set(tutorial_contrib_root "${CMAKE_CURRENT_BINARY_DIR}/contrib_tutorials.markdown")
|
|
|
|
file(WRITE "${tutorial_contrib_root}"
|
|
|
|
"Tutorials for contrib modules {#tutorial_contrib_root}\n"
|
|
|
|
"=============================\n")
|
|
|
|
endif()
|
|
|
|
file(STRINGS "${OPENCV_MODULE_opencv_${m}_LOCATION}/${t}" tutorial_id LIMIT_COUNT 1 REGEX ".*{#[^}]+}")
|
|
|
|
string(REGEX REPLACE ".*{#([^}]+)}" "\\1" tutorial_id "${tutorial_id}")
|
|
|
|
file(APPEND "${tutorial_contrib_root}" "- ${m}. @subpage ${tutorial_id}\n")
|
|
|
|
endforeach()
|
2014-12-02 00:22:04 +08:00
|
|
|
endif()
|
2016-03-22 21:52:23 +08:00
|
|
|
# HAL replacement file
|
|
|
|
set(replacement_header "${OPENCV_MODULE_opencv_${m}_LOCATION}/src/hal_replacement.hpp")
|
|
|
|
if(EXISTS "${replacement_header}")
|
|
|
|
list(APPEND paths_hal_interface "${replacement_header}")
|
|
|
|
endif()
|
2015-08-14 23:05:17 +08:00
|
|
|
|
2014-11-26 19:21:08 +08:00
|
|
|
# BiBTeX file
|
|
|
|
set(bib_file "${docs_dir}/${m}.bib")
|
|
|
|
if(EXISTS "${bib_file}")
|
|
|
|
set(paths_bib "${paths_bib} ${bib_file}")
|
|
|
|
list(APPEND deps ${bib_file})
|
2014-11-21 16:28:14 +08:00
|
|
|
endif()
|
2014-12-02 00:22:04 +08:00
|
|
|
# Reference entry
|
|
|
|
# set(one_ref "@ref ${m} | ${m}\n")
|
|
|
|
set(one_ref "\t- ${m}. @ref ${m}\n")
|
|
|
|
list(FIND EXTRA_MODULES ${m} _pos)
|
|
|
|
if(${_pos} EQUAL -1)
|
|
|
|
set(refs_main "${refs_main}${one_ref}")
|
|
|
|
else()
|
|
|
|
set(refs_extra "${refs_extra}${one_ref}")
|
|
|
|
endif()
|
2014-10-09 18:04:00 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2014-12-02 00:22:04 +08:00
|
|
|
# fix references
|
|
|
|
# set(ref_header "Module name | Folder\n----------- | ------")
|
|
|
|
# if(refs_main)
|
|
|
|
# set(refs_main "### Main modules\n${ref_header}\n${refs_main}")
|
|
|
|
# endif()
|
|
|
|
# if(refs_extra)
|
|
|
|
# set(refs_extra "### Extra modules\n${ref_header}\n${refs_extra}")
|
|
|
|
# endif()
|
|
|
|
if(refs_main)
|
|
|
|
set(refs_main "- Main modules:\n${refs_main}")
|
|
|
|
endif()
|
|
|
|
if(refs_extra)
|
|
|
|
set(refs_extra "- Extra modules:\n${refs_extra}")
|
|
|
|
endif()
|
2014-11-21 16:28:14 +08:00
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
# additional config
|
2014-10-31 23:09:19 +08:00
|
|
|
set(doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
|
|
|
|
set(rootfile "${CMAKE_CURRENT_BINARY_DIR}/root.markdown")
|
2014-11-21 16:28:14 +08:00
|
|
|
set(bibfile "${CMAKE_CURRENT_SOURCE_DIR}/opencv.bib")
|
2014-12-02 00:22:04 +08:00
|
|
|
set(faqfile "${CMAKE_CURRENT_SOURCE_DIR}/faq.markdown")
|
2014-11-27 18:23:24 +08:00
|
|
|
set(tutorial_path "${CMAKE_CURRENT_SOURCE_DIR}/tutorials")
|
2014-11-28 22:18:32 +08:00
|
|
|
set(tutorial_py_path "${CMAKE_CURRENT_SOURCE_DIR}/py_tutorials")
|
2017-09-25 21:52:07 +08:00
|
|
|
set(CMAKE_DOXYGEN_TUTORIAL_JS_ROOT "- @ref tutorial_js_root")
|
|
|
|
set(tutorial_js_path "${CMAKE_CURRENT_SOURCE_DIR}/js_tutorials")
|
2014-12-02 00:22:04 +08:00
|
|
|
set(example_path "${CMAKE_SOURCE_DIR}/samples")
|
|
|
|
|
|
|
|
# set export variables
|
2017-09-25 21:52:07 +08:00
|
|
|
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_INPUT_LIST "${rootfile} ; ${faqfile} ; ${paths_include} ; ${paths_hal_interface} ; ${paths_doc} ; ${tutorial_path} ; ${tutorial_py_path} ; ${tutorial_js_path} ; ${paths_tutorial} ; ${tutorial_contrib_root}")
|
|
|
|
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_IMAGE_PATH "${paths_doc} ; ${tutorial_path} ; ${tutorial_py_path} ; ${tutorial_js_path} ; ${paths_tutorial}")
|
2014-12-02 00:22:04 +08:00
|
|
|
# TODO: remove paths_doc from EXAMPLE_PATH after face module tutorials/samples moved to separate folders
|
|
|
|
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_EXAMPLE_PATH "${example_path} ; ${paths_doc} ; ${paths_sample}")
|
2014-10-09 18:04:00 +08:00
|
|
|
set(CMAKE_DOXYGEN_LAYOUT "${CMAKE_CURRENT_SOURCE_DIR}/DoxygenLayout.xml")
|
|
|
|
set(CMAKE_DOXYGEN_OUTPUT_PATH "doxygen")
|
2014-12-02 00:22:04 +08:00
|
|
|
set(CMAKE_DOXYGEN_MAIN_REFERENCE "${refs_main}")
|
|
|
|
set(CMAKE_DOXYGEN_EXTRA_REFERENCE "${refs_extra}")
|
2014-11-21 16:28:14 +08:00
|
|
|
set(CMAKE_EXTRA_BIB_FILES "${bibfile} ${paths_bib}")
|
2014-12-26 23:39:40 +08:00
|
|
|
if (CMAKE_DOXYGEN_GENERATE_QHP)
|
|
|
|
set(CMAKE_DOXYGEN_GENERATE_QHP "YES")
|
|
|
|
else()
|
|
|
|
set(CMAKE_DOXYGEN_GENERATE_QHP "NO")
|
|
|
|
endif()
|
2014-12-26 22:30:33 +08:00
|
|
|
|
|
|
|
list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/opencv.ico")
|
|
|
|
list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/pattern.png")
|
|
|
|
list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/acircles_pattern.png")
|
|
|
|
list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/bodybg.png")
|
|
|
|
list(APPEND CMAKE_DOXYGEN_HTML_FILES "${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty")
|
|
|
|
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_HTML_FILES "${CMAKE_DOXYGEN_HTML_FILES}")
|
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
# writing file
|
|
|
|
configure_file(Doxyfile.in ${doxyfile} @ONLY)
|
2014-10-31 23:09:19 +08:00
|
|
|
configure_file(root.markdown.in ${rootfile} @ONLY)
|
2014-10-09 18:04:00 +08:00
|
|
|
|
2017-09-25 21:52:07 +08:00
|
|
|
# js tutorial assets
|
|
|
|
set(opencv_tutorial_html_dir "${CMAKE_CURRENT_BINARY_DIR}/doxygen/html")
|
|
|
|
set(js_tutorials_assets_dir "${CMAKE_CURRENT_SOURCE_DIR}/js_tutorials/js_assets")
|
|
|
|
set(js_tutorials_assets_deps "")
|
|
|
|
|
|
|
|
# make sure the build directory exists
|
|
|
|
file(MAKE_DIRECTORY "${opencv_tutorial_html_dir}")
|
|
|
|
|
|
|
|
# gather and copy specific files for js tutorials
|
|
|
|
file(GLOB_RECURSE js_assets "${js_tutorials_assets_dir}/*")
|
|
|
|
ocv_list_filterout(js_assets "\\\\.eslintrc.json")
|
|
|
|
list(APPEND js_assets "${OpenCV_SOURCE_DIR}/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/Data/box.mp4")
|
|
|
|
|
|
|
|
if(BUILD_opencv_js)
|
|
|
|
set(ocv_js_dir "${CMAKE_BINARY_DIR}/bin")
|
|
|
|
set(ocv_js "opencv.js")
|
|
|
|
list(APPEND js_assets "${ocv_js_dir}/${ocv_js}")
|
2017-09-28 00:24:24 +08:00
|
|
|
elseif(DEFINED OPENCV_JS_LOCATION)
|
|
|
|
list(APPEND js_assets "${OPENCV_JS_LOCATION}")
|
2017-09-25 21:52:07 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# copy haar cascade files
|
|
|
|
set(haar_cascade_files "")
|
|
|
|
set(data_harrcascades_path "${OpenCV_SOURCE_DIR}/data/haarcascades/")
|
|
|
|
list(APPEND js_tutorials_assets_deps "${data_harrcascades_path}/haarcascade_frontalface_default.xml" "${data_harrcascades_path}/haarcascade_eye.xml")
|
2017-09-26 13:00:36 +08:00
|
|
|
list(APPEND js_assets "${data_harrcascades_path}/haarcascade_frontalface_default.xml" "${data_harrcascades_path}/haarcascade_eye.xml")
|
2017-09-25 21:52:07 +08:00
|
|
|
|
|
|
|
foreach(f ${js_assets})
|
|
|
|
get_filename_component(fname "${f}" NAME)
|
|
|
|
add_custom_command(OUTPUT "${opencv_tutorial_html_dir}/${fname}"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${f}" "${opencv_tutorial_html_dir}/${fname}"
|
|
|
|
DEPENDS "${f}"
|
|
|
|
COMMENT "Copying ${fname}"
|
|
|
|
)
|
|
|
|
list(APPEND js_tutorials_assets_deps "${f}" "${opencv_tutorial_html_dir}/${fname}")
|
|
|
|
endforeach()
|
|
|
|
|
2017-07-29 03:52:56 +08:00
|
|
|
add_custom_target(doxygen_cpp
|
2014-12-24 23:41:01 +08:00
|
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
|
2017-09-25 21:52:07 +08:00
|
|
|
DEPENDS ${doxyfile} ${rootfile} ${bibfile} ${deps} ${js_tutorials_assets_deps}
|
2014-11-27 18:23:24 +08:00
|
|
|
)
|
2015-03-13 00:14:14 +08:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html
|
|
|
|
DESTINATION "${OPENCV_DOC_INSTALL_PATH}"
|
|
|
|
COMPONENT "docs" OPTIONAL
|
|
|
|
)
|
2016-12-10 01:03:05 +08:00
|
|
|
|
2017-07-29 03:52:56 +08:00
|
|
|
if(BUILD_opencv_python2)
|
|
|
|
add_custom_target(doxygen_python
|
|
|
|
COMMAND ${PYTHON2_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/tools/python_signatures.py" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/html/"
|
|
|
|
DEPENDS doxygen_cpp opencv_python2
|
|
|
|
)
|
|
|
|
add_custom_target(doxygen
|
|
|
|
DEPENDS doxygen_cpp doxygen_python
|
|
|
|
)
|
|
|
|
elseif(BUILD_opencv_python3)
|
|
|
|
add_custom_target(doxygen_python
|
|
|
|
COMMAND ${PYTHON3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/tools/python_signatures.py" "${CMAKE_CURRENT_BINARY_DIR}/doxygen/html/"
|
|
|
|
DEPENDS doxygen_cpp opencv_python3
|
|
|
|
)
|
|
|
|
add_custom_target(doxygen
|
|
|
|
DEPENDS doxygen_cpp doxygen_python
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
add_custom_target(doxygen
|
|
|
|
DEPENDS doxygen_cpp
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2016-12-10 01:03:05 +08:00
|
|
|
# Alias to build/install docs only
|
|
|
|
add_custom_target(install_docs
|
|
|
|
DEPENDS doxygen
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=docs -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
|
|
)
|
2014-10-09 18:04:00 +08:00
|
|
|
endif()
|