6dadcc62c9e4055d589f8c0946f0e1e16be7b53d
[profile/ivi/opencv.git] / doc / CMakeLists.txt
1 #
2 #  CMake file for OpenCV docs
3 #
4
5 file(GLOB FILES_DOC *.htm *.txt *.jpg *.png *.pdf)
6 file(GLOB FILES_DOC_PAPERS papers/*.pdf papers/*.ps)
7 file(GLOB FILES_DOC_VS vidsurv/*.doc)
8 file(GLOB FILES_TEX *.tex *.sty *.bib go)
9 file(GLOB FILES_TEX_PICS pics/*.png pics/*.jpg)
10 file(GLOB_RECURSE FILES_PLASTEX plastex/*)
11
12 if(BUILD_LATEX_DOCS AND PDFLATEX_COMPILER)
13         
14 project(opencv_refman)
15
16 set(refman_copied_srcs)
17
18 #foreach(f ${refman_m4_srcs})
19 #    get_filename_component(basef ${f} NAME_WE)
20 #    set(outputf ${CMAKE_CURRENT_BINARY_DIR}/${basef}-c.tex)
21 #    add_custom_command(
22 #        OUTPUT ${outputf}
23 #        DEPENDS ${f}
24 #        COMMAND m4
25 #        ARGS -DTARGET_LANGUAGE=c ${f} > ${outputf}
26 #        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
27 #        VERBATIM
28 #        )
29 #    list(APPEND refman_copied_srcs ${outputf})
30 #endforeach()
31
32 foreach(f ${FILES_TEX})
33     get_filename_component(basef ${f} NAME)
34     set(outputf ${CMAKE_CURRENT_BINARY_DIR}/${basef})
35     add_custom_command(
36         OUTPUT ${outputf}
37         DEPENDS ${f}
38         COMMAND ${CMAKE_COMMAND}
39         ARGS -E copy ${f} ${outputf}
40         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
41     list(APPEND refman_copied_srcs ${outputf})
42 endforeach()
43
44 set(pdflatex_args -interaction=batchmode
45 "\"\\newcommand{\\genc}{true}\\newcommand{\\genpy}{true}\\newcommand{\\targetlang}{c}\\input{opencv.tex}\"")
46
47 add_custom_command(
48   OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/opencv.aux
49   DEPENDS   ${refman_copied_srcs}
50   COMMAND   ${PDFLATEX_COMPILER}
51   ARGS      ${pdflatex_args}
52   COMMENT   "Latex (first pass)"
53   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
54   )
55
56 add_custom_command(
57   OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/opencv.bbl
58   DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/opencv.aux
59   COMMAND   ${BIBTEX_COMPILER}
60   ARGS      ${CMAKE_CURRENT_BINARY_DIR}/opencv
61   COMMENT   "Bibtex"
62   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
63   )
64
65 add_custom_command(
66   OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/opencv.pdf
67   DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/opencv.bbl
68   COMMAND   ${PDFLATEX_COMPILER}
69   ARGS      ${pdflatex_args}
70   COMMENT   "Latex (second pass)"
71   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
72   )
73
74 add_custom_command(
75   OUTPUT    ${CMAKE_CURRENT_BINARY_DIR}/opencv.log
76   DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/opencv.bbl
77             ${CMAKE_CURRENT_BINARY_DIR}/opencv.pdf
78   COMMAND   ${PDFLATEX_COMPILER}
79   ARGS      ${pdflatex_args}
80   COMMENT   "Latex (third pass)"
81   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
82   )
83
84 set(PICS_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/pics")
85 message(STATUS "Copying pictures to the build directory")
86 make_directory(${PICS_OUT_DIR})
87
88 file(GLOB pics RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/pics" pics/*.jpg pics/*.png)
89
90 foreach(p ${pics})
91     configure_file(
92            "pics/${p}"
93            "${PICS_OUT_DIR}/${p}"
94            COPYONLY)
95 endforeach()
96
97 set(PYTHON_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/python_fragments")
98 message(STATUS "Copying python_fragments to the build directory")
99 make_directory(${PYTHON_OUT_DIR})
100
101 file(GLOB python_fragments RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/python_fragments" python_fragments/*.py)
102
103 foreach(p ${python_fragments})
104     configure_file(
105            "python_fragments/${p}"
106            "${PYTHON_OUT_DIR}/${p}"
107            COPYONLY)
108 endforeach()
109
110 #add_custom_target(MakePicsLink
111 #   COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/pics ${CMAKE_CURRENT_BINARY_DIR}/pics
112 #   )
113   
114 # Eventually trigger the whole process
115 add_custom_target(ReferenceManual ALL echo
116    DEPENDS   ${CMAKE_CURRENT_BINARY_DIR}/opencv.log
117    )
118
119 #add_dependencies(ReferenceManual MakePicsLink)
120
121 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/opencv.pdf"
122         DESTINATION "${OPENCV_DOC_INSTALL_PATH}" COMPONENT main)
123         
124 endif() # BUILD_LATEX_DOCS AND PDFLATEX_COMPILER
125         
126 install(FILES ${FILES_DOC} DESTINATION "${OPENCV_DOC_INSTALL_PATH}" COMPONENT main)
127 install(FILES ${FILES_DOC_PAPERS} DESTINATION "${OPENCV_DOC_INSTALL_PATH}/papers" COMPONENT main)
128 install(FILES ${FILES_DOC_VS} DESTINATION "${OPENCV_DOC_INSTALL_PATH}/vidsurv" COMPONENT main)
129
130 ########################################### Doxygen Docs #########################################
131
132 if(BUILD_DOXYGEN_DOCS AND DOXYGEN_FOUND)
133
134 set(DOXYGEN_LANGUAGE "English" CACHE STRING "Language used by doxygen")
135 mark_as_advanced(DOXYGEN_LANGUAGE)
136
137 set(CMAKE_DOXYGEN_IMAGE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pics")
138
139 set(module_names core imgproc calib3d features2d objdetect video highgui ml legacy contrib)
140 set(DOXYGEN_SOURCE_DIR)
141 set(doxy_html_dep_list)
142
143 foreach(m ${module_names})
144     set(module_hdr_path "${CMAKE_SOURCE_DIR}/modules/${m}/include/opencv2/${m}")
145     set(DOXYGEN_SOURCE_DIR ${DOXYGEN_SOURCE_DIR} ${module_hdr_path})
146     file(GLOB module_hdrs "${module_hdr_path}/*.h*")
147     set(doxy_html_dep_list ${doxy_html_dep_list} ${module_hdrs})
148 endforeach()
149
150 set(DOXYGEN_OUTPUT_DIR html)
151 string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${DOXYGEN_SOURCE_DIR}")
152
153 configure_file(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
154 set(HTML_TARGET "DOXY_HTML" )
155
156 add_custom_target(${HTML_TARGET} ALL
157         ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
158         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${doxy_html_dep_list})
159 exec_program(mkdir ARGS "-p \"${CMAKE_CURRENT_BINARY_DIR}/html/\"")
160 install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html" DESTINATION "${OPENCV_DOC_INSTALL_PATH}/html" COMPONENT main)
161
162 endif()
163