~midori/midori/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# GtkDoc.cmake
#
# Macros for building Midori API documentation.
# Copyright (C) 2013 Olivier Duchateau

find_program (GTKDOC_SCAN_BIN gtkdoc-scan)
find_program (GTKDOC_MKDB_BIN gtkdoc-mkdb)
find_program (GTKDOC_MKHTML_BIN gtkdoc-mkhtml)
find_program (GTKDOC_MKTMPL_BIN gtkdoc-mktmpl)

if (GTKDOC_SCAN_BIN AND GTKDOC_MKTMPL_BIN AND GTKDOC_MKDB_BIN
        AND GTKDOC_MKHTML_BIN)

    set (GTKDOC_FOUND TRUE)

    macro (gtkdoc_build module)
        message("gtkdoc: module ${module}")
        # file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}")
        add_custom_target ("gtkdoc-scan_${module}" ALL
            ${GTKDOC_SCAN_BIN} --module=${module}
                --source-dir="${CMAKE_SOURCE_DIR}/${module}"
                --output-dir="${CMAKE_CURRENT_BINARY_DIR}/${module}"
                --rebuild-sections --rebuild-types
                WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")

        add_custom_target ("gtkdoc-tmpl_${module}" ALL
            ${GTKDOC_MKTMPL_BIN} --module=${module}
            --output-dir="${CMAKE_CURRENT_BINARY_DIR}"
            WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}"
            DEPENDS "gtkdoc-scan_${module}")

        add_custom_target ("gtkdoc-docbook_${module}" ALL
            ${GTKDOC_MKDB_BIN} --module=${module}
                --output-dir="xml"
                --source-dir="${CMAKE_SOURCE_DIR}/${module}"
                --source-suffixes=c,h --output-format=xml
                --default-includes=${module}/${module}.h
                --sgml-mode --main-sgml-file=${module}.sgml
            WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}"
            DEPENDS "gtkdoc-tmpl_${module}")

        # Keep this target alone, otherwise build fails
        add_custom_target ("gtkdoc-html_${module}" ALL
            ${GTKDOC_MKHTML_BIN} ${module}
            "${CMAKE_CURRENT_BINARY_DIR}/${module}/${module}.sgml"
            WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}/html"
            DEPENDS "gtkdoc-docbook_${module}")

    endmacro (gtkdoc_build module)

    macro (gtkdoc module)
        file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}/html")
        gtkdoc_build (${module})

        set (DOC_DIR "html/midori-${MIDORI_MAJOR_VERSION}-${MIDORI_MINOR_VERSION}")
        install (DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${module}/html/"
            DESTINATION "${CMAKE_INSTALL_DATADIR}/gtk-doc/${DOC_DIR}/${module}"
            PATTERN "html/*"
            PATTERN "index.sgml" EXCLUDE)
    endmacro (gtkdoc module)
endif ()