Skip to content

Commit

Permalink
Replacing FindSphinx.cmake with one that returns a version number.
Browse files Browse the repository at this point in the history
  • Loading branch information
woodbri committed Aug 4, 2013
1 parent cfc2fa3 commit a8e6be1
Showing 1 changed file with 71 additions and 13 deletions.
84 changes: 71 additions & 13 deletions cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,79 @@
#
# Find Sphinx
# Find Sphinx executable to build documentation
# Source: http://ericscottbarr.com/blog/2012/03/sphinx-and-cmake-beautiful-documentation-for-c-projects/
#
# Daniel Kastl 03/2013
# - Try to find Sphinx (sphinx-build)

# Once done this will define
#
# SPHINX_FOUND - system has Sphinx
# SPHINX_EXECUTABLE - full path to the Sphinx documentation generator tool
# SPHINX_VERSION - the version of Sphinx which was found, e.g. "1.0.7"

find_program(SPHINX_EXECUTABLE NAMES sphinx-build
HINTS
$ENV{SPHINX_DIR}
PATH_SUFFIXES bin\r\n DOC "Sphinx documentation generator"
)
#=============================================================================
# Copyright (C) 2011 Marie Rognes and Johannes Ring
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#=============================================================================

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sphinx DEFAULT_MSG\r\n SPHINX_EXECUTABLE
message(STATUS "Checking for package 'Sphinx'")

# Make sure Python is available
if (NOT PYTHON_EXECUTABLE)
find_package(PythonInterp)
endif()

# Try to find sphinx-build
find_program(SPHINX_EXECUTABLE sphinx-build
HINTS ${SPHINX_DIR} $ENV{SPHINX_DIR}
PATH_SUFFIXES bin
DOC "Sphinx documentation generator tool"
)

if (SPHINX_EXECUTABLE)
# Try to check Sphinx version by importing Sphinx
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import sphinx; print sphinx.__version__"
OUTPUT_VARIABLE SPHINX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

if (Sphinx_FIND_VERSION)
# Check if version found is >= required version
if (NOT "${SPHINX_VERSION}" VERSION_LESS "${Sphinx_FIND_VERSION}")
set(SPHINX_VERSION_OK TRUE)
endif()
else()
# No specific version of Sphinx is requested
set(SPHINX_VERSION_OK TRUE)
endif()
endif()

mark_as_advanced(
SPHINX_EXECUTABLE
SPHINX_VERSION
SPHINX_VERSION_OK
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sphinx DEFAULT_MSG
SPHINX_EXECUTABLE SPHINX_VERSION_OK)

0 comments on commit a8e6be1

Please sign in to comment.