| 1 |
# #%L |
| 2 |
# OME Files C++ libraries (cmake build infrastructure) |
| 3 |
# %% |
| 4 |
# Copyright © 2015 Open Microscopy Environment: |
| 5 |
# - Massachusetts Institute of Technology |
| 6 |
# - National Institutes of Health |
| 7 |
# - University of Dundee |
| 8 |
# - Board of Regents of the University of Wisconsin-Madison |
| 9 |
# - Glencoe Software, Inc. |
| 10 |
# %% |
| 11 |
# Redistribution and use in source and binary forms, with or without |
| 12 |
# modification, are permitted provided that the following conditions are met: |
| 13 |
# |
| 14 |
# 1. Redistributions of source code must retain the above copyright notice, |
| 15 |
# this list of conditions and the following disclaimer. |
| 16 |
# 2. Redistributions in binary form must reproduce the above copyright notice, |
| 17 |
# this list of conditions and the following disclaimer in the documentation |
| 18 |
# and/or other materials provided with the distribution. |
| 19 |
# |
| 20 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 21 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 24 |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 25 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 26 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 27 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 28 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 29 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 30 |
# POSSIBILITY OF SUCH DAMAGE. |
| 31 |
# |
| 32 |
# The views and conclusions contained in the software and documentation are |
| 33 |
# those of the authors and should not be interpreted as representing official |
| 34 |
# policies, either expressed or implied, of any organization. |
| 35 |
# #L% |
| 36 |
|
| 37 |
find_package(Python3 COMPONENTS Interpreter) |
| 38 |
|
| 39 |
# Sphinx documentation generator |
| 40 |
find_program(SPHINX_BUILD sphinx-build) |
| 41 |
if (SPHINX_BUILD) |
| 42 |
message(STATUS "Looking for sphinx-build - ${SPHINX_BUILD}") |
| 43 |
else() |
| 44 |
message(STATUS "Looking for sphinx-build - not found") |
| 45 |
endif() |
| 46 |
|
| 47 |
set(SPHINX_DEFAULT OFF) |
| 48 |
if(SPHINX_BUILD) |
| 49 |
set(SPHINX_DEFAULT ON) |
| 50 |
endif() |
| 51 |
option(sphinx "Enable sphinx manual page and HTML documentation" ${SPHINX_DEFAULT}) |
| 52 |
option(sphinx-linkcheck "Check sphinx documentation links by default" OFF) |
| 53 |
|
| 54 |
set(BUILD_SPHINX ${sphinx}) |
| 55 |
set(SPHINX_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 56 |
|
| 57 |
function(sphinx_manpages srcdir builddir manvar) |
| 58 |
execute_process(COMMAND "${Python3_EXECUTABLE}" -B ${SPHINX_LIST_DIR}/list-manpages.py |
| 59 |
"${srcdir}" "${builddir}" |
| 60 |
RESULT_VARIABLE sphinx_man_fail |
| 61 |
OUTPUT_VARIABLE MAN_PAGES) |
| 62 |
if (sphinx_man_fail) |
| 63 |
message(WARNING "Failed to get generated sphinx manual pages from ${confdir}") |
| 64 |
endif() |
| 65 |
string(REPLACE "\n" ";" MAN_PAGES "${MAN_PAGES}") |
| 66 |
set(${manvar} "${MAN_PAGES}" PARENT_SCOPE) |
| 67 |
|
| 68 |
message(STATUS "Sphinx manual pages: ${MAN_PAGES}") |
| 69 |
endfunction(sphinx_manpages) |
| 70 |
|
| 71 |
function(sphinx_manpage_dependencies srcdir depvar) |
| 72 |
execute_process(COMMAND "${Python3_EXECUTABLE}" -B ${SPHINX_LIST_DIR}/list-manpage-dependencies.py |
| 73 |
"${srcdir}" |
| 74 |
RESULT_VARIABLE sphinx_dep_fail |
| 75 |
OUTPUT_VARIABLE SPHINX_MAN_DEPENDENCIES) |
| 76 |
if (sphinx_dep_fail) |
| 77 |
message(WARNING "Failed to get Sphinx dependencies from ${confdir}") |
| 78 |
endif() |
| 79 |
string(REPLACE "\n" ";" SPHINX_MAN_DEPENDENCIES "${SPHINX_MAN_DEPENDENCIES}") |
| 80 |
|
| 81 |
set(${depvar} "${SPHINX_MAN_DEPENDENCIES}" PARENT_SCOPE) |
| 82 |
endfunction(sphinx_manpage_dependencies) |
| 83 |
|
| 84 |
function(sphinx_dependencies srcdir depvar) |
| 85 |
file(GLOB_RECURSE CRUDE_SPHINX_DEPENDENCIES "${srcdir}/*.rst") |
| 86 |
foreach(file ${CRUDE_SPHINX_DEPENDENCIES}) |
| 87 |
string(FIND "${file}" "_build" FILE_MATCH) |
| 88 |
if(FILE_MATCH EQUAL -1) |
| 89 |
list(APPEND SPHINX_DEPENDENCIES "${file}") |
| 90 |
endif() |
| 91 |
endforeach() |
| 92 |
set(${depvar} "${SPHINX_DEPENDENCIES}" PARENT_SCOPE) |
| 93 |
endfunction(sphinx_dependencies) |