Debian Codegraph @

texk/xdvipsk/thirdparty/libtiff/doc/CMakeLists.txt

raw
1 # CMake build for libtiff
2 # Run "cmake" to generate the build files for your platform
3 #
4 # Copyright © 2015 Open Microscopy Environment / University of Dundee
5 # Copyright © 2021-2022 Roger Leigh <[email protected]>
6 # Written by Roger Leigh <[email protected]>
7 #
8 # Permission to use, copy, modify, distribute, and sell this software and
9 # its documentation for any purpose is hereby granted without fee, provided
10 # that (i) the above copyright notices and this permission notice appear in
11 # all copies of the software and related documentation, and (ii) the names of
12 # Sam Leffler and Silicon Graphics may not be used in any advertising or
13 # publicity relating to the software without the specific, prior written
14 # permission of Sam Leffler and Silicon Graphics.
15 #
16 # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
17 # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18 # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19 #
20 # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
21 # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
22 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23 # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
24 # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
25 # OF THIS SOFTWARE.
26
27 include(Sphinx)
28
29 if (BUILD_SPHINX AND SPHINX_BUILD)
30 # Re-run CMake when the Sphinx configuration is updated
31 set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/conf.py")
32
33 message(STATUS "Checking manual page dependencies")
34
35 # Create build directory and conf.py
36 set(sphinx_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
37 set(sphinx_builddir "${CMAKE_CURRENT_BINARY_DIR}")
38 file(MAKE_DIRECTORY "${sphinx_builddir}")
39
40 sphinx_manpages("${sphinx_srcdir}" "${sphinx_builddir}/man" MAN_PAGES)
41 sphinx_manpage_dependencies("${sphinx_srcdir}" MAN_PAGE_DEPENDENCIES)
42 sphinx_dependencies("${sphinx_srcdir}" SPHINX_DEPENDENCIES)
43
44 # Generate and install man pages
45
46 unset(man_target)
47 if(MAN_PAGES)
48 add_custom_command(OUTPUT ${MAN_PAGES}
49 COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/cache"
50 COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/man"
51 COMMAND ${SPHINX_BUILD}
52 -D "release=${LIBTIFF_VERSION_FULL}"
53 -D "version=${tiff_VERSION_MAJOR}.${tiff_VERSION_MINOR}"
54 -d "${sphinx_builddir}/cache"
55 -b man
56 "${sphinx_srcdir}" "${sphinx_builddir}/man"
57 WORKING_DIRECTORY "${sphinx_srcdir}"
58 DEPENDS ${MAN_PAGE_DEPENDENCIES})
59
60 if(NOT TARGET doc-man)
61 add_custom_target(doc-man ALL)
62 endif()
63 add_custom_target(${PROJECT_NAME}-doc-man DEPENDS ${MAN_PAGES})
64 add_dependencies(doc-man ${PROJECT_NAME}-doc-man)
65 set(man_target ${PROJECT_NAME}-doc-man)
66
67 foreach (man ${MAN_PAGES})
68 string(REGEX REPLACE ".*\\.([0-9])[a-z]*\$" "\\1" man_section "${man}")
69 install(FILES "${man}"
70 DESTINATION "${CMAKE_INSTALL_MANDIR}/man${man_section}"
71 COMPONENT "runtime")
72 endforeach()
73 endif()
74
75 # Generate and install HTML manual
76 # Depends on man to allow sharing of cache with parallel build.
77
78 add_custom_command(OUTPUT "${sphinx_builddir}/html/index.html"
79 COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/cache"
80 COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/html"
81 COMMAND ${SPHINX_BUILD}
82 -D "release=${tiff_VERSION}"
83 -D "version=${tiff_VERSION_MAJOR}.${tiff_VERSION_MINOR}"
84 -d "${sphinx_builddir}/cache"
85 -b html
86 "${sphinx_srcdir}" "${sphinx_builddir}/html"
87 WORKING_DIRECTORY "${sphinx_srcdir}"
88 DEPENDS ${man_target} ${SPHINX_DEPENDENCIES})
89
90 if(NOT TARGET doc-html)
91 add_custom_target(doc-html ALL)
92 endif()
93 add_custom_target(${PROJECT_NAME}-doc-html DEPENDS "${sphinx_builddir}/html/index.html")
94 add_dependencies(doc-html ${PROJECT_NAME}-doc-html)
95
96 install(DIRECTORY "${sphinx_builddir}/html"
97 DESTINATION "${CMAKE_INSTALL_DOCDIR}/manual"
98 COMPONENT "runtime")
99
100 if(sphinx-linkcheck)
101 set(sphinx_linkcheck_all ALL)
102 endif()
103
104 if(NOT TARGET doc-linkcheck)
105 add_custom_target(doc-linkcheck)
106 endif()
107 add_custom_target(${PROJECT_NAME}-doc-linkcheck ${sphinx_linkcheck_all}
108 COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/cache"
109 COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/linkcheck"
110 COMMAND ${SPHINX_BUILD}
111 -D "release=${tiff_VERSION}"
112 -D "version=${tiff_VERSION_MAJOR}.${tiff_VERSION_MINOR}"
113 -c "${sphinx_builddir}"
114 -d "${sphinx_builddir}/cache"
115 -b linkcheck
116 "${sphinx_srcdir}" "${sphinx_builddir}/linkcheck"
117 COMMENT "Checking remote links in sphinx documentation"
118 WORKING_DIRECTORY "${sphinx_srcdir}"
119 DEPENDS ${man_target} ${SPHINX_DEPENDENCIES})
120 add_dependencies(doc-linkcheck ${PROJECT_NAME}-doc-linkcheck)
121
122 if(NOT TARGET doc-locallinkcheck)
123 add_custom_target(doc-locallinkcheck)
124 endif()
125 add_custom_target(${PROJECT_NAME}-doc-locallinkcheck ${sphinx_linkcheck_all}
126 COMMAND ${CMAKE_COMMAND}
127 "-DOUTPUT=${sphinx_builddir}/linkcheck/output.txt"
128 "-DSPHINX_INSTALL_PATH=${PROJECT_NAME}/manual/html"
129 "-DINTERNAL_REFERENCE=${sphinx_builddir}/html"
130 "-DEXTERNAL_REFERENCE=${CMAKE_INSTALL_FULL_DATAROOTDIR}/doc"
131 "-DDOXYGEN_REFERENCE=${PROJECT_BINARY_DIR}/docs/doxygen/api"
132 "-DDOXYGEN_INSTALL_PATH=${PROJECT_NAME}/api"
133 -P "${PROJECT_SOURCE_DIR}/cmake/SphinxCheckInternalLinks.cmake"
134 COMMENT "Checking local links in sphinx documentation"
135 WORKING_DIRECTORY "${sphinx_srcdir}"
136 DEPENDS doc-linkcheck)
137 add_dependencies(doc-locallinkcheck ${PROJECT_NAME}-doc-locallinkcheck)
138 elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/html-prebuilt/")
139 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/html-prebuilt/"
140 DESTINATION "${CMAKE_INSTALL_DOCDIR}/manual/html"
141 COMPONENT "runtime")
142 else()
143 message(WARNING "Manual pages and HTML manual will not be generated or installed")
144 endif()