manual: also install images/*.png with the HTML output
[pulseview.git] / manual / CMakeLists.txt
1 ##
2 ## This file is part of the PulseView project.
3 ##
4 ## Copyright (C) 2018 Gerhard Sittig <gerhard.sittig@gmx.net>
5 ##
6 ## This program is free software: you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, either version 2 of the License, or
9 ## (at your option) any later version.
10 ##
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ## GNU General Public License for more details.
15 ##
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 ##
19
20 find_program(ASCIIDOCTOR_EXECUTABLE NAMES asciidoctor)
21 find_program(ASCIIDOCTOR_PDF_EXECUTABLE NAMES asciidoctor-pdf)
22
23 set(STYLES_DIR "asciidoctor-stylesheet-factory/stylesheets")
24 set(STYLE_SHEET "readthedocs.css")
25 set(MANUAL_SRC "${CMAKE_CURRENT_SOURCE_DIR}/pulseview_manual.txt")
26 set(MANUAL_OUT_HTML "${CMAKE_CURRENT_BINARY_DIR}/pulseview_manual.html")
27 set(MANUAL_OUT_PDF "${CMAKE_CURRENT_BINARY_DIR}/pulseview_manual.pdf")
28
29 add_custom_target(manual-html
30         COMMAND ${ASCIIDOCTOR_EXECUTABLE}
31                 -a stylesheet=${STYLE_SHEET}
32                 -a stylesdir=${CMAKE_CURRENT_SOURCE_DIR}/${STYLES_DIR}
33                 -a toc=left
34                 --destination-dir=${CMAKE_CURRENT_BINARY_DIR}
35                 ${MANUAL_SRC}
36         BYPRODUCTS ${MANUAL_OUT_HTML}
37         DEPENDS ${MANUAL_SRC}
38         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
39         COMMENT "Generating manual, HTML output"
40 )
41 if (ASCIIDOCTOR_PDF_EXECUTABLE)
42         add_custom_target(manual-pdf
43                 COMMAND ${ASCIIDOCTOR_PDF_EXECUTABLE}
44                         -a stylesheet=${STYLE_SHEET}
45                         -a stylesdir=${CMAKE_CURRENT_SOURCE_DIR}/${STYLES_DIR}
46                         --destination-dir=${CMAKE_CURRENT_BINARY_DIR}
47                         ${MANUAL_SRC}
48                 BYPRODUCTS ${MANUAL_OUT_PDF}
49                 DEPENDS ${MANUAL_SRC}
50                 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
51                 COMMENT "Generating manual, HTML output"
52         )
53 else ()
54         add_custom_target(manual-pdf
55                 COMMAND ${CMAKE_COMMAND} -E echo
56                         "asciidoctor-pdf executable is missing, NOT generating HTML output"
57                 DEPENDS ${MANUAL_SRC}
58                 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
59         )
60 endif ()
61 add_custom_target(manual)
62 add_dependencies(manual manual-html manual-pdf)
63
64 set(MANUAL_INST_SUBDIR "share/doc/pulseview")
65 install(
66         FILES ${MANUAL_OUT_HTML} ${MANUAL_OUT_PDF}
67         DESTINATION ${MANUAL_INST_SUBDIR}
68         PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
69         OPTIONAL
70 )
71 if (ASCIIDOCTOR_EXECUTABLE)
72         install(
73                 DIRECTORY images
74                 DESTINATION ${MANUAL_INST_SUBDIR}
75                 FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
76                 PATTERN "*.xcf" EXCLUDE
77         )
78 endif ()