diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 108aa71e..8e5e8a83 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -4,10 +4,15 @@ if (NOT DOXYGEN) return () endif () +find_package(PythonInterp QUIET REQUIRED) +find_program(SPHINX_EXECUTABLE NAMES sphinx-build sphinx-build-3) + add_custom_target(doc - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build.py ${FMT_VERSION} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/build.py + ${SPHINX_EXECUTABLE} ${FMT_VERSION} SOURCES api.rst syntax.rst usage.rst build.py conf.py _templates/layout.html) +include(GNUInstallDirs) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ - DESTINATION share/doc/fmt OPTIONAL + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/fmt OPTIONAL PATTERN ".doctrees" EXCLUDE) diff --git a/doc/build.py b/doc/build.py index 25d7885a..385205d9 100755 --- a/doc/build.py +++ b/doc/build.py @@ -59,7 +59,7 @@ def create_build_env(dirname='virtualenv'): '129222318f7c8f865d2631e7da7b033567e7f56a', min_version='4.2.0') -def build_docs(version='dev', **kwargs): +def build_docs(sphinx_executable='sphinx-build', version='dev', **kwargs): doc_dir = kwargs.get('doc_dir', os.path.dirname(os.path.realpath(__file__))) work_dir = kwargs.get('work_dir', '.') include_dir = kwargs.get( @@ -101,7 +101,7 @@ def build_docs(version='dev', **kwargs): raise CalledProcessError(p.returncode, cmd) html_dir = os.path.join(work_dir, 'html') main_versions = reversed(versions[-3:]) - check_call(['sphinx-build', + check_call([sphinx_executable, '-Dbreathe_projects.format=' + os.path.abspath(doxyxml_dir), '-Dversion=' + version, '-Drelease=' + version, '-Aversion=' + version, '-Aversions=' + ','.join(main_versions), @@ -121,4 +121,4 @@ def build_docs(version='dev', **kwargs): if __name__ == '__main__': create_build_env() - build_docs(sys.argv[1]) + build_docs(sys.argv[1], sys.argv[2])