Add a new QtGstreamerUi library that contains a VideoWidget class, a widget that...
[qtgstreamer:qtgstreamer.git] / cmake / modules / UseDoxygen.cmake
1 # - Run Doxygen
2 #
3 # Adds a doxygen target that runs doxygen to generate the html
4 # and optionally the LaTeX API documentation.
5 # The doxygen target is added to the doc target as dependency.
6 # i.e.: the API documentation is built with:
7 #  make doc
8 #
9 # USAGE: GLOBAL INSTALL
10 #
11 # Install it with:
12 #  cmake ./ && sudo make install
13 # Add the following to the CMakeLists.txt of your project:
14 #  include(UseDoxygen OPTIONAL)
15 # Optionally copy Doxyfile.in in the directory of CMakeLists.txt and edit it.
16 #
17 # USAGE: INCLUDE IN PROJECT
18 #
19 #  set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
20 #  include(UseDoxygen)
21 # Add the Doxyfile.in and UseDoxygen.cmake files to the projects source directory.
22 #
23 #
24 # Variables you may define are:
25 #  DOXYFILE_OUTPUT_DIR - Path where the Doxygen output is stored. Defaults to "doc".
26 #
27 #  DOXYFILE_LATEX_DIR - Directory where the Doxygen LaTeX output is stored. Defaults to "latex".
28 #
29 #  DOXYFILE_HTML_DIR - Directory where the Doxygen html output is stored. Defaults to "html".
30 #
31
32 #
33 #  Copyright (c) 2009, 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
34 #
35 #  Redistribution and use is allowed according to the terms of the New
36 #  BSD license.
37 #  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
38 #
39
40 macro(usedoxygen_set_default name value)
41         if(NOT DEFINED "${name}")
42                 set("${name}" "${value}")
43         endif()
44 endmacro()
45
46 find_package(Doxygen)
47
48 if(DOXYGEN_FOUND)
49         find_file(DOXYFILE_IN "Doxyfile.in"
50                         PATHS "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_ROOT}/Modules/"
51                         NO_DEFAULT_PATH)
52         include(FindPackageHandleStandardArgs)
53         find_package_handle_standard_args(DOXYFILE_IN DEFAULT_MSG "DOXYFILE_IN")
54 endif()
55
56 if(DOXYGEN_FOUND AND DOXYFILE_IN_FOUND)
57         add_custom_target(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
58
59         usedoxygen_set_default(DOXYFILE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
60         usedoxygen_set_default(DOXYFILE_HTML_DIR "html")
61
62         set_property(DIRECTORY APPEND PROPERTY
63                         ADDITIONAL_MAKE_CLEAN_FILES "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_HTML_DIR}")
64
65         set(DOXYFILE_LATEX "NO")
66         set(DOXYFILE_PDFLATEX "NO")
67         set(DOXYFILE_DOT "NO")
68
69         find_package(LATEX)
70         if(LATEX_COMPILER AND MAKEINDEX_COMPILER)
71                 set(DOXYFILE_LATEX "YES")
72                 usedoxygen_set_default(DOXYFILE_LATEX_DIR "latex")
73
74                 set_property(DIRECTORY APPEND PROPERTY
75                                 ADDITIONAL_MAKE_CLEAN_FILES
76                                 "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
77
78                 if(PDFLATEX_COMPILER)
79                         set(DOXYFILE_PDFLATEX "YES")
80                 endif()
81                 if(DOXYGEN_DOT_EXECUTABLE)
82                         set(DOXYFILE_DOT "YES")
83                 endif()
84
85                 add_custom_command(TARGET doxygen
86                         POST_BUILD
87                         COMMAND ${CMAKE_MAKE_PROGRAM}
88                         WORKING_DIRECTORY "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
89         endif()
90
91
92         configure_file(${DOXYFILE_IN} Doxyfile ESCAPE_QUOTES IMMEDIATE @ONLY)
93
94         get_target_property(DOC_TARGET doc TYPE)
95         if(NOT DOC_TARGET)
96                 add_custom_target(doc)
97         endif()
98                 
99         add_dependencies(doc doxygen)
100 endif()