Merge branch 'dbus-1.2'
[platform/upstream/dbus.git] / cmake / doc / CMakeLists.txt
1 find_package(Doxygen)
2
3 if(DOXYGEN_EXECUTABLE)
4   OPTION(DBUS_ENABLE_DOXYGEN_DOCS "build DOXYGEN documentation (requires Doxygen)" ON)
5 endif(DOXYGEN_EXECUTABLE)
6
7 if (DBUS_ENABLE_DOXYGEN_DOCS)
8     set (top_srcdir ${CMAKE_SOURCE_DIR}/..)
9     configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_BINARY_DIR}/Doxyfile )
10     add_custom_target(doc 
11         COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
12     )
13 endif (DBUS_ENABLE_DOXYGEN_DOCS)
14
15 #
16 # find docbook generator
17
18 find_program(MEINPROC_EXECUTABLE meinproc4)
19
20 find_program(XMLTO_EXECUTABLE xmlto)
21
22 if (MEINPROC_EXECUTABLE OR XMLTO_EXECUTABLE)
23   OPTION(DBUS_ENABLE_XML_DOCS "build XML  documentation (requires xmlto or meinproc4)" ON)
24 endif (MEINPROC_EXECUTABLE OR XMLTO_EXECUTABLE)
25
26 if (MEINPROC_EXECUTABLE)
27         set(DOCBOOK_GENERATOR_NAME "meinproc4" PARENT_SCOPE)
28         set(DBUS_XML_DOCS_ENABLED 1)
29         set(STYLESHEET "${CMAKE_INSTALL_PREFIX}/share/apps/ksgmltools2/docbook/xsl/html/docbook.xsl")
30 endif (MEINPROC_EXECUTABLE)
31   
32  
33 if (XMLTO_EXECUTABLE)
34         set (DOCBOOK_GENERATOR_NAME "xmlto" PARENT_SCOPE)
35         set(DBUS_XML_DOCS_ENABLED 0)
36         MESSAGE(STATUS "xmlto docbook generator found, but xmlto doc generating needs validation")
37 endif (XMLTO_EXECUTABLE)
38
39 if (DBUS_ENABLE_XML_DOCS)
40
41 macro (DOCBOOK _sources _options)
42   get_filename_component(_infile ${_sources} REALPATH)
43   get_filename_component(_basename ${_infile} NAME_WE)
44   set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.html)
45
46   if (EXISTS ${_sources})
47           if (MEINPROC_EXECUTABLE)
48                   ADD_CUSTOM_TARGET(${_basename}.html ALL
49                         meinproc4 --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} 
50                         DEPENDS ${_infile} 
51                         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
52                 )
53           endif ()
54           if (XMLTO_EXECUTABLE)
55                   ADD_CUSTOM_TARGET(${_basename}.html ALL
56                         xmlto.bat ${_options} ${_infile} 
57                         DEPENDS ${_infile} 
58                         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
59                 )
60           endif ()
61           install(FILES ${_outfile} DESTINATION share/doc/dbus)
62   else ()
63           MESSAGE(STATUS "skipping xml doc generating for ${_infile}, file not found")
64   endif ()
65           
66 endmacro (DOCBOOK)
67
68 ### copy tests to builddir so that generated tests and static tests 
69 ### are all in one place.
70 ### todo how to add more filetypes 
71 MACRO (COPYDIR _src _type)
72     FOREACH(FILE_TYPE ${_type})
73         FOREACH(DIR ${_src})
74                 FILE(GLOB FILES "${CMAKE_SOURCE_DIR}/../${DIR}/${FILE_TYPE}" )
75                 FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${DIR})
76                 FOREACH(FILE ${FILES})
77                         GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME)
78                         SET (TARGET ${CMAKE_BINARY_DIR}/${DIR}/${FILENAME})
79                         configure_file(${FILE} ${TARGET} COPYONLY)
80                         IF (CONFIG_VERBOSE)
81                                 MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n")
82                         ENDIF (CONFIG_VERBOSE)
83                 ENDFOREACH(FILE)
84         ENDFOREACH(DIR)
85     ENDFOREACH(FILE_TYPE)
86 ENDMACRO (COPYDIR)
87
88 COPYDIR(doc *.png)
89 COPYDIR(doc *.svg)
90
91 DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-test-plan.xml html-nochunks)
92 DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-tutorial.xml html-nochunks)
93 DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-specification.xml html-nochunks)
94 DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-faq.xml html-nochunks)
95 DOCBOOK(${CMAKE_SOURCE_DIR}/bus/dbus-daemon.xml html-nochunks)
96 DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-monitor.xml html-nochunks)
97 DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-send.xml html-nochunks)
98 DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-launch.xml html-nochunks)
99
100 #
101 # handle html index file
102 #
103 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/index.html.cmake ${CMAKE_CURRENT_BINARY_DIR}/index.html )
104 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/index.html DESTINATION share/doc/dbus)
105
106 set (EXTRA_DIST         
107         ${CMAKE_SOURCE_DIR}/../doc/busconfig.dtd                        
108         ${CMAKE_SOURCE_DIR}/../doc/introspect.dtd                       
109         ${CMAKE_SOURCE_DIR}/../doc/introspect.xsl
110 )
111
112 install(FILES ${EXTRA_DIST} DESTINATION share/doc/dbus)
113
114 endif(DBUS_ENABLE_XML_DOCS)