Skip to content

Commit 88cf702

Browse files
committed
Cmake: build python bindings doc (sphinx)
If WITH_DOC is set while PYTHON_BINDINGS is on, then build the python binding doc, and leave it in the html directory Signed-off-by: Robin Getz <[email protected]>
1 parent 33b1f15 commit 88cf702

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

bindings/python/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,26 @@ if (Python_Interpreter_FOUND)
2929
else()
3030
message(FATAL_ERROR "Python search failed : Can not build Python bindings")
3131
endif()
32+
33+
if(WITH_DOC)
34+
find_program(SPHINX_EXECUTABLE
35+
NAMES sphinx-build
36+
DOC "Sphinx Documentation Builder (sphinx-doc.org)"
37+
)
38+
if (NOT SPHINX_EXECUTABLE)
39+
message(FATAL_ERROR "Can not build python doc without sphinx-build")
40+
endif()
41+
message (STATUS "Building with Python Doc (Sphinx)")
42+
configure_file(
43+
${CMAKE_CURRENT_SOURCE_DIR}/doc/conf.py.in
44+
${CMAKE_CURRENT_SOURCE_DIR}/doc/conf.py)
45+
add_custom_command(TARGET libiio-py POST_BUILD
46+
COMMAND ${SPHINX_EXECUTABLE}
47+
-b html
48+
-c ${CMAKE_CURRENT_SOURCE_DIR}/doc
49+
-d ${CMAKE_CURRENT_BINARY_DIR}/doctrees
50+
${CMAKE_CURRENT_SOURCE_DIR}/doc
51+
${CMAKE_HTML_DEST_DIR}/python
52+
COMMENT "Generating Python binding documentation with Sphinx" VERBATIM
53+
)
54+
endif()

0 commit comments

Comments
 (0)