Warning, /multimedia/kwave/doc/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 #############################################################################
0002 ##    Kwave                - doc/CMakeLists.txt
0003 ##                           -------------------
0004 ##    begin                : Sat May 12 2007
0005 ##    copyright            : (C) 2007 by Thomas Eschenbacher
0006 ##    email                : Thomas.Eschenbacher@gmx.de
0007 #############################################################################
0008 #
0009 #############################################################################
0010 #                                                                           #
0011 # Redistribution and use in source and binary forms, with or without        #
0012 # modification, are permitted provided that the following conditions        #
0013 # are met:                                                                  #
0014 #                                                                           #
0015 # 1. Redistributions of source code must retain the above copyright         #
0016 #    notice, this list of conditions and the following disclaimer.          #
0017 # 2. Redistributions in binary form must reproduce the above copyright      #
0018 #    notice, this list of conditions and the following disclaimer in the    #
0019 #    documentation and/or other materials provided with the distribution.   #
0020 #                                                                           #
0021 # For details see the accompanying cmake/COPYING-CMAKE-SCRIPTS file.        #
0022 #                                                                           #
0023 #############################################################################
0024 
0025 SET(UPDATE_COMMAND_XREF    ${CMAKE_SOURCE_DIR}/bin/update-command-xref.pl)
0026 SET(UPDATE_FILEINFO_XREF   ${CMAKE_SOURCE_DIR}/bin/update-fileinfo-xref.pl)
0027 SET(UPDATE_PLUGIN_XREF     ${CMAKE_SOURCE_DIR}/bin/update-plugin-xref.pl)
0028 SET(_index_docbook         ${CMAKE_CURRENT_SOURCE_DIR}/en/index.docbook)
0029 SET(_index_docbook_updated ${CMAKE_CURRENT_BINARY_DIR}/index-updated.docbook)
0030 
0031 FIND_REQUIRED_PROGRAM(CP_EXECUTABLE cp)
0032 
0033 #############################################################################
0034 ### how to convert from svg to png                                        ###
0035 
0036 FIND_PROGRAM(RSVG_EXECUTABLE NAMES rsvg-convert rsvg)
0037 IF (RSVG_EXECUTABLE)
0038     GET_FILENAME_COMPONENT(_basename ${RSVG_EXECUTABLE} NAME_WE)
0039     MESSAGE(STATUS "Found ${_basename}: ${RSVG_EXECUTABLE}")
0040 ENDIF (RSVG_EXECUTABLE)
0041 
0042 SET(_test_icon "${CMAKE_SOURCE_DIR}/kwave/toolbar/sc-actions-kwave_zoom_in.svgz")
0043 GET_FILENAME_COMPONENT(_svgz_file ${_test_icon} NAME)
0044 STRING(REPLACE ".svgz" ".png" _png_file ${_svgz_file})
0045 
0046 SET(RSVG_AVAILABLE NO)
0047 IF (RSVG_EXECUTABLE)
0048     # try to convert one icon, to see if "rsvg" really works
0049     EXECUTE_PROCESS(
0050         COMMAND ${RSVG_EXECUTABLE} -w 32 -h 32 -f png ${_test_icon} -o "${_png_file}"
0051         WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
0052         RESULT_VARIABLE RSVG_CONVERT_RESULT
0053         OUTPUT_VARIABLE _stdout
0054         ERROR_VARIABLE _stderr
0055     )
0056     IF (${RSVG_CONVERT_RESULT} EQUAL 0)
0057         MESSAGE(STATUS "Converting svg to png with ${RSVG_EXECUTABLE}")
0058         MACRO(SVG2PNG _infile _outfile _name)
0059             ADD_CUSTOM_COMMAND(OUTPUT ${_outfile}
0060                 COMMAND ${RSVG_EXECUTABLE} -w 32 -h 32 -f png ${_infile} -o ${_outfile}
0061                 DEPENDS ${_infile}
0062                 COMMENT STATUS "Converting ${_name}"
0063             )
0064         ENDMACRO(SVG2PNG)
0065 
0066         SET(RSVG_AVAILABLE YES)
0067     ELSE (${RSVG_CONVERT_RESULT} EQUAL 0)
0068         MESSAGE(STATUS "Found rsvg but conversion failed, falling back to convert from ImageMagick")
0069     ENDIF (${RSVG_CONVERT_RESULT} EQUAL 0)
0070 ENDIF (RSVG_EXECUTABLE)
0071 
0072 IF (NOT RSVG_AVAILABLE)
0073     SET(CONVERT_AVAILABLE NO)
0074     FIND_PROGRAM(CONVERT_EXECUTABLE NAMES convert)
0075     IF (CONVERT_EXECUTABLE)
0076         GET_FILENAME_COMPONENT(_basename ${CONVERT_EXECUTABLE} NAME_WE)
0077         MESSAGE(STATUS "Found ${_basename}: ${CONVERT_EXECUTABLE}")
0078 
0079         # try to convert one icon, to see if "convert" has proper svg support
0080         EXECUTE_PROCESS(
0081             COMMAND ${CONVERT_EXECUTABLE} -resize 32x32 ${_test_icon} "${_png_file}"
0082             WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
0083             RESULT_VARIABLE SVG_CONVERT_RESULT
0084             OUTPUT_VARIABLE _stdout
0085             ERROR_VARIABLE _stderr
0086         )
0087         IF (${SVG_CONVERT_RESULT} EQUAL 0)
0088             MESSAGE(STATUS "Converting svg to png with ${CONVERT_EXECUTABLE}")
0089             MACRO(SVG2PNG _infile _outfile _name)
0090                 ADD_CUSTOM_COMMAND(OUTPUT ${_outfile}
0091                     COMMAND ${CONVERT_EXECUTABLE} -resize 32x32 ${_infile} ${_outfile}
0092                     DEPENDS ${_infile}
0093                     COMMENT STATUS "Converting ${_name}"
0094                 )
0095             ENDMACRO(SVG2PNG)
0096             SET(CONVERT_AVAILABLE YES)
0097         ENDIF (${SVG_CONVERT_RESULT} EQUAL 0)
0098     ENDIF (CONVERT_EXECUTABLE)
0099 
0100     IF (NOT CONVERT_AVAILABLE)
0101         MESSAGE(FATAL_ERROR "
0102         your system lacks support for converting icons in svg format to png.
0103 
0104         You have three options:
0105         1) install the tool \"rsvg\"
0106         2) install a version of \"convert\" (ImageMagick) that has proper svg support
0107         3) omit building the online documentation by using the cmake option \"-DWITH_DOC=OFF\"
0108         ")
0109     ENDIF (NOT CONVERT_AVAILABLE)
0110 ENDIF (NOT RSVG_AVAILABLE)
0111 
0112 # clean up the temporary png file after conversion test
0113 FILE(REMOVE "${CMAKE_BINARY_DIR}/${_png_file}")
0114 
0115 #############################################################################
0116 ### "make update-handbook"                                                ###
0117 
0118 ADD_CUSTOM_TARGET(update-handbook
0119     COMMAND ${UPDATE_COMMAND_XREF}
0120         ${CMAKE_SOURCE_DIR}
0121         ${_index_docbook}
0122         ${_index_docbook_updated}
0123     COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_index_docbook_updated} ${_index_docbook}
0124 
0125     COMMAND ${UPDATE_FILEINFO_XREF}
0126         ${_index_docbook}
0127         ${CMAKE_SOURCE_DIR}/libkwave/FileInfo.cpp
0128         ${_index_docbook_updated}
0129     COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_index_docbook_updated} ${_index_docbook}
0130 
0131     COMMAND ${UPDATE_PLUGIN_XREF}
0132         ${CMAKE_SOURCE_DIR}/plugins
0133         ${_index_docbook}
0134         ${_index_docbook_updated}
0135     COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_index_docbook_updated} ${_index_docbook}
0136 )
0137 
0138 #############################################################################
0139 ### handle the various languages                                          ###
0140 
0141 # collects all "html_doc_${_lang}" sub targets
0142 ADD_CUSTOM_TARGET(html_doc)
0143 
0144 FILE(GLOB _files "${CMAKE_SOURCE_DIR}/doc/*/index.docbook")
0145 FOREACH(_file ${_files})
0146     GET_FILENAME_COMPONENT(_subdir ${_file} DIRECTORY)
0147     GET_FILENAME_COMPONENT(_lang ${_subdir} NAME)
0148 
0149     # take only languages that have been requested
0150     SET(_take_it TRUE)
0151     IF (NOT "${LINGUAS}" STREQUAL "*")
0152         LIST(FIND LINGUAS "${_lang}" _found)
0153         IF (_found LESS 0)
0154             SET(_take_it FALSE)
0155         ENDIF (_found LESS 0)
0156     ENDIF (NOT "${LINGUAS}" STREQUAL "*")
0157 
0158     IF (_take_it)
0159         MESSAGE(STATUS "Enabled handbook for ${_lang}")
0160         ADD_SUBDIRECTORY(${_lang})
0161     ENDIF (_take_it)
0162 
0163 ENDFOREACH(_file ${_files})
0164 
0165 #############################################################################
0166 ### "make html_doc_devel"                                                 ###
0167 
0168 SET(_common_en_dir ${CMAKE_INSTALL_PREFIX}/share/help/en/kdoctools5-common)
0169 SET(_html_dir_devel ${CMAKE_CURRENT_BINARY_DIR}/devel)
0170 GET_TARGET_PROPERTY(MEINPROC_EXECUTABLE ${KDOCTOOLS_MEINPROC_EXECUTABLE} LOCATION)
0171 
0172 ADD_CUSTOM_TARGET(html_doc_devel
0173     COMMENT "Generating HTML developer documentation"
0174     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/devel.docbook
0175     # start with an empty output (_html_dir)
0176     COMMAND ${CMAKE_COMMAND} -E remove_directory ${_html_dir_devel}
0177     COMMAND ${CMAKE_COMMAND} -E make_directory   ${_html_dir_devel}
0178     # create the HTML pages from docbook
0179     COMMAND cd ${_html_dir_devel} && ${MEINPROC_EXECUTABLE}
0180             --check ${CMAKE_CURRENT_SOURCE_DIR}/devel.docbook
0181     # copy files for the "common" directory
0182     COMMAND ${CMAKE_COMMAND} -E make_directory      ${_html_dir_devel}/common
0183     COMMAND ${CP_EXECUTABLE} -n ${_common_en_dir}/* ${_html_dir_devel}/common/
0184     # fix wrong paths in the HTML pages
0185     COMMAND cd ${_html_dir_devel} && ${CMAKE_SOURCE_DIR}/doc/fix-common
0186     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
0187 )
0188 
0189 #############################################################################
0190 #############################################################################