| 1 |
# - Try to find Sphinx (sphinx-build) |
| 2 |
|
| 3 |
# Once done this will define |
| 4 |
# |
| 5 |
# SPHINX_FOUND - system has Sphinx |
| 6 |
# SPHINX_EXECUTABLE - full path to the Sphinx documentation generator tool |
| 7 |
# SPHINX_VERSION - the version of Sphinx which was found, e.g. "1.0.7" |
| 8 |
|
| 9 |
#============================================================================= |
| 10 |
# Copyright (C) 2011 Marie Rognes and Johannes Ring |
| 11 |
# All rights reserved. |
| 12 |
# |
| 13 |
# Redistribution and use in source and binary forms, with or without |
| 14 |
# modification, are permitted provided that the following conditions |
| 15 |
# are met: |
| 16 |
# |
| 17 |
# 1. Redistributions of source code must retain the above copyright |
| 18 |
# notice, this list of conditions and the following disclaimer. |
| 19 |
# 2. Redistributions in binary form must reproduce the above copyright |
| 20 |
# notice, this list of conditions and the following disclaimer in |
| 21 |
# the documentation and/or other materials provided with the |
| 22 |
# distribution. |
| 23 |
# |
| 24 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 25 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 26 |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 27 |
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 28 |
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 29 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 30 |
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 31 |
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 32 |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 33 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 34 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 35 |
# POSSIBILITY OF SUCH DAMAGE. |
| 36 |
#============================================================================= |
| 37 |
|
| 38 |
message(STATUS "Checking for package 'Sphinx'") |
| 39 |
|
| 40 |
# Make sure Python is available |
| 41 |
if (NOT PYTHON_EXECUTABLE) |
| 42 |
find_package(PythonInterp) |
| 43 |
endif() |
| 44 |
|
| 45 |
# Try to find sphinx-build |
| 46 |
find_program(SPHINX_EXECUTABLE sphinx-build |
| 47 |
HINTS ${SPHINX_DIR} $ENV{SPHINX_DIR} |
| 48 |
PATH_SUFFIXES bin |
| 49 |
DOC "Sphinx documentation generator tool" |
| 50 |
) |
| 51 |
|
| 52 |
if (SPHINX_EXECUTABLE) |
| 53 |
# Try to check Sphinx version by importing Sphinx |
| 54 |
execute_process( |
| 55 |
COMMAND ${PYTHON_EXECUTABLE} -c "import sphinx; print(sphinx.__version__)" |
| 56 |
OUTPUT_VARIABLE SPHINX_VERSION |
| 57 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 58 |
|
| 59 |
if (Sphinx_FIND_VERSION) |
| 60 |
# Check if version found is >= required version |
| 61 |
if (NOT "${SPHINX_VERSION}" VERSION_LESS "${Sphinx_FIND_VERSION}") |
| 62 |
set(SPHINX_VERSION_OK TRUE) |
| 63 |
endif() |
| 64 |
else() |
| 65 |
# No specific version of Sphinx is requested |
| 66 |
set(SPHINX_VERSION_OK TRUE) |
| 67 |
endif() |
| 68 |
endif() |
| 69 |
|
| 70 |
mark_as_advanced( |
| 71 |
SPHINX_EXECUTABLE |
| 72 |
SPHINX_VERSION |
| 73 |
SPHINX_VERSION_OK |
| 74 |
) |
| 75 |
|
| 76 |
include(FindPackageHandleStandardArgs) |
| 77 |
find_package_handle_standard_args(Sphinx DEFAULT_MSG |
| 78 |
SPHINX_EXECUTABLE SPHINX_VERSION_OK) |