Skip to content

Commit

Permalink
CMake - revisit build and install file locations
Browse files Browse the repository at this point in the history
- add install rules only for xml (gnome-help) and chm (windows help).
  For the other documentation formats there's not much use as they
  are not typically installed
- at build time mimic the install locations. That is all final documents
  that we build will be stored under BUILD_DIR/share/doc/gnucash-docs/LANG
  You will find there a directory for the html format and the final documents
  for the other formats (pdf, chm, epub, mobi)
- files that are only needed to build the end document formats will
  remain in the traditional build directories
  (BUILDDIR/guide/LANG and BUILDDIR/help/LANG)
  These are for example the intermediate fo file (which is used
  for final pdf generation), the fop xconf file, a temporary directory
  used for epub generation,...
  • Loading branch information
gjanssens committed Sep 7, 2019
1 parent 715f7fa commit ee29380
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 54 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -52,6 +52,10 @@ set(JAPANESE_MINCHO_TTF "ume-tmo3.ttf" CACHE STRING "Mincho TrueType font used f
set(JAPANESE_GOTHIC_TTF "ume-tmo3.ttf" CACHE STRING "Gothic TrueType font used for Japanese pdf")
set(japanese_fontdir "${CMAKE_SOURCE_DIR}/fonts/truetype" CACHE STRING "Directory to search for Japanese fonts")

# Buildtime destination directories for our generated documentation
set(DATADIR_BUILD "${CMAKE_BINARY_DIR}/share")
set(DOCDIR_BUILD "${DATADIR_BUILD}/doc/${PACKAGE}")

# ############################################################
# Find the documentation dependencies

Expand Down
12 changes: 11 additions & 1 deletion cmake/AddChmTarget.cmake
Expand Up @@ -3,6 +3,9 @@ function (add_chm_target docname lang entities figdir)
set(chmfile "${docname}.chm")
set(mapfile "${docname}.hhmap")

set(BUILD_DIR "${DOCDIR_BUILD}/${lang}")
file(MAKE_DIRECTORY "${BUILD_DIR}")

file(GLOB figures "${CMAKE_CURRENT_SOURCE_DIR}/${figdir}/*.png")

file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/htmlhelp")
Expand All @@ -12,15 +15,22 @@ function (add_chm_target docname lang entities figdir)
-D SRC_DIR=${CMAKE_SOURCE_DIR}
-D CURRENT_SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-D CURRENT_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}
-D BUILD_DIR=${BUILD_DIR}
-D XSLTPROC=${XSLTPROC}
"-DXSLTPROCFLAGS=\"${XSLTPROCFLAGS}\""
"-Dentities=\"${entities}\""
-D HHC=${HHC}
-P ${CMAKE_SOURCE_DIR}/cmake/MakeChm.cmake
# TODO amend htmlhelp.hhp, create mymaps and htmlhelp.hhmap, run hhc
BYPRODUCTS "${BUILD_DIR}/${chmfile}" "${BUILD_DIR}/${mapfile}"
DEPENDS ${entities} "${docname}.xml" "${CMAKE_SOURCE_DIR}/docbook/gnc-docbookx.dtd" ${figures}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/htmlhelp")

add_dependencies(${docname}-chm "${lang}-${docname}-chm")

install(FILES
"${BUILD_DIR}/${chmfile}"
"${BUILD_DIR}/${mapfile}"
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${lang}"
COMPONENT "${docname}-chm")

endfunction()
22 changes: 13 additions & 9 deletions cmake/AddEpubTarget.cmake
@@ -1,9 +1,12 @@
function (add_epub_target docname lang entities figdir)

set(epubfile "${docname}.epub")
set(EPUB_TMPDIR "${CMAKE_CURRENT_BINARY_DIR}/epub_tmp")
set(EPUB_TMPDIR "${CMAKE_CURRENT_BINARY_DIR}/epub")
file(GLOB figures "${CMAKE_CURRENT_SOURCE_DIR}/${figdir}/*.png")

set(BUILD_DIR "${DOCDIR_BUILD}/${lang}")
file(MAKE_DIRECTORY "${BUILD_DIR}")

add_custom_target("${lang}-${docname}-epub"
COMMAND rm -fr "${EPUB_TMPDIR}"
COMMAND mkdir "${EPUB_TMPDIR}"
Expand All @@ -17,26 +20,27 @@ function (add_epub_target docname lang entities figdir)
"${CMAKE_SOURCE_DIR}/xsl/1.79.2/epub/docbook.xsl"
"${CMAKE_CURRENT_SOURCE_DIR}/${docname}.xml"
COMMAND cmake -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/figures" "${EPUB_TMPDIR}/OEBPS/figures"
COMMAND cd "${EPUB_TMPDIR}" && zip -X -r ../${epubfile} mimetype META-INF OEBPS
COMMAND cd "${EPUB_TMPDIR}" && zip -X -r "${BUILD_DIR}/${epubfile}" mimetype META-INF OEBPS
BYPRODUCTS "${BUILD_DIR}/${epubfile}"
DEPENDS ${entities} "${docname}.xml" "${CMAKE_SOURCE_DIR}/docbook/gnc-docbookx.dtd" ${figures})

