3 # This module looks for some usual Unix commands.
6 include(FindChocolatey)
8 # Strawberry Perl ships with xsltproc but no DocBook XML files, which
9 # is detrimental to our interests. Search for the Chocolatey
10 # versions first, and un-find xsltproc if needed.
11 find_program(XSLTPROC_EXECUTABLE
15 ${CHOCOLATEY_BIN_PATH}
21 string(TOLOWER ${XSLTPROC_EXECUTABLE} _xe_lower)
22 if(${_xe_lower} MATCHES "strawberry")
23 set(_ignore_reason "Strawberry xsltproc found at ${XSLTPROC_EXECUTABLE}. Ignoring.")
24 message(STATUS ${_ignore_reason})
25 set(XSLTPROC_EXECUTABLE XSLTPROC_EXECUTABLE-NOTFOUND CACHE FILEPATH ${_ignore_reason} FORCE)
28 # Handle the QUIETLY and REQUIRED arguments and set XSLTPROC_FOUND to TRUE if
29 # all listed variables are TRUE
30 INCLUDE(FindPackageHandleStandardArgs)
31 FIND_PACKAGE_HANDLE_STANDARD_ARGS(XSLTPROC DEFAULT_MSG XSLTPROC_EXECUTABLE)
33 MARK_AS_ADVANCED(XSLTPROC_EXECUTABLE)
35 set (_common_xsltproc_args
36 --stringparam use.id.as.filename 1
37 --stringparam admon.graphics 1
38 --stringparam admon.graphics.extension .svg
39 --stringparam section.autolabel 1
40 --stringparam section.label.includes.component.label 1
41 --stringparam html.stylesheet ws.css
44 set(_xsltproc_path "${CMAKE_CURRENT_SOURCE_DIR}:${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_BINARY_DIR}/wsluarm_src")
46 # Workaround for parallel build issue with msbuild.
47 # https://gitlab.kitware.com/cmake/cmake/issues/16767
48 if(CMAKE_GENERATOR MATCHES "Visual Studio")
49 # msbuild (as used by the Visual Studio generators) must not depend on the XML
50 # file (otherwise the XML file will be generated multiple times, possibly in
51 # parallel, breaking the build). Workaround: add one dependency to generate
52 # the XML file when outdated, depend on the -stamp file to ensure that the
53 # target is rebuilt when the XML file is regenerated.
54 function(get_docbook_xml_depends varname _dbk_source)
56 "generate_${_dbk_source}"
57 "${CMAKE_CURRENT_BINARY_DIR}/${_dbk_source}-stamp"
62 # Unix Makefiles, Ninja, etc: first dependency enforces that the XML file is
63 # rebuilt when outdated, the second dependency ensures that the target is
64 # rebuilt when the XML file has changed.
65 function(get_docbook_xml_depends varname _dbk_source)
67 "generate_${_dbk_source}"
74 # Translate XML to HTML
77 # single-page or chunked
81 MACRO(XML2HTML _target_dep _dir_pfx _mode _dbk_source _gfx_sources)
82 # We depend on the docbook target to avoid parallel builds.
83 SET(_dbk_dep ${_target_dep}_docbook)
85 # We can pass chunker.xxx parameters to customize the chunked output.
86 # We have to use a custom layer to customize the single-page output.
87 # Set the output encoding for both to UTF-8. Indent the single-page
88 # output because we sometimes need to copy and paste the release
90 IF(${_mode} STREQUAL "chunked")
91 SET(_basedir ${_dir_pfx}_html_chunked)
92 SET(_stylesheet "http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl")
93 SET(_modeparams --stringparam chunker.output.encoding UTF-8 --stringparam chunk.quietly 1)
95 SET(_basedir ${_dir_pfx}_html)
96 SET(_stylesheet ${CMAKE_SOURCE_DIR}/doc/custom_layer_single_html.xsl)
97 SET(_modeparams --output ${_basedir}/index.html)
100 SET(_out_dir ${CMAKE_CURRENT_BINARY_DIR}/${_basedir})
101 SET(_output ${_basedir}/index.html)
102 get_docbook_xml_depends(_dbk_xml_deps "${_dbk_source}")
104 FOREACH(_tmpgfx ${${_gfx_sources}})
105 set(_gfx_deps ${CMAKE_CURRENT_SOURCE_DIR}/${_tmpgfx})
108 SET(_gfx_src_dir ${_dir_pfx}_src/images)
112 COMMAND ${CMAKE_COMMAND}
113 -E make_directory ${_out_dir}
114 COMMAND ${CMAKE_COMMAND}
115 -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${_gfx_src_dir} ${_out_dir}/images
116 COMMAND ${CMAKE_COMMAND}
117 -E copy_if_different ${CMAKE_SOURCE_DIR}/doc/ws.css ${_out_dir}
118 COMMAND ${XSLTPROC_EXECUTABLE}
119 --path "${_xsltproc_path}"
120 --stringparam base.dir ${_basedir}/
121 ${_common_xsltproc_args}
122 --stringparam admon.graphics.path images/
124 --noout ${_stylesheet}
130 custom_layer_single_html.xsl
132 if(${_dir_pfx} STREQUAL wsug)
136 COMMAND ${CMAKE_COMMAND}
137 -E make_directory ${_out_dir}/images/toolbar
138 COMMAND ${CMAKE_COMMAND}
139 -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${_gfx_src_dir}/toolbar ${_out_dir}/images/toolbar