Skip to content

Commit 28535d2

Browse files
committed
Improve CMake bits
1 parent 543efab commit 28535d2

File tree

3 files changed

+18
-27
lines changed

3 files changed

+18
-27
lines changed

.readthedocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ build:
1111
- cmake --workflow --preset documentation-workflow
1212
# Copy built documentation to Read the Docs output directory
1313
- mkdir -p $READTHEDOCS_OUTPUT/html
14-
- cp -r build/* $READTHEDOCS_OUTPUT/html/
14+
- cp -r build/html/* $READTHEDOCS_OUTPUT/html/
15+
- cp -r build/markdown/* $READTHEDOCS_OUTPUT/html/
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# SetupSphinx.cmake - Find Sphinx for CI environments
1+
# Sphinx related utilities
2+
3+
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/source)
4+
set(SPHINX_BUILD ${CMAKE_BINARY_DIR})
25

36
# Function to find Sphinx in the system
47
function(setup_sphinx_environment)
@@ -15,3 +18,11 @@ function(setup_sphinx_environment)
1518
# Export to parent scope
1619
set(SPHINX_EXECUTABLE "${SPHINX_EXECUTABLE}" PARENT_SCOPE)
1720
endfunction()
21+
22+
# Function to add a Sphinx builder target
23+
function(add_sphinx_builder builder_name)
24+
add_custom_target(${builder_name}
25+
COMMAND ${SPHINX_EXECUTABLE} -b ${builder_name} ${SPHINX_SOURCE} ${SPHINX_BUILD}/${builder_name}
26+
VERBATIM
27+
)
28+
endfunction()

docs/CMakeLists.txt

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
1-
# Find Sphinx
2-
include(SetupSphinx)
3-
setup_sphinx_environment()
4-
5-
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/source)
6-
set(SPHINX_BUILD ${CMAKE_BINARY_DIR})
1+
include(SphinxUtils)
72

8-
# Build HTML documentation
9-
add_custom_target(html
10-
COMMAND ${SPHINX_EXECUTABLE} -b html ${SPHINX_SOURCE} ${SPHINX_BUILD}
11-
COMMENT "Building HTML documentation"
12-
VERBATIM
13-
)
14-
15-
# Build markdown documentation
16-
add_custom_target(markdown
17-
COMMAND ${SPHINX_EXECUTABLE} -b markdown ${SPHINX_SOURCE} ${SPHINX_BUILD}
18-
COMMENT "Building Markdown documentation"
19-
VERBATIM
20-
)
3+
setup_sphinx_environment()
214

22-
# Build reStructuredText documentation
23-
add_custom_target(rst
24-
COMMAND ${SPHINX_EXECUTABLE} -b rst ${SPHINX_SOURCE} ${SPHINX_BUILD}
25-
COMMENT "Building reStructuredText documentation"
26-
VERBATIM
27-
)
5+
add_sphinx_builder(html)
6+
add_sphinx_builder(markdown)

0 commit comments

Comments
 (0)