4 # SPHINX_EXECUTABLE - path to the Sphinx executable
5 # SPHINX_PYTHONPATH - path to the Sphinx Python modules
8 # Sphinx_EXTENSIONS - optional variable which can be used to specify
9 # a list of required Sphinx extensions; not found
10 # extensions will be reported during the detection
11 # procedure; by default this variable is empty.
13 # set(Sphinx_EXTENSIONS sphinxcontrib.napoleon)
15 ###########################################################################
16 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
18 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
19 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
21 # This library is free software; you can redistribute it and/or
22 # modify it under the terms of the GNU Lesser General Public
23 # License as published by the Free Software Foundation; either
24 # version 2.1 of the License, or (at your option) any later version.
26 # This library is distributed in the hope that it will be useful,
27 # but WITHOUT ANY WARRANTY; without even the implied warranty of
28 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 # Lesser General Public License for more details.
31 # You should have received a copy of the GNU Lesser General Public
32 # License along with this library; if not, write to the Free Software
33 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
38 FIND_PROGRAM(SPHINX_EXECUTABLE
39 NAMES sphinx-build sphinx-build-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}
40 PATH_SUFFIXES Scripts)
41 FIND_PROGRAM(SPHINX_APIDOC_EXECUTABLE
42 NAMES sphinx-apidoc sphinx-apidoc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}
43 PATH_SUFFIXES Scripts)
44 FIND_PROGRAM(SPHINX_INTL_EXECUTABLE
45 NAMES sphinx-intl sphinx-intl-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}
46 PATH_SUFFIXES Scripts)
49 # Get root dir locally, going up two levels from the exec:
50 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${SPHINX_EXECUTABLE}" PATH)
51 GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH)
53 SET(SPHINX_PYTHONPATH "${_tmp_ROOT_DIR}/lib/site-packages")
55 SET(SPHINX_PYTHONPATH "${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
58 # Handle the standard arguments of the find_package() command:
59 INCLUDE(FindPackageHandleStandardArgs)
60 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx REQUIRED_VARS SPHINX_EXECUTABLE SPHINX_APIDOC_EXECUTABLE SPHINX_INTL_EXECUTABLE)
63 EXECUTE_PROCESS(COMMAND ${SPHINX_EXECUTABLE} "--version" OUTPUT_VARIABLE SPHINX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
64 STRING(REGEX REPLACE ".* ([0-9.]+)$" "\\1" SPHINX_VERSION "${SPHINX_VERSION}" )
65 MESSAGE(STATUS "Sphinx version is ${SPHINX_VERSION}")
66 IF(SPHINX_VERSION VERSION_LESS "1.3")
67 SET(SPHINX_THEME "default")
69 SET(SPHINX_THEME "classic")
71 ENDIF(SPHINX_EXECUTABLE)
73 FOREACH(_ext ${Sphinx_EXTENSIONS})
74 EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import ${_ext}; print 'ok'" OUTPUT_VARIABLE _has_ext ERROR_QUIET)
76 MESSAGE(STATUS "Required Sphinx extension '${_ext}' has been found!")
78 MESSAGE(WARNING "Required Sphinx extension '${_ext}' is not found!")