From fdec202e8a10ef6d1a2473f3aec0931aff6cda1e Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 26 Jan 2013 08:44:02 +0100 Subject: [PATCH 1/2] Let cmake build system use xsltproc for doc generating. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59807 --- cmake/doc/CMakeLists.txt | 131 +++++++++++++++++------------------- cmake/modules/FindDocBookXSL.cmake | 51 ++++++++++++++ 2 Dateien geändert, 113 Zeilen hinzugefügt(+), 69 Zeilen entfernt(-) create mode 100644 cmake/modules/FindDocBookXSL.cmake diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index df6b587..b29ca28 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -1,74 +1,67 @@ +# +# api documentation +# find_package(Doxygen) -if(DOXYGEN_EXECUTABLE) - OPTION(DBUS_ENABLE_DOXYGEN_DOCS "build DOXYGEN documentation (requires Doxygen)" ON) -endif(DOXYGEN_EXECUTABLE) +add_custom_target(doc ALL) + +if (DOXYGEN_EXECUTABLE) + option(DBUS_ENABLE_DOXYGEN_DOCS "build DOXYGEN documentation (requires Doxygen)" ON) +endif () if (DBUS_ENABLE_DOXYGEN_DOCS) - set (top_srcdir ${CMAKE_SOURCE_DIR}/..) - configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_BINARY_DIR}/Doxyfile ) - add_custom_target(doc - COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile - ) -endif (DBUS_ENABLE_DOXYGEN_DOCS) + set (top_srcdir ${CMAKE_SOURCE_DIR}/..) + configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_BINARY_DIR}/Doxyfile ) + add_custom_target(apidoc + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile + ) + add_dependencies(doc apidoc) +endif () # -# find docbook generator +# docbook based documentation # -find_program(MEINPROC4_EXECUTABLE meinproc4) - -find_program(XMLTO_EXECUTABLE xmlto) - -if (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE) - OPTION(DBUS_ENABLE_XML_DOCS "build XML documentation (requires xmlto or meinproc4)" ON) -endif (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE) - -if (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) - else(WIN32) - set(_meinproc_install_path ${CMAKE_INSTALL_PREFIX}) - endif(WIN32) - set(STYLESHEET "${_meinproc_install_path}/share/apps/ksgmltools2/docbook/xsl/html/docbook.xsl") -endif (MEINPROC4_EXECUTABLE) - - -if (XMLTO_EXECUTABLE) - set (DOCBOOK_GENERATOR_NAME "xmlto" PARENT_SCOPE) - set(DBUS_XML_DOCS_ENABLED 1) - MESSAGE(STATUS "xmlto docbook generator found") -endif (XMLTO_EXECUTABLE) +find_program(XSLTPROC_EXECUTABLE xsltproc) +find_package(DocBookXSL) + +if ((DOCBOOKXSL_FOUND AND XSLTPROC_EXECUTABLE)) + option(DBUS_ENABLE_XML_DOCS "build XML documentation" ON) + set(DBUS_XML_DOCS_ENABLED 1) + message(STATUS "xsltproc docbook generator found") + add_custom_target(xmldoc) + add_dependencies(doc xmldoc) +endif () if (DBUS_ENABLE_XML_DOCS) -macro (DOCBOOK _sources _options) +macro (DOCBOOK _sources _format) get_filename_component(_infile ${_sources} ABSOLUTE) - get_filename_component(_basename ${_infile} NAME_WE) - set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.html) + get_filename_component(_name ${_infile} NAME) + + if (${_format} STREQUAL "man") + string(REPLACE ".xml" "" _outname ${_name}) + set(STYLESHEET "${DOCBOOKXSL_DIR}/manpages/docbook.xsl") + else() + string(REPLACE ".xml" ".html" _outname ${_name}) + set(STYLESHEET "${DOCBOOKXSL_DIR}/html/docbook.xsl") + endif () + set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname}) if (EXISTS ${_sources}) - if (MEINPROC4_EXECUTABLE) - ADD_CUSTOM_TARGET(${_basename}.html ALL - ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} - DEPENDS ${_infile} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - endif () - if (XMLTO_EXECUTABLE) - ADD_CUSTOM_TARGET(${_basename}.html ALL - ${XMLTO_EXECUTABLE} -vv ${_options} ${_infile} - DEPENDS ${_infile} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - endif () - install(FILES ${_outfile} DESTINATION share/doc/dbus) + add_custom_target(${_outname} + ${XSLTPROC_EXECUTABLE} --output ${_outfile} --nonet --xinclude --param passivetex.extensions '1' ${STYLESHEET} ${_infile} + DEPENDS ${_infile} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + add_dependencies(xmldoc ${_outname}) + 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") + message(STATUS "skipping xml doc generating for ${_infile}, file not found") endif () - endmacro (DOCBOOK) ### copy tests to builddir so that generated tests and static tests @@ -94,14 +87,14 @@ 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) -DOCBOOK(${CMAKE_SOURCE_DIR}/bus/dbus-daemon.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-monitor.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-send.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-launch.xml html-nochunks) +docbook(${CMAKE_SOURCE_DIR}/../doc/dbus-test-plan.xml html) +docbook(${CMAKE_SOURCE_DIR}/../doc/dbus-tutorial.xml html) +docbook(${CMAKE_SOURCE_DIR}/../doc/dbus-specification.xml html) +docbook(${CMAKE_SOURCE_DIR}/../doc/dbus-faq.xml html) +docbook(${CMAKE_SOURCE_DIR}/bus/dbus-daemon.xml html) +docbook(${CMAKE_SOURCE_DIR}/tools/dbus-monitor.xml html) +docbook(${CMAKE_SOURCE_DIR}/tools/dbus-send.xml html) +docbook(${CMAKE_SOURCE_DIR}/tools/dbus-launch.xml html) # # handle html index file @@ -109,12 +102,12 @@ DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-launch.xml html-nochunks) 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 +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) +endif () diff --git a/cmake/modules/FindDocBookXSL.cmake b/cmake/modules/FindDocBookXSL.cmake new file mode 100644 index 0000000..158e678 --- /dev/null +++ b/cmake/modules/FindDocBookXSL.cmake @@ -0,0 +1,51 @@ +# Try to find DocBook XSL stylesheet +# Once done, it will define: +# +# DOCBOOKXSL_FOUND - system has the required DocBook XML DTDs +# DOCBOOKXSL_DIR - the directory containing the stylesheets +# used to process DocBook XML + +# Copyright (c) 2010, Luigi Toscano, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +set (STYLESHEET_PATH_LIST + share/xml/docbook/stylesheet/docbook-xsl + share/xml/docbook/xsl-stylesheets + share/sgml/docbook/xsl-stylesheets + share/xml/docbook/stylesheet/nwalsh/current + share/xml/docbook/stylesheet/nwalsh + share/xsl/docbook +) + +find_path (DOCBOOKXSL_DIR lib/lib.xsl + PATHS ${CMAKE_SYSTEM_PREFIX_PATH} + PATH_SUFFIXES ${STYLESHEET_PATH_LIST} +) + +if (NOT DOCBOOKXSL_DIR) + # hacks for systems that put the version in the stylesheet dirs + set (STYLESHEET_PATH_LIST) + foreach (STYLESHEET_PREFIX_ITER ${CMAKE_SYSTEM_PREFIX_PATH}) + file(GLOB STYLESHEET_SUFFIX_ITER RELATIVE ${STYLESHEET_PREFIX_ITER} + ${STYLESHEET_PREFIX_ITER}/share/xml/docbook/xsl-stylesheets-* + ) + if (STYLESHEET_SUFFIX_ITER) + list (APPEND STYLESHEET_PATH_LIST ${STYLESHEET_SUFFIX_ITER}) + endif () + endforeach () + + find_path (DOCBOOKXSL_DIR VERSION + PATHS ${CMAKE_SYSTEM_PREFIX_PATH} + PATH_SUFFIXES ${STYLESHEET_PATH_LIST} + ) +endif (NOT DOCBOOKXSL_DIR) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args (DocBookXSL + "Could NOT find DocBook XSL stylesheets" + DOCBOOKXSL_DIR) + +mark_as_advanced (DOCBOOKXSL_DIR) -- 1.7.10.4