summaryrefslogtreecommitdiff
path: root/cmake/doc/CMakeLists.txt
blob: 807af60c54b8caada262928657cd505b4e1eaef5 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
find_package(Doxygen)

if(DOXYGEN_EXECUTABLE)
  OPTION(DBUS_ENABLE_DOXYGEN_DOCS "build DOXYGEN documentation (requires Doxygen)" ON)
endif(DOXYGEN_EXECUTABLE)

if (DBUS_ENABLE_DOXYGEN_DOCS)
    set (top_srcdir ${CMAKE_SOURCE_DIR}/..)
    configure_file(${CMAKE_SOURCE_DIR}/../Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile )
    add_custom_target(doc 
        COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
    )
endif (DBUS_ENABLE_DOXYGEN_DOCS)

#
# find docbook generator
# 
find_program(MEINPROC4_EXECUTABLE meinproc4)

find_program(XMLTO_EXECUTABLE xmlto)

find_program(CYGPATH_EXECUTABLE cygpath)

if (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE)
  OPTION(DBUS_ENABLE_XML_DOCS "build XML  documentation (requires xmlto or meinproc4)" ON)
  ADD_CUSTOM_TARGET(xmldoc ALL)
endif (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE)

if (XMLTO_EXECUTABLE)
	set (DOCBOOK_GENERATOR_NAME "xmlto" PARENT_SCOPE)
	set(DBUS_XML_DOCS_ENABLED 1)
	set(MEINPROC4_EXECUTABLE 0)
	MESSAGE(STATUS "xmlto docbook generator found")
	set(STYLESHEET_MAN "${DOCBOOKXSL_DIR}/manpages/docbook.xsl")
	set(STYLESHEET_HTML "${DOCBOOKXSL_DIR}/html/docbook.xsl")

elseif (MEINPROC4_EXECUTABLE)
	set(DOCBOOK_GENERATOR_NAME "meinproc4" PARENT_SCOPE)
	set(DBUS_XML_DOCS_ENABLED 1)
	if(WIN32)
		get_filename_component(_a ${MEINPROC4_EXECUTABLE} PATH)
		get_filename_component(_meinproc_install_path ${_a} PATH)
		set(STYLESHEET_HTML "${_meinproc_install_path}/share/apps/ksgmltools2/docbook/xsl/html/docbook.xsl")
	else(WIN32)
		set(STYLESHEET_HTML file:///usr/share/kde4/apps/ksgmltools2/customization/kde-nochunk.xsl)
	endif(WIN32)
endif ()

if (DBUS_ENABLE_XML_DOCS)

macro (DOCBOOK _sources _format)
  get_filename_component(_infile ${_sources} ABSOLUTE)
  get_filename_component(_name ${_infile} NAME)
  set(_deps ${CMAKE_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)

  if (${_format} STREQUAL "man")
    string(REPLACE ".xml" "" _outname ${_name})
    set(STYLESHEET ${STYLESHEET_MAN})
  else()
    string(REPLACE ".xml" ".html" _outname ${_name})
    set(STYLESHEET ${STYLESHEET_HTML})
  endif ()

  set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname})
  if (EXISTS ${_sources})
	  if (MEINPROC4_EXECUTABLE)
		    ADD_CUSTOM_COMMAND(
			OUTPUT ${_outfile}
			COMMAND ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile}
			DEPENDS ${_infile} ${STYLESHEET} ${_deps}
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
		)
	  endif ()
	  if (XMLTO_EXECUTABLE)
		    if (MSYS)
			if (CYGPATH_EXECUTABLE)
			    execute_process(
				COMMAND cygpath ${_infile}
				OUTPUT_VARIABLE _infile)
			else ()
			    execute_process(COMMAND dirname ${_infile}  OUTPUT_VARIABLE _path)
			    string(STRIP ${_path} _path)
			    execute_process(COMMAND sh -c "cd ${_path}; pwd -W" OUTPUT_VARIABLE _path)
			    string(STRIP ${_path} _path)
			    set(_infile "${_path}/${_name}")
			endif(CYGPATH_EXECUTABLE)
		    endif (MSYS)
		    ADD_CUSTOM_COMMAND(
			OUTPUT ${_outfile}
			COMMAND ${XMLTO_EXECUTABLE} -vv ${_format} ${_infile}
			DEPENDS ${_infile} ${_deps}
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
		)
	  endif ()
	  if (${_format} STREQUAL "man")
		  install(FILES ${_outfile} DESTINATION share/man/man1)
	  else ()
		  install(FILES ${_outfile} DESTINATION share/doc/dbus)
	  endif ()
  else ()
	  MESSAGE(STATUS "skipping xml doc generating for ${_infile}, file not found")
  endif ()
  ADD_CUSTOM_TARGET(${_outname} DEPENDS ${_outfile})
  ADD_DEPENDENCIES(xmldoc ${_outname})
endmacro (DOCBOOK)

### copy tests to builddir so that generated tests and static tests 
### are all in one place.
### todo how to add more filetypes 
MACRO (COPYDIR _src _type)
    FOREACH(FILE_TYPE ${_type})
    	FOREACH(DIR ${_src})
    		FILE(GLOB FILES "${CMAKE_SOURCE_DIR}/../${DIR}/${FILE_TYPE}" )
    		FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR})
    		FOREACH(FILE ${FILES})
    			GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME)
    			SET (TARGET ${CMAKE_BINARY_DIR}/${DIR}/${FILENAME})
    			configure_file(${FILE} ${TARGET} COPYONLY)
    			IF (CONFIG_VERBOSE)
    				MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n")
    			ENDIF (CONFIG_VERBOSE)
    		ENDFOREACH(FILE)
    	ENDFOREACH(DIR)
    ENDFOREACH(FILE_TYPE)
ENDMACRO (COPYDIR)

COPYDIR(doc *.png)
COPYDIR(doc *.svg)

DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-test-plan.xml html-nochunks)
DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-tutorial.xml html-nochunks)
DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-specification.xml html-nochunks)
DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-faq.xml html-nochunks)
configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-cleanup-sockets.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml)
configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-daemon.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml)
configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml)
configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml)
configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml)
configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-uuidgen.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml)
DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml html-nochunks)
DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml html-nochunks)
DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml html-nochunks)
DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml html-nochunks)
DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml html-nochunks)
DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml html-nochunks)
if (UNIX)
  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml man)
  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml man)
  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml man)
  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml man)
  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml man)
  DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml man)
endif()
#
# handle html index file
#
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/index.html.cmake ${CMAKE_CURRENT_BINARY_DIR}/index.html )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/index.html DESTINATION share/doc/dbus)

set (EXTRA_DIST 	
	${CMAKE_SOURCE_DIR}/../doc/busconfig.dtd			
	${CMAKE_SOURCE_DIR}/../doc/introspect.dtd			
	${CMAKE_SOURCE_DIR}/../doc/introspect.xsl
)

install(FILES ${EXTRA_DIST} DESTINATION share/doc/dbus)

endif(DBUS_ENABLE_XML_DOCS)