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
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
set(HAVE_DOC_GENERATOR BUILD_DOCS AND (HAVE_SPHINX OR HAVE_DOXYGEN))
|
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)
|
2014-08-12 03:26:39 +08:00
|
|
|
set(FIXED_ORDER_MODULES core imgproc imgcodecs videoio highgui video calib3d features2d objdetect 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})
|
2013-11-12 23:38:59 +08:00
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
set(DOC_LIST
|
|
|
|
"${OpenCV_SOURCE_DIR}/doc/opencv-logo.png"
|
|
|
|
"${OpenCV_SOURCE_DIR}/doc/opencv-logo2.png"
|
|
|
|
"${OpenCV_SOURCE_DIR}/doc/opencv-logo-white.png"
|
|
|
|
"${OpenCV_SOURCE_DIR}/doc/opencv.ico"
|
|
|
|
"${OpenCV_SOURCE_DIR}/doc/pattern.png"
|
|
|
|
"${OpenCV_SOURCE_DIR}/doc/acircles_pattern.png")
|
|
|
|
set(OPTIONAL_DOC_LIST "")
|
|
|
|
endif(HAVE_DOC_GENERATOR)
|
2013-11-12 23:38:59 +08:00
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
# ========= Sphinx docs =========
|
|
|
|
if(BUILD_DOCS AND HAVE_SPHINX)
|
|
|
|
if(NOT INSTALL_CREATE_DISTRIB)
|
|
|
|
list(APPEND DOC_LIST "${OpenCV_SOURCE_DIR}/doc/haartraining.htm")
|
|
|
|
endif()
|
2012-05-30 22:06:47 +08:00
|
|
|
|
|
|
|
# build lists of documentation files and generate table of contents for reference manual
|
2013-11-12 23:38:59 +08:00
|
|
|
set(DOC_FAKE_ROOT "${CMAKE_CURRENT_BINARY_DIR}/fake-root")
|
|
|
|
set(DOC_FAKE_ROOT_FILES "")
|
2012-05-30 22:06:47 +08:00
|
|
|
|
2013-11-12 23:38:59 +08:00
|
|
|
function(ocv_doc_add_file_to_fake_root source destination)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${DOC_FAKE_ROOT}/${destination}"
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy "${source}" "${DOC_FAKE_ROOT}/${destination}"
|
|
|
|
DEPENDS "${source}"
|
|
|
|
COMMENT "Copying ${destination} to fake root..."
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
list(APPEND DOC_FAKE_ROOT_FILES "${DOC_FAKE_ROOT}/${destination}")
|
|
|
|
set(DOC_FAKE_ROOT_FILES "${DOC_FAKE_ROOT_FILES}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(ocv_doc_add_to_fake_root source)
|
|
|
|
if(ARGC GREATER 1)
|
|
|
|
set(destination "${ARGV1}")
|
|
|
|
else()
|
|
|
|
file(RELATIVE_PATH destination "${OpenCV_SOURCE_DIR}" "${source}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(IS_DIRECTORY "${source}")
|
|
|
|
file(GLOB_RECURSE files RELATIVE "${source}" "${source}/*")
|
|
|
|
|
|
|
|
foreach(file ${files})
|
|
|
|
ocv_doc_add_file_to_fake_root("${source}/${file}" "${destination}/${file}")
|
|
|
|
endforeach()
|
|
|
|
else()
|
|
|
|
ocv_doc_add_file_to_fake_root("${source}" "${destination}")
|
2012-05-30 22:06:47 +08:00
|
|
|
endif()
|
|
|
|
|
2013-11-12 23:38:59 +08:00
|
|
|
set(DOC_FAKE_ROOT_FILES "${DOC_FAKE_ROOT_FILES}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
2012-07-13 21:00:29 +08:00
|
|
|
|
2013-11-12 23:38:59 +08:00
|
|
|
set(OPENCV_REFMAN_TOC "")
|
|
|
|
|
|
|
|
foreach(mod ${BASE_MODULES} ${EXTRA_MODULES})
|
|
|
|
if(EXISTS "${OPENCV_MODULE_opencv_${mod}_LOCATION}/doc/${mod}.rst")
|
|
|
|
ocv_doc_add_to_fake_root("${OPENCV_MODULE_opencv_${mod}_LOCATION}/doc" modules/${mod}/doc)
|
|
|
|
set(OPENCV_REFMAN_TOC "${OPENCV_REFMAN_TOC} ${mod}/doc/${mod}.rst\n")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2012-05-30 22:06:47 +08:00
|
|
|
|
2013-11-12 23:38:59 +08:00
|
|
|
configure_file("${OpenCV_SOURCE_DIR}/modules/refman.rst.in" "${DOC_FAKE_ROOT}/modules/refman.rst" @ONLY)
|
2012-03-03 23:49:23 +08:00
|
|
|
|
2013-11-12 23:38:59 +08:00
|
|
|
ocv_doc_add_to_fake_root("${OpenCV_SOURCE_DIR}/index.rst")
|
|
|
|
ocv_doc_add_to_fake_root("${OpenCV_SOURCE_DIR}/doc")
|
|
|
|
ocv_doc_add_to_fake_root("${OpenCV_SOURCE_DIR}/platforms/android")
|
|
|
|
ocv_doc_add_to_fake_root("${OpenCV_SOURCE_DIR}/samples")
|
2012-03-03 23:49:23 +08:00
|
|
|
|
2013-09-04 22:00:50 +08:00
|
|
|
set(BUILD_PLANTUML "")
|
|
|
|
if(PLANTUML)
|
|
|
|
set(BUILD_PLANTUML "-tplantuml")
|
|
|
|
endif()
|
|
|
|
|
2012-03-03 23:49:23 +08:00
|
|
|
if(PDFLATEX_COMPILER)
|
|
|
|
add_custom_target(docs
|
2013-11-26 19:05:26 +08:00
|
|
|
COMMAND ${SPHINX_BUILD} ${BUILD_PLANTUML} -b latex -c "${CMAKE_CURRENT_SOURCE_DIR}" "${DOC_FAKE_ROOT}" .
|
2012-03-03 23:49:23 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty ${CMAKE_CURRENT_BINARY_DIR}
|
2014-06-30 04:45:24 +08:00
|
|
|
COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2refman.tex
|
|
|
|
COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2manager.tex
|
2013-01-18 22:27:43 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv2refman.pdf"
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2refman.tex
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2refman.tex
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv2manager.pdf"
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2manager.tex
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2manager.tex
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv_user.pdf"
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv_user.tex
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv_user.tex
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv_tutorials.pdf"
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv_tutorials.tex
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv_tutorials.tex
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv_cheatsheet.pdf"
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode "${CMAKE_CURRENT_SOURCE_DIR}/opencv_cheatsheet.tex"
|
|
|
|
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode "${CMAKE_CURRENT_SOURCE_DIR}/opencv_cheatsheet.tex"
|
2013-11-12 23:38:59 +08:00
|
|
|
DEPENDS ${DOC_FAKE_ROOT_FILES}
|
2012-03-03 23:49:23 +08:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
COMMENT "Generating the PDF Manuals"
|
|
|
|
)
|
|
|
|
|
2012-12-08 21:07:55 +08:00
|
|
|
LIST(APPEND OPTIONAL_DOC_LIST "${CMAKE_BINARY_DIR}/doc/opencv2refman.pdf" "${CMAKE_BINARY_DIR}/doc/opencv2manager.pdf"
|
|
|
|
"${CMAKE_BINARY_DIR}/doc/opencv_user.pdf" "${CMAKE_BINARY_DIR}/doc/opencv_tutorials.pdf" "${CMAKE_BINARY_DIR}/doc/opencv_cheatsheet.pdf")
|
|
|
|
|
2012-03-03 23:49:23 +08:00
|
|
|
if(ENABLE_SOLUTION_FOLDERS)
|
|
|
|
set_target_properties(docs PROPERTIES FOLDER "documentation")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_target(html_docs
|
2013-11-26 19:05:26 +08:00
|
|
|
COMMAND "${SPHINX_BUILD}" ${BUILD_PLANTUML} -b html -c "${CMAKE_CURRENT_SOURCE_DIR}" "${DOC_FAKE_ROOT}" ./_html
|
2012-03-03 23:49:23 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty ${CMAKE_CURRENT_BINARY_DIR}
|
2013-11-12 23:38:59 +08:00
|
|
|
DEPENDS ${DOC_FAKE_ROOT_FILES}
|
2012-03-03 23:49:23 +08:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
COMMENT "Generating Online Documentation"
|
|
|
|
)
|
|
|
|
|
|
|
|
if(ENABLE_SOLUTION_FOLDERS)
|
|
|
|
set_target_properties(html_docs PROPERTIES FOLDER "documentation")
|
|
|
|
endif()
|
2012-05-30 22:06:47 +08:00
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# ========= Doxygen docs =========
|
2014-11-21 16:28:14 +08:00
|
|
|
|
|
|
|
macro(make_reference result modules_list black_list)
|
|
|
|
set(_res)
|
|
|
|
foreach(m ${${modules_list}})
|
|
|
|
list(FIND ${black_list} ${m} _pos)
|
|
|
|
if(${_pos} EQUAL -1)
|
|
|
|
set(_res "${_res} @ref ${m} | ${m} \n")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
set(${result} ${_res})
|
|
|
|
endmacro()
|
|
|
|
|
2014-10-09 18:04:00 +08:00
|
|
|
if(BUILD_DOCS AND HAVE_DOXYGEN)
|
2014-11-21 16:28:14 +08:00
|
|
|
# not documented modules list
|
|
|
|
list(APPEND blacklist "ts" "java" "python2" "python3" "world")
|
2014-10-31 23:09:19 +08:00
|
|
|
|
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-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()
|
|
|
|
# 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-10-09 18:04:00 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
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")
|
|
|
|
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_INPUT_LIST "${rootfile} ; ${paths_include} ; ${paths_doc}")
|
|
|
|
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_IMAGE_PATH "${paths_doc}")
|
|
|
|
string(REPLACE ";" " \\\n" CMAKE_DOXYGEN_EXAMPLE_PATH "${CMAKE_SOURCE_DIR}/samples/cpp ; ${paths_doc}")
|
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-11-21 16:28:14 +08:00
|
|
|
set(CMAKE_EXTRA_BIB_FILES "${bibfile} ${paths_bib}")
|
|
|
|
|
|
|
|
# generate references
|
|
|
|
make_reference(CMAKE_DOXYGEN_MAIN_REFERENCE BASE_MODULES blacklist)
|
|
|
|
make_reference(CMAKE_DOXYGEN_EXTRA_REFERENCE EXTRA_MODULES blacklist)
|
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)
|
|
|
|
configure_file(mymath.sty "${CMAKE_DOXYGEN_OUTPUT_PATH}/html/mymath.sty" @ONLY)
|
2014-11-26 19:21:08 +08:00
|
|
|
configure_file(mymath.sty "${CMAKE_DOXYGEN_OUTPUT_PATH}/latex/mymath.sty" @ONLY)
|
2014-10-09 18:04:00 +08:00
|
|
|
|
|
|
|
add_custom_target(doxygen
|
|
|
|
COMMAND ${DOXYGEN_BUILD} ${doxyfile}
|
2014-11-26 19:21:08 +08:00
|
|
|
DEPENDS ${doxyfile} ${rootfile} ${bibfile} ${deps})
|
2014-10-09 18:04:00 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAVE_DOC_GENERATOR)
|
|
|
|
# installation
|
2012-12-08 21:07:55 +08:00
|
|
|
foreach(f ${DOC_LIST})
|
2014-01-17 20:30:31 +08:00
|
|
|
install(FILES "${f}" DESTINATION "${OPENCV_DOC_INSTALL_PATH}" COMPONENT docs)
|
2012-12-08 21:07:55 +08:00
|
|
|
endforeach()
|
|
|
|
foreach(f ${OPTIONAL_DOC_LIST})
|
2014-01-17 20:30:31 +08:00
|
|
|
install(FILES "${f}" DESTINATION "${OPENCV_DOC_INSTALL_PATH}" OPTIONAL COMPONENT docs)
|
2012-12-08 21:07:55 +08:00
|
|
|
endforeach()
|
2014-10-09 18:04:00 +08:00
|
|
|
endif(HAVE_DOC_GENERATOR)
|