]> sigrok.org Git - pulseview.git/blame - manual/CMakeLists.txt
Session: Fix issue #67 by improving error handling
[pulseview.git] / manual / CMakeLists.txt
CommitLineData
f2f536aa
GS
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
074da67e
GS
20cmake_minimum_required(VERSION 2.8.12)
21
16d72fc1
GS
22project(PV_MANUAL)
23
4596756f 24# External dependencies, required and optional tools.
f2f536aa
GS
25find_program(ASCIIDOCTOR_EXECUTABLE NAMES asciidoctor)
26find_program(ASCIIDOCTOR_PDF_EXECUTABLE NAMES asciidoctor-pdf)
27
4596756f 28# Tunables.
e6bc4b9d 29set(STYLES_DIR "asciidoctor-stylesheet-factory/stylesheets")
f2f536aa 30set(STYLE_SHEET "readthedocs.css")
4596756f
GS
31
32# Input files.
2eab551b 33set(MANUAL_SRC "${CMAKE_CURRENT_SOURCE_DIR}/manual.txt")
4596756f
GS
34
35# Output files, conversion results.
2eab551b
UH
36set(MANUAL_OUT_HTML "${CMAKE_CURRENT_BINARY_DIR}/manual.html")
37set(MANUAL_OUT_PDF "${CMAKE_CURRENT_BINARY_DIR}/manual.pdf")
f2f536aa 38
cfcda2e6
GS
39# Make in-source images/ content available to the output hierarchy for
40# the inspection of created output documents during development in the
41# case of out-of-source build configurations.
42if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/images")
43 message(STATUS "creating symlink for manual's images/ subdirectory")
44 execute_process(
45 COMMAND ${CMAKE_COMMAND} -E create_symlink
46 "${CMAKE_CURRENT_SOURCE_DIR}/images"
47 "${CMAKE_CURRENT_BINARY_DIR}/images"
48 RESULT_VARIABLE IMAGES_LINK_RESULT
49 )
50 if (NOT IMAGES_LINK_RESULT EQUAL 0)
51 message(WARNING "manual rendering will lack images")
52 endif ()
53endif ()
54
4596756f 55# Manual related make(1) targets.
f2f536aa
GS
56add_custom_target(manual-html
57 COMMAND ${ASCIIDOCTOR_EXECUTABLE}
58 -a stylesheet=${STYLE_SHEET}
e6bc4b9d 59 -a stylesdir=${CMAKE_CURRENT_SOURCE_DIR}/${STYLES_DIR}
f2f536aa
GS
60 -a toc=left
61 --destination-dir=${CMAKE_CURRENT_BINARY_DIR}
62 ${MANUAL_SRC}
63 BYPRODUCTS ${MANUAL_OUT_HTML}
64 DEPENDS ${MANUAL_SRC}
65 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
66 COMMENT "Generating manual, HTML output"
67)
6bbbf1f8
GS
68if (ASCIIDOCTOR_PDF_EXECUTABLE)
69 add_custom_target(manual-pdf
70 COMMAND ${ASCIIDOCTOR_PDF_EXECUTABLE}
71 -a stylesheet=${STYLE_SHEET}
e6bc4b9d 72 -a stylesdir=${CMAKE_CURRENT_SOURCE_DIR}/${STYLES_DIR}
6bbbf1f8
GS
73 --destination-dir=${CMAKE_CURRENT_BINARY_DIR}
74 ${MANUAL_SRC}
75 BYPRODUCTS ${MANUAL_OUT_PDF}
76 DEPENDS ${MANUAL_SRC}
77 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
0f76477f 78 COMMENT "Generating manual, PDF output"
6bbbf1f8
GS
79 )
80else ()
81 add_custom_target(manual-pdf
82 COMMAND ${CMAKE_COMMAND} -E echo
a53b8efe 83 "asciidoctor-pdf executable is missing, NOT generating PDF output"
6bbbf1f8
GS
84 DEPENDS ${MANUAL_SRC}
85 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
86 )
87endif ()
f2f536aa
GS
88add_custom_target(manual)
89add_dependencies(manual manual-html manual-pdf)
7305c218 90
e6bc4b9d 91set(MANUAL_INST_SUBDIR "share/doc/pulseview")
7305c218
GS
92install(
93 FILES ${MANUAL_OUT_HTML} ${MANUAL_OUT_PDF}
e6bc4b9d 94 DESTINATION ${MANUAL_INST_SUBDIR}
7305c218
GS
95 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
96 OPTIONAL
97)
e6bc4b9d
GS
98if (ASCIIDOCTOR_EXECUTABLE)
99 install(
100 DIRECTORY images
101 DESTINATION ${MANUAL_INST_SUBDIR}
102 FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
103 PATTERN "*.xcf" EXCLUDE
104 )
105endif ()