Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 18 additions & 35 deletions cmake/AddHtmlTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,31 @@
function (add_html_target targetbase lang entities figures xslt_file)

set(docname "gnucash-${targetbase}")
set(styledir "${CMAKE_SOURCE_DIR}/stylesheet")
file(GLOB styleicons "${CMAKE_SOURCE_DIR}/stylesheet/*.png")
set(BUILD_DIR "${DOCDIR_BUILD}/${lang}/${docname}")

if (NOT IS_ABSOLUTE ${xslt_file})
set(xslt_file "${CMAKE_CURRENT_SOURCE_DIR}/${xslt_file}")
endif()

file(MAKE_DIRECTORY "${BUILD_DIR}" "${BUILD_DIR}/figures" "${BUILD_DIR}/stylesheet")

# Copy figures for this document
foreach(figure ${figures})
configure_file(${figure} ${BUILD_DIR}/figures COPYONLY)
endforeach()
file(GLOB dest_figures "${BUILD_DIR}/${figures}")

# Copy style icons for this document (warning, info, ...)
file(GLOB styleicons "${CMAKE_SOURCE_DIR}/stylesheet/*.png")
foreach(styleicon ${styleicons})
configure_file(${styleicon} ${BUILD_DIR}/stylesheet COPYONLY)
endforeach()
file(GLOB dest_styleicons "${BUILD_DIR}/stylesheet/*")

# Convert xml to html with xsltproc
# xsltproc --xinclude -o outputdir/ /usr/share/sgml/docbook/xsl-stylesheets/html/chunk.xsl filename.xml
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/htmltrigger"
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILD_DIR}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILD_DIR}/figures"
COMMAND ${CMAKE_COMMAND} -E make_directory "${BUILD_DIR}/stylesheet"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/htmltrigger"
COMMAND ${XSLTPROC} ${XSLTPROCFLAGS} ${XSLTPROCFLAGS_HTML}
-o "${BUILD_DIR}/"
--param use.id.as.filename "1"
Expand All @@ -35,41 +45,14 @@ function (add_html_target targetbase lang entities figures xslt_file)
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/htmltrigger"
DEPENDS ${entities} "index.docbook" "${CMAKE_SOURCE_DIR}/docbook/gnc-docbookx.dtd")

# Copy figures for this document
set(source_figures "")
foreach(figure ${figures})
list(APPEND source_figures "${CMAKE_CURRENT_SOURCE_DIR}/${figure}")
endforeach()

set(dest_figures "")
foreach(figure ${figures})
list(APPEND dest_figures "${BUILD_DIR}/${figure}")
endforeach()

if(dest_figures)
add_custom_command(
OUTPUT ${dest_figures}
COMMAND ${CMAKE_COMMAND} -E copy ${source_figures} "${BUILD_DIR}/figures"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/html_figtrigger"
DEPENDS ${source_figures} "${CMAKE_CURRENT_BINARY_DIR}/htmltrigger")
endif()

# Copy style icons for this document (warning, info,...)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/styletrigger"
COMMAND ${CMAKE_COMMAND} -E copy ${styleicons} "${BUILD_DIR}/stylesheet"
COMMAND touch "${CMAKE_CURRENT_BINARY_DIR}/styletrigger"
DEPENDS ${styleicons} "${CMAKE_CURRENT_BINARY_DIR}/htmltrigger")

add_custom_target("${lang}-${targetbase}-html"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/htmltrigger"
${dest_figures}
"${CMAKE_CURRENT_BINARY_DIR}/styletrigger")
${dest_figures} ${dest_styleicons})

add_dependencies(${lang}-html "${lang}-${targetbase}-html")

if(WITH_HTML_INSTALL)
install(DIRECTORY ${BUILD_DIR}
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${lang}")
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${lang}")
endif()
endfunction()