add_dependencies(${docname}-epub "${lang}-${docname}-epub")

# CLEANFILES += $(epubfile)

endfunction()

function (add_mobi_target docname lang)

set(epubfile "${CMAKE_CURRENT_BINARY_DIR}/${docname}.epub")
set(mobifile "${CMAKE_CURRENT_BINARY_DIR}/${docname}.mobi")
set(BUILD_DIR "${DOCDIR_BUILD}/${lang}")
file(MAKE_DIRECTORY "${BUILD_DIR}")

set(epubfile "${BUILD_DIR}/${docname}.epub")
set(mobifile "${BUILD_DIR}/${docname}.mobi")

add_custom_target("${lang}-${docname}-mobi"
COMMAND ${EBOOK_CONVERT} ${epubfile} ${mobifile}
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${docname}.epub")
BYPRODUCTS "${mobifile}"
DEPENDS "${epubfile}")

add_dependencies(${docname}-mobi "${lang}-${docname}-mobi")

# CLEANFILES += $(epubfile)

endfunction()
41 changes: 7 additions & 34 deletions cmake/AddHtmlTarget.cmake
Expand Up @@ -14,62 +14,35 @@ function (add_html_target docname lang entities figdir)
set(styledir "${CMAKE_SOURCE_DIR}/stylesheet")
file(GLOB styleicons "${CMAKE_SOURCE_DIR}/stylesheet/*.png")

# TODO clean target
#CLEANFILES += $(docname)/*.html
set(BUILD_DIR "${DOCDIR_BUILD}/${lang}/${docname}")
file(MAKE_DIRECTORY "${BUILD_DIR}")

# Convert xml to html with xsltproc
# xsltproc --xinclude -o outputdir/ /usr/share/sgml/docbook/xsl-stylesheets/html/chunk.xsl filename.xml
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${docname}")
add_custom_target("${lang}-${docname}-html-files"
COMMAND ${XSLTPROC} ${XSLTPROCFLAGS} ${XSLTPROCFLAGS_HTML}
-o "${CMAKE_CURRENT_BINARY_DIR}/${docname}/"
-o "${BUILD_DIR}/"
--param use.id.as.filename "1"
--stringparam chunker.output.encoding UTF-8
"${CMAKE_SOURCE_DIR}/xsl/general-customization.xsl"
"${CMAKE_CURRENT_SOURCE_DIR}/${docname}.xml"
DEPENDS ${entities} "${docname}.xml" "${CMAKE_SOURCE_DIR}/docbook/gnc-docbookx.dtd")

# Copy figures for this document
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${docname}/${figdir}")
file(MAKE_DIRECTORY "${BUILD_DIR}/${figdir}")
add_custom_target("${lang}-${docname}-html-figures"
COMMAND ${CMAKE_COMMAND} -E copy ${figures} "${CMAKE_CURRENT_BINARY_DIR}/${docname}/${figdir}"
COMMAND ${CMAKE_COMMAND} -E copy ${figures} "${BUILD_DIR}/${figdir}"
DEPENDS ${figures})

# Copy style icons for this document (warning, info,...)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${docname}/stylesheet")
file(MAKE_DIRECTORY "${BUILD_DIR}/stylesheet")
add_custom_target("${lang}-${docname}-html-style"
COMMAND ${CMAKE_COMMAND} -E copy ${styleicons} "${CMAKE_CURRENT_BINARY_DIR}/${docname}/stylesheet"
COMMAND ${CMAKE_COMMAND} -E copy ${styleicons} "${BUILD_DIR}/stylesheet"
DEPENDS ${styleicons})

add_custom_target("${lang}-${docname}-html"
DEPENDS "${lang}-${docname}-html-files" "${lang}-${docname}-html-figures" "${lang}-${docname}-html-style")

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

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${docname}
DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PACKAGE_NAME}/${lang}"
COMPONENT "${lang}-${docname}-html")

