"Fossies" - the Fresh Open Source Software Archive

Member "brlcad-7.32.4/misc/CMake/DocBook.cmake" (29 Jul 2021, 12565 Bytes) of package /linux/misc/brlcad-7.32.4.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) CMake source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "DocBook.cmake": 7.32.0_vs_7.32.2.

A hint: This file contains one or more very long lines, so maybe it is better readable using the pure text view mode that shows the contents as wrapped lines within the browser window.


    1 #                   D O C B O O K . C M A K E
    2 # BRL-CAD
    3 #
    4 # Copyright (c) 2011-2021 United States Government as represented by
    5 # the U.S. Army Research Laboratory.
    6 #
    7 # Redistribution and use in source and binary forms, with or without
    8 # modification, are permitted provided that the following conditions
    9 # are met:
   10 #
   11 # 1. Redistributions of source code must retain the above copyright
   12 # notice, this list of conditions and the following disclaimer.
   13 #
   14 # 2. Redistributions in binary form must reproduce the above
   15 # copyright notice, this list of conditions and the following
   16 # disclaimer in the documentation and/or other materials provided
   17 # with the distribution.
   18 #
   19 # 3. The name of the author may not be used to endorse or promote
   20 # products derived from this software without specific prior written
   21 # permission.
   22 #
   23 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
   24 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   25 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   26 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
   27 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   28 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
   29 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   30 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
   31 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   32 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   33 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   34 #
   35 ###
   36 #
   37 # In principle, DocBook conversion and validation can be accomplished
   38 # with multiple programs.  BRL-CAD's CMake logic uses variables to
   39 # hold the "active" tools for each conversion operation, but will
   40 # set defaults if the user does not manually set them.
   41 
   42 # If a user wishes to use their own validation and/or conversion
   43 # tools, they can set the following variables to their executable
   44 # names and create <exec_name>.cmake.in files in misc/CMake.  To work,
   45 # the cmake.in files will need to produce the same validity "stamp"
   46 # files and fatal errors as the default tools upon success or failure.
   47 # For a worked example, see rnv.cmake.in - to test it, install rnv from
   48 # http://sourceforge.net/projects/rnv/ and configure BRL-CAD as follows:
   49 #
   50 # cmake .. -DBRLCAD_EXTRADOCS_VALIDATE=ON -DVALIDATE_EXECUTABLE=rnv
   51 #
   52 # Note that rnv must be in the system path for this to work.
   53 
   54 
   55 # Handle default exec and sanity checking for XML validation
   56 if(BRLCAD_ENABLE_STRICT)
   57   if(NOT DEFINED VALIDATE_EXECUTABLE)
   58     set(VALIDATE_EXECUTABLE "xmllint")
   59   else(NOT DEFINED VALIDATE_EXECUTABLE)
   60     if(NOT EXISTS "${BRLCAD_SOURCE_DIR}/misc/CMake/${VALIDATE_EXECUTABLE}.cmake.in")
   61       message(FATAL_ERROR "Specified ${VALIDATE_EXECUTABLE} for DocBook validation, but \"${BRLCAD_SOURCE_DIR}/misc/CMake/${VALIDATE_EXECUTABLE}.cmake.in\" does not exist.  To use ${VALIDATE_EXECUTABLE} a ${VALIDATE_EXECUTABLE}.cmake.in file must be defined.")
   62     endif(NOT EXISTS "${BRLCAD_SOURCE_DIR}/misc/CMake/${VALIDATE_EXECUTABLE}.cmake.in")
   63   endif(NOT DEFINED VALIDATE_EXECUTABLE)
   64 endif(BRLCAD_ENABLE_STRICT)
   65 
   66 # Handle default exec and sanity checking for XSLT
   67 if(NOT DEFINED XSLT_EXECUTABLE)
   68   set(XSLT_EXECUTABLE "xsltproc")
   69 else(NOT DEFINED XSLT_EXECUTABLE)
   70   if(NOT EXISTS "${BRLCAD_SOURCE_DIR}/misc/CMake/${XSLT_EXECUTABLE}.cmake.in")
   71     message(FATAL_ERROR "Specified ${XSLT_EXECUTABLE} for DocBook processing, but \"${BRLCAD_SOURCE_DIR}/misc/CMake/${XSLT_EXECUTABLE}.cmake.in\" does not exist.  To use ${XSLT_EXECUTABLE} a ${XSLT_EXECUTABLE}.cmake.in file must be defined.")
   72   endif(NOT EXISTS "${BRLCAD_SOURCE_DIR}/misc/CMake/${XSLT_EXECUTABLE}.cmake.in")
   73 endif(NOT DEFINED XSLT_EXECUTABLE)
   74 
   75 # Handle default exec and sanity checking for PDF conversion
   76 if(NOT DEFINED PDF_CONV_EXECUTABLE)
   77   set(PDF_CONV_EXECUTABLE "fop")
   78 else(NOT DEFINED PDF_CONF_EXECUTABLE)
   79   if(NOT EXISTS "${BRLCAD_SOURCE_DIR}/misc/CMake/${PDF_CONF_EXECUTABLE}.cmake.in")
   80     message(FATAL_ERROR "Specified ${PDF_CONF_EXECUTABLE} for DocBook pdf conversion, but \"${BRLCAD_SOURCE_DIR}/misc/CMake/${PDF_CONF_EXECUTABLE}.cmake.in\" does not exist.  To use ${PDF_CONF_EXECUTABLE} a ${PDF_CONF_EXECUTABLE}.cmake.in file must be defined.")
   81   endif(NOT EXISTS "${BRLCAD_SOURCE_DIR}/misc/CMake/${PDF_CONF_EXECUTABLE}.cmake.in")
   82 endif(NOT DEFINED PDF_CONV_EXECUTABLE)
   83 
   84 # Get our root path
   85 if(CMAKE_CONFIGURATION_TYPES)
   86   set(bin_root "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}")
   87 else(CMAKE_CONFIGURATION_TYPES)
   88   set(bin_root "${CMAKE_BINARY_DIR}")
   89 endif(CMAKE_CONFIGURATION_TYPES)
   90 
   91 # xsltproc is finicky about slashes in names - do some
   92 # sanity scrubbing of the full root path string in
   93 # preparation for generating DocBook scripts
   94 string(REGEX REPLACE "/+" "/" bin_root "${bin_root}")
   95 string(REGEX REPLACE "/$" "" bin_root "${bin_root}")
   96 
   97 set(OUTPUT_FORMATS)
   98 if(BRLCAD_EXTRADOCS_HTML)
   99   set(OUTPUT_FORMATS ${OUTPUT_FORMATS} HTML)
  100 endif(BRLCAD_EXTRADOCS_HTML)
  101 if(BRLCAD_EXTRADOCS_PHP)
  102   set(OUTPUT_FORMATS ${OUTPUT_FORMATS} PHP)
  103 endif(BRLCAD_EXTRADOCS_PHP)
  104 if(BRLCAD_EXTRADOCS_PPT)
  105   set(OUTPUT_FORMATS ${OUTPUT_FORMATS} PPT)
  106 endif(BRLCAD_EXTRADOCS_PPT)
  107 if(BRLCAD_EXTRADOCS_MAN)
  108   set(OUTPUT_FORMATS ${OUTPUT_FORMATS} MAN1)
  109   set(OUTPUT_FORMATS ${OUTPUT_FORMATS} MAN3)
  110   set(OUTPUT_FORMATS ${OUTPUT_FORMATS} MAN5)
  111   set(OUTPUT_FORMATS ${OUTPUT_FORMATS} MANN)
  112 endif(BRLCAD_EXTRADOCS_MAN)
  113 if(BRLCAD_EXTRADOCS_PDF)
  114   set(OUTPUT_FORMATS ${OUTPUT_FORMATS} PDF)
  115 endif(BRLCAD_EXTRADOCS_PDF)
  116 
  117 set(HTML_EXTENSION "html")
  118 set(PHP_EXTENSION "php")
  119 set(PPT_EXTENSION "ppt.html")
  120 set(MAN1_EXTENSION "1")
  121 set(MAN3_EXTENSION "3")
  122 set(MAN5_EXTENSION "5")
  123 set(MANN_EXTENSION "nged")
  124 set(PDF_EXTENSION "pdf")
  125 
  126 set(HTML_DIR "${DOC_DIR}/html/")
  127 set(PHP_DIR "${DOC_DIR}/html/")
  128 set(PPT_DIR "${DOC_DIR}/html/")
  129 set(MAN1_DIR "${DOC_DIR}/../man/")
  130 set(MAN3_DIR "${DOC_DIR}/../man/")
  131 set(MAN5_DIR "${DOC_DIR}/../man/")
  132 set(MANN_DIR "${DOC_DIR}/../man/")
  133 set(PDF_DIR "${DOC_DIR}/pdf/")
  134 
  135 # The general pattern of the BRL-CAD build is to use CMAKE_CFG_INTDIR when
  136 # multi-configuration builds complicate the location of binaries.  In this
  137 # case, however, we are using a generated script with a different mechanism
  138 # for handling this situation, and we need to update the executable paths
  139 # accordingly if they are configuration dependent.
  140 if(CMAKE_CONFIGURATION_TYPES)
  141   string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" XMLLINT_EXEC "${XMLLINT_EXECUTABLE}")
  142   string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" XSLTPROC_EXEC "${XSLTPROC_EXECUTABLE}")
  143 else(CMAKE_CONFIGURATION_TYPES)
  144   set(XMLLINT_EXEC "${XMLLINT_EXECUTABLE}")
  145   set(XSLTPROC_EXEC "${XSLTPROC_EXECUTABLE}")
  146 endif(CMAKE_CONFIGURATION_TYPES)
  147 
  148 # Convenience target to launch all DocBook builds
  149 add_custom_target(docbook ALL)
  150 set_target_properties(docbook PROPERTIES FOLDER "DocBook")
  151 if (TARGET brlcad_css)
  152   add_dependencies(docbook brlcad_css)
  153 endif (TARGET brlcad_css)
  154 
  155 macro(ADD_DOCBOOK fmts in_xml_files outdir deps_list)
  156 
  157   # If we got the name of a list or an explicit list,
  158   # translate into the form we need.
  159   list(GET ${in_xml_files} 0 xml_files)
  160   if("${xml_files}" MATCHES "NOTFOUND")
  161     set(xml_files ${in_xml_files})
  162   else("${xml_files}" MATCHES "NOTFOUND")
  163     set(xml_files ${${in_xml_files}})
  164   endif("${xml_files}" MATCHES "NOTFOUND")
  165 
  166   # Get a target name that is unique but at least has
  167   # some information about what/where the target is.
  168   get_filename_component(dname_root1 "${CMAKE_CURRENT_SOURCE_DIR}" NAME_WE)
  169   get_filename_component(dname_path1  "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
  170   get_filename_component(dname_root2 "${dname_path1}" NAME_WE)
  171   get_filename_component(dname_path2  "${dname_path1}" PATH)
  172   get_filename_component(dname_root3 "${dname_path2}" NAME_WE)
  173   set(inc_num 0)
  174   set(target_root "${dname_root3}-${dname_root2}-${dname_root1}")
  175   while(TARGET docbook-${target_root})
  176     math(EXPR inc_num "${inc_num} + 1")
  177     set(target_root "${dname_root3}-${dname_root2}-${dname_root1}-${inc_num}")
  178   endwhile(TARGET docbook-${target_root})
  179 
  180   # Mark files for distcheck
  181   CMAKEFILES(${xml_files})
  182 
  183   if(BRLCAD_EXTRADOCS)
  184     set(all_outfiles)
  185 
  186     # Each file gets its own script file and custom command, which handle all
  187     # the outputs to be produced from that file.
  188     foreach(fname ${xml_files})
  189       get_filename_component(fname_root "${fname}" NAME_WE)
  190       get_filename_component(filename "${fname}" ABSOLUTE)
  191 
  192       # Find out which outputs we're actually going to produce, between
  193       # what's currently enabled and what the command says the target
  194       # *can* produce
  195       set(CURRENT_OUTPUT_FORMATS)
  196       foreach(fmt ${fmts})
  197     list(FIND OUTPUT_FORMATS "${fmt}" IN_LIST)
  198     if(NOT "${IN_LIST}" STREQUAL "-1")
  199       set(CURRENT_OUTPUT_FORMATS ${CURRENT_OUTPUT_FORMATS} ${fmt})
  200     endif(NOT "${IN_LIST}" STREQUAL "-1")
  201       endforeach(fmt ${fmts})
  202 
  203       # Now that we know our formats, prepare output paths
  204       set(outputs)
  205       foreach(fmt ${fmts})
  206     list(FIND OUTPUT_FORMATS "${fmt}" IN_LIST)
  207     if(NOT "${IN_LIST}" STREQUAL "-1")
  208       set(${fmt}_OUTFILE_RAW "${bin_root}/${${fmt}_DIR}${outdir}/${fname_root}.${${fmt}_EXTENSION}")
  209       # Use CMAKE_CFG_INTDIR for build system output list, but need
  210       # BUILD_TYPE form of path for scripts and install commands.
  211       if(CMAKE_CONFIGURATION_TYPES)
  212         string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" ${fmt}_OUTFILE "${${fmt}_OUTFILE_RAW}")
  213       else(CMAKE_CONFIGURATION_TYPES)
  214         set(${fmt}_OUTFILE "${${fmt}_OUTFILE_RAW}")
  215       endif(CMAKE_CONFIGURATION_TYPES)
  216       set(outputs ${outputs} ${${fmt}_OUTFILE_RAW})
  217       install(FILES "${${fmt}_OUTFILE}" DESTINATION ${${fmt}_DIR}${outdir})
  218     endif(NOT "${IN_LIST}" STREQUAL "-1")
  219       endforeach(fmt ${OUTPUT_FORMATS})
  220 
  221       # If we have more outputs than the default, they need to be handled here.
  222       foreach(fmt ${fmts})
  223     list(FIND OUTPUT_FORMATS "${fmt}" IN_LIST)
  224     if(NOT "${IN_LIST}" STREQUAL "-1")
  225       set(${fmt}_EXTRAS)
  226       get_property(EXTRA_OUTPUTS SOURCE ${fname} PROPERTY EXTRA_${fmt}_OUTPUTS)
  227       foreach(extra_out ${EXTRA_OUTPUTS})
  228         # Pass the file name to the script's extras list, in case the script
  229         # has to manually place the file in the correct directory...
  230         set(${fmt}_EXTRAS ${${fmt}_EXTRAS} "${extra_out}")
  231 
  232         # Use CMAKE_CFG_INTDIR for build system output list, but need
  233         # BUILD_TYPE form of path for scripts and install commands.
  234         set(${fmt}_EXTRA_RAW "${bin_root}/${${fmt}_DIR}${outdir}/${extra_out}")
  235         if(CMAKE_CONFIGURATION_TYPES)
  236           string(REPLACE "${CMAKE_CFG_INTDIR}" "\${BUILD_TYPE}" ${fmt}_EXTRA "${${fmt}_EXTRA_RAW}")
  237         else(CMAKE_CONFIGURATION_TYPES)
  238           set(${fmt}_EXTRA "${${fmt}_EXTRA_RAW}")
  239         endif(CMAKE_CONFIGURATION_TYPES)
  240         set(outputs ${outputs} ${${fmt}_EXTRA_RAW})
  241         install(FILES "${${fmt}_EXTRA}" DESTINATION ${${fmt}_DIR}${outdir})
  242       endforeach(extra_out ${EXTRA_OUTPUTS})
  243     endif(NOT "${IN_LIST}" STREQUAL "-1")
  244 
  245       endforeach(fmt ${fmts})
  246 
  247       set(all_outfiles ${all_outfiles} ${outputs})
  248 
  249       # As long as we're outputting *something*, we have a target to produce
  250       if(NOT "${outputs}" STREQUAL "")
  251     string(MD5 path_md5 "${CMAKE_CURRENT_SOURCE_DIR}/${fname}")
  252     configure_file(${BRLCAD_CMAKE_DIR}/docbook.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/dbp_${fname_root}-${path_md5}.cmake @ONLY)
  253     DISTCLEAN("${CMAKE_CURRENT_BINARY_DIR}/dbp_${fname_root}-${path_md5}.cmake")
  254     add_custom_command(
  255       OUTPUT ${outputs}
  256       COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/dbp_${fname_root}-${path_md5}.cmake
  257       DEPENDS ${fname} ${XMLLINT_EXECUTABLE_TARGET} ${XSLTPROC_EXECUTABLE_TARGET} ${DOCBOOK_RESOURCE_FILES} ${deps_list}
  258       )
  259     # For now, we'll skip generating per-input-file build targets - that's not normally how
  260     # the docbook targets are built.
  261     #add_custom_target(docbook-${fname_root}-${path_md5} DEPENDS ${outputs})
  262     #set_target_properties(docbook-${fname_root}-${path_md5} PROPERTIES FOLDER "DocBook")
  263     #if (TARGET brlcad_css)
  264     #  add_dependencies(docbook-${fname_root}-${path_md5} brlcad_css)
  265     #endif (TARGET brlcad_css)
  266       endif(NOT "${outputs}" STREQUAL "")
  267 
  268     endforeach(fname ${xml_files})
  269 
  270     if(NOT "${all_outfiles}" STREQUAL "")
  271       add_custom_target(docbook-${target_root} ALL DEPENDS ${all_outfiles})
  272       set_target_properties(docbook-${target_root} PROPERTIES FOLDER "DocBook")
  273       add_dependencies(docbook docbook-${target_root})
  274     endif(NOT "${all_outfiles}" STREQUAL "")
  275   endif(BRLCAD_EXTRADOCS)
  276 
  277 endmacro(ADD_DOCBOOK)
  278 
  279 # Local Variables:
  280 # tab-width: 8
  281 # mode: cmake
  282 # indent-tabs-mode: t
  283 # End:
  284 # ex: shiftwidth=2 tabstop=8