1
# CMake macros to use the GtkDoc documentation system
5
# gtk_doc_add_module(doc_prefix sourcedir
7
# [FIXXREFOPTS fixxrefoption1...]
8
# [IGNOREHEADERS header1...]
9
# [DEPENDS depend1...] )
11
# sourcedir must be the *full* path to the source directory.
13
# If omitted, sgmlfile defaults to the auto generated ${doc_prefix}/${doc_prefix}-docs.xml.
14
function(gtk_doc_add_module _doc_prefix _doc_sourcedir)
15
set (_multi_value DEPENDS XML FIXXREFOPTS IGNOREHEADERS CFLAGS LDFLAGS LDPATH SUFFIXES)
16
cmake_parse_arguments (ARG "" "" "${_multi_value}" ${ARGN})
18
list(LENGTH ARG_XML _xml_file_length)
21
set(_doc_source_suffixes "")
22
foreach(_suffix ${ARG_SUFFIXES})
23
if(_doc_source_suffixes)
24
set(_doc_source_suffixes "${_doc_source_suffixes},${_suffix}")
25
else(_doc_source_suffixes)
26
set(_doc_source_suffixes "${_suffix}")
27
endif(_doc_source_suffixes)
30
set(_doc_source_suffixes "h")
36
if(NOT _xml_file_length LESS 2)
37
message(SEND_ERROR "Must have at most one sgml file specified.")
39
endif(NOT _xml_file_length LESS 2)
42
# a directory to store output.
43
set(_output_dir "${CMAKE_CURRENT_BINARY_DIR}/${_doc_prefix}")
44
set(_output_dir_stamp "${_output_dir}/dir.stamp")
46
# set default sgml file if not specified
47
set(_default_xml_file "${_output_dir}/${_doc_prefix}-docs.xml")
48
get_filename_component(_default_xml_file ${_default_xml_file} ABSOLUTE)
50
# a directory to store html output.
51
set(_output_html_dir "${_output_dir}/html")
52
set(_output_html_dir_stamp "${_output_dir}/html_dir.stamp")
55
set(_output_decl_list "${_output_dir}/${_doc_prefix}-decl-list.txt")
56
set(_output_decl "${_output_dir}/${_doc_prefix}-decl.txt")
57
set(_output_overrides "${_output_dir}/${_doc_prefix}-overrides.txt")
58
set(_output_sections "${_output_dir}/${_doc_prefix}-sections.txt")
59
set(_output_types "${_output_dir}/${_doc_prefix}.types")
61
set(_output_signals "${_output_dir}/${_doc_prefix}.signals")
63
set(_output_unused "${_output_dir}/${_doc_prefix}-unused.txt")
64
set(_output_undeclared "${_output_dir}/${_doc_prefix}-undeclared.txt")
65
set(_output_undocumented "${_output_dir}/${_doc_prefix}-undocumented.txt")
66
set(_output_tmpl_dir "${_output_dir}/tmpl")
67
set(_output_tmpl_stamp "${_output_dir}/tmpl.stamp")
69
set(_output_xml_dir "${_output_dir}/xml")
70
set(_output_sgml_stamp "${_output_dir}/sgml.stamp")
72
set(_output_html_stamp "${_output_dir}/html.stamp")
74
# add a command to create output directory
76
OUTPUT "${_output_dir_stamp}" "${_output_dir}"
77
COMMAND ${CMAKE_COMMAND} -E make_directory "${_output_dir}"
78
COMMAND ${CMAKE_COMMAND} -E touch ${_output_dir_stamp}
81
set(_ignore_headers_opt "")
83
set(_ignore_headers_opt "--ignore-headers=")
84
foreach(_header ${ARG_IGNOREHEADERS})
85
set(_ignore_headers_opt "${_ignore_headers_opt}${_header} ")
86
endforeach(_header ${ARG_IGNOREHEADERS})
87
endif(ARG_IGNOREHEADERS)
89
# add a command to scan the input
92
"${_output_decl_list}"
95
"${_output_overrides}"
98
"${_output_types}.bak"
102
COMMAND ${GTKDOC_SCAN_EXE}
103
"--module=${_doc_prefix}"
104
"${_ignore_headers_opt}"
107
"--source-dir=${_doc_sourcedir}"
108
WORKING_DIRECTORY "${_output_dir}"
111
# add a command to scan the input via gtkdoc-scangobj
112
# This is such a disgusting hack!
119
COMMAND ${CMAKE_COMMAND}
120
-D "GTKDOC_SCANGOBJ_EXE:STRING=${GTKDOC_SCANGOBJ_EXE}"
121
-D "doc_prefix:STRING=${_doc_prefix}"
122
-D "output_types:STRING=${_output_types}"
123
-D "output_dir:STRING=${_output_dir}"
124
-D "EXTRA_CFLAGS:STRING=${ARG_CFLAGS}"
125
-D "EXTRA_LDFLAGS:STRING=${ARG_LDFLAGS}"
126
-D "EXTRA_LDPATH:STRING=${ARG_LDPATH}"
127
-P ${GTKDOC_SCANGOBJ_WRAPPER}
128
WORKING_DIRECTORY "${_output_dir}"
131
# add a command to make the templates
135
"${_output_undeclared}"
136
"${_output_undocumented}"
137
"${_output_tmpl_dir}"
138
"${_output_tmpl_stamp}"
142
"${_output_sections}"
143
"${_output_overrides}"
145
COMMAND ${CMAKE_COMMAND} -E remove_directory ${_output_tmpl_dir}
146
COMMAND ${GTKDOC_MKTMPL_EXE}
147
"--module=${_doc_prefix}"
148
WORKING_DIRECTORY "${_output_dir}"
151
set(_copy_xml_if_needed "")
153
get_filename_component(ARG_XML ${ARG_XML} ABSOLUTE)
154
set(_copy_xml_if_needed
155
COMMAND ${CMAKE_COMMAND} -E copy "${ARG_XML}" "${_default_xml_file}")
158
set(_remove_xml_if_needed "")
160
set(_remove_xml_if_needed
161
COMMAND ${CMAKE_COMMAND} -E remove ${_default_xml_file})
164
# add a command to make the database
167
"${_output_sgml_stamp}"
168
"${_default_xml_file}"
170
"${_output_tmpl_stamp}"
172
"${_output_undeclared}"
173
"${_output_undocumented}"
175
${_remove_xml_if_needed}
176
COMMAND ${CMAKE_COMMAND} -E remove_directory ${_output_xml_dir}
177
COMMAND ${GTKDOC_MKDB_EXE}
178
"--module=${_doc_prefix}"
179
"--source-dir=${_doc_sourcedir}"
180
"--source-suffixes=${_doc_source_suffixes}"
181
"--output-format=xml"
182
"--main-sgml-file=${_default_xml_file}"
183
${_copy_xml_if_needed}
184
WORKING_DIRECTORY "${_output_dir}"
187
# add a command to create html directory
189
OUTPUT "${_output_html_dir_stamp}" "${_output_html_dir}"
190
COMMAND ${CMAKE_COMMAND} -E make_directory ${_output_html_dir}
191
COMMAND ${CMAKE_COMMAND} -E touch ${_output_html_dir_stamp}
194
# add a command to output HTML
197
"${_output_html_stamp}"
199
"${_output_html_dir_stamp}"
200
"${_output_sgml_stamp}"
201
"${_output_tmpl_stamp}"
204
${_copy_xml_if_needed}
205
COMMAND ${GTKDOC_MKHTML_EXE}
207
"${_default_xml_file}"
208
WORKING_DIRECTORY "${_output_html_dir}"
212
add_custom_target("${_doc_prefix}-gtxdoc-fixxref"
214
"${_output_html_stamp}"
216
COMMAND ${GTKDOC_FIXXREF_EXE}
217
"--module=${_doc_prefix}"
220
#${_remove_xml_if_needed}
221
WORKING_DIRECTORY "${_output_dir}"
224
add_custom_target(doc-${_doc_prefix} ${_do_all}
226
"${_doc_prefix}-gtxdoc-fixxref"
229
add_test(doc-${_doc_prefix}-check ${GTKDOC_CHECK_EXE})
230
set_tests_properties(doc-${_doc_prefix}-check PROPERTIES
231
ENVIRONMENT "DOC_MODULE=${_doc_prefix};DOC_MAIN_SGML_FILE=${_doc_prefix}-docs.xml;SRCDIR=${_doc_sourcedir};BUILDDIR=${_output_dir}"
234
endfunction(gtk_doc_add_module)