6d8727
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
6d8727
index f3dae606..2af32d53 100644
6d8727
--- a/doc/CMakeLists.txt
6d8727
+++ b/doc/CMakeLists.txt
6d8727
@@ -4,8 +4,11 @@ if (NOT DOXYGEN)
6d8727
   return ()
6d8727
 endif ()
6d8727
 
6d8727
+find_program(SPHINX_EXECUTABLE
6d8727
+  NAMES sphinx-build sphinx-build-3)
6d8727
 add_custom_target(doc
6d8727
-  COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build.py ${FMT_VERSION}
6d8727
+  COMMAND ${CMAKE_COMMAND} -E env SPHINX_EXECUTABLE=${SPHINX_EXECUTABLE}
6d8727
+    ${CMAKE_CURRENT_SOURCE_DIR}/build.py ${FMT_VERSION}
6d8727
   SOURCES api.rst syntax.rst usage.rst build.py conf.py _templates/layout.html)
6d8727
 
6d8727
 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
6d8727
diff --git a/doc/build.py b/doc/build.py
6d8727
index af3313d1..44b31343 100755
6d8727
--- a/doc/build.py
6d8727
+++ b/doc/build.py
6d8727
@@ -49,7 +49,8 @@ def build_docs(version='dev', **kwargs):
6d8727
     raise CalledProcessError(p.returncode, cmd)
6d8727
   html_dir = os.path.join(work_dir, 'html')
6d8727
   main_versions = reversed(versions[-3:])
6d8727
-  check_call(['sphinx-build',
6d8727
+  sphinx_build = os.environ.get('SPHINX_EXECUTABLE', 'sphinx-build')
6d8727
+  check_call([sphinx_build,
6d8727
               '-Dbreathe_projects.format=' + os.path.abspath(doxyxml_dir),
6d8727
               '-Dversion=' + version, '-Drelease=' + version,
6d8727
               '-Aversion=' + version, '-Aversions=' + ','.join(main_versions),
6d8727
-- 
6d8727
2.26.2
6d8727