Skip to content

Commit

Permalink
Fail gracefully if doxygen, sphinx, or breate are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Apr 18, 2017
1 parent f3261ac commit 6334bd8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
24 changes: 19 additions & 5 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@
set(SPHINX_EXTRA_OPTIONS "-N;-a;-E" CACHE STRING "Sphinx options")

find_program(SPHINX_BUILD sphinx-build)
find_program(DOXYGEN doxygen)

if(SPHINX_BUILD AND DOXYGEN)
EXECUTE_PROCESS (COMMAND ${PYTHON_EXECUTABLE} -c
"import breathe"
RESULT_VARIABLE _breathe_notfound
OUTPUT_QUIET ERROR_QUIET)
if (NOT ${_breate_notfound} EQUAL 0)
set(MAYBE_BREATHE "")
else()
set(MAYBE_BREATHE "'breathe'")
endif()
endif()

if(SPHINX_BUILD)
message("+-- sphinx-build found, building sphinx documentation")
message("-- + sphinx-build found, building sphinx documentation")
set(SPHINX_PAPER_SIZE "letter" CACHE STRING "Size of paper when generating latex/pdf of documentation. Options are 'letter' or 'a4'")
set(SPHINX_EXTRA_OPTIONS "" CACHE STRING "Extra options to pass to sphinx")

Expand Down Expand Up @@ -35,17 +48,18 @@ if(SPHINX_BUILD)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_SOURCE_DIR}/source/conf.py
@ONLY)
else()
message("+-- sphinx-build *not* found, disabling build of sphinx documentation.")
message("-- - sphinx-build *not* found, disabling build of sphinx documentation.")
endif()

find_program(DOXYGEN doxygen)
if(DOXYGEN)
add_custom_target(doxygen
COMMAND doxygen doxyfile
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/docs
)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxyfile.in ${CMAKE_BINARY_DIR}/docs/doxyfile
@ONLY)
add_dependencies(html doxygen)
add_dependencies(latex doxygen)
if(SPHINX_BUILD)
add_dependencies(html doxygen)
add_dependencies(latex doxygen)
endif()
endif()
6 changes: 3 additions & 3 deletions docs/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sys.path.insert(0, '@CMAKE_SOURCE_DIR@/python')

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax', 'sphinx.ext.todo', 'breathe']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.mathjax', 'sphinx.ext.todo', @MAYBE_BREATHE@]

breathe_projects = dict(photospline="@CMAKE_BINARY_DIR@/docs/xml")
breathe_default_project = "photospline"
Expand All @@ -52,9 +52,9 @@ copyright = u'2009-2012, Nathan Whitehorn and Jakob van Santen'
# built documents.
#
# The short X.Y version.
version = '@PHOTOSPLINE_MAJOR_VERSION@.@PHOTOSPLINE_MINOR_VERSION@'
version = '@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@'
# The full version, including alpha/beta/rc tags.
release = '@PHOTOSPLINE_MAJOR_VERSION@.@PHOTOSPLINE_MINOR_VERSION@.@PHOTOSPLINE_PATCH_VERSION@ @PHOTOSPLINE_CODENAME@'
release = '@PROJECT_VERSION@'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down

0 comments on commit 6334bd8

Please sign in to comment.