# TODO uninstall target
# uninstall-html:
# -if test "$(docname)"; then \
# if test "$(figdir)"; then \
# for file in $(docname)/$(figdir)/*.png; do \
# basefile=`basename $$file`; \
# rm -f "$(DESTDIR)$(otherdocdir)/$(docname)/$(figdir)/$$basefile"; \
# done; \
# rmdir --ignore-fail-on-non-empty "$(DESTDIR)$(otherdocdir)/$(docname)/$(figdir)"; \
# fi; \
# for file in $(styledir)/*.png; do \
# basefile=`basename $$file`; \
# rm -f "$(DESTDIR)$(otherdocdir)/$(docname)/stylesheet/$$basefile"; \
# done; \
# rmdir --ignore-fail-on-non-empty "$(DESTDIR)$(otherdocdir)/$(docname)/stylesheet"; \
# for file in $(docname)/*.html; do \
# basefile=`basename $$file`; \
# rm -f "$(DESTDIR)$(otherdocdir)/$(docname)/$$basefile"; \
# done; \
# rmdir --ignore-fail-on-non-empty "$(DESTDIR)$(otherdocdir)/$(docname)"; \
# rmdir --ignore-fail-on-non-empty "$(DESTDIR)$(otherdocdir)"; \
# fi
endfunction()
7 changes: 6 additions & 1 deletion cmake/AddPdfTarget.cmake
Expand Up @@ -4,6 +4,9 @@ function (add_pdf_target docname lang entities figdir)
set(pdffile "${docname}.pdf")
file(GLOB figures "${CMAKE_CURRENT_SOURCE_DIR}/${figdir}/*.png")

set(BUILD_DIR "${DOCDIR_BUILD}/${lang}")
file(MAKE_DIRECTORY "${BUILD_DIR}")

# Determine paper format depending on language (which maps to the document's directory name)
# * for language "C" (fallback language) determine paper format based on current locale
# * for other languages, the will be set to letter. All others use A4.
Expand All @@ -23,6 +26,7 @@ function (add_pdf_target docname lang entities figdir)
--stringparam fop1.extensions 1
"${CMAKE_SOURCE_DIR}/xsl/1.79.2/fo/docbook.xsl"
"${CMAKE_CURRENT_SOURCE_DIR}/${docname}.xml"
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/${fofile}"
DEPENDS ${entities} "${docname}.xml" "${CMAKE_SOURCE_DIR}/docbook/gnc-docbookx.dtd")

configure_file("${FOP_XCONF}" "${CMAKE_CURRENT_BINARY_DIR}/fop.xconf")
Expand All @@ -31,7 +35,8 @@ function (add_pdf_target docname lang entities figdir)
-l ${lang}
-c "${CMAKE_CURRENT_BINARY_DIR}/fop.xconf"
-fo "${CMAKE_CURRENT_BINARY_DIR}/${fofile}"
-pdf "${CMAKE_CURRENT_BINARY_DIR}/${pdffile}"
-pdf "${BUILD_DIR}/${pdffile}"
BYPRODUCTS "${BUILD_DIR}/${pdffile}"
DEPENDS ${lang}-${docname}-fo ${figures})

add_dependencies(${docname}-pdf "${lang}-${docname}-pdf")
Expand Down
8 changes: 3 additions & 5 deletions cmake/AddXmlTarget.cmake
Expand Up @@ -17,10 +17,10 @@ function (add_xml_target docname lang entities figdir)

install(FILES ${xml_files}
DESTINATION "${CMAKE_INSTALL_DATADIR}/gnome/help/${docname}/${lang}"
COMPONENT "${lang}-${docname}-xml")
COMPONENT "${docname}-xml")
install(FILES ${figures}
DESTINATION "${CMAKE_INSTALL_DATADIR}/gnome/help/${docname}/${lang}/${figdir}"
COMPONENT "${lang}-${docname}-xml")
COMPONENT "${docname}-xml")

add_custom_target("${lang}-${docname}-check"
COMMAND ${XMLLINT} --postvalid
Expand All @@ -32,10 +32,8 @@ function (add_xml_target docname lang entities figdir)

add_dependencies(${docname}-check "${lang}-${docname}-check")

# TODO Uninstall and dist targets
# TODO Uninstall target
# uninstall-hook:
# rmdir --ignore-fail-on-non-empty "$(DESTDIR)$(gnomehelpfiguresdir)"
# rmdir --ignore-fail-on-non-empty "$(DESTDIR)$(gnomehelpdir)"
#
# EXTRA_DIST = ${xml_files} ${omffile} ${figures}
endfunction()
10 changes: 6 additions & 4 deletions cmake/MakeChm.cmake
Expand Up @@ -58,11 +58,13 @@ set(HHP "${HHP};${MAP}")
string(REPLACE ";" "\n" HHP_OUT "${HHP}")
string(REPLACE ";" "\n" HHMAP_OUT "${HHMAP}")
file(APPEND "${htmlhelpdir}/htmlhelp.hhp" ${HHP_OUT})
file(WRITE "${CURRENT_BIN_DIR}/htmlhelp/${mapfile}" ${HHMAP_OUT})
file(WRITE "${BUILD_DIR}/${mapfile}" ${HHMAP_OUT})

execute_process(
COMMAND ${HHC} htmlhelp.hhp
WORKING_DIRECTORY "${CURRENT_BIN_DIR}/htmlhelp"
# OUTPUT_QUIET
# ERROR_QUIET
WORKING_DIRECTORY "${htmlhelpdir}"
OUTPUT_QUIET
ERROR_QUIET
)

file(COPY "${htmlhelpdir}/${docname}.chm" DESTINATION "${BUILD_DIR}")

0 comments on commit ee29380

Please sign in to comment.