Skip to content

Commit 51fba03

Browse files
authored
build: build documentation in CMake (#90)
* build: build docs using CMake * build(docs): add file stamp depends
1 parent 91219de commit 51fba03

File tree

4 files changed

+50
-12
lines changed

4 files changed

+50
-12
lines changed

.github/workflows/build.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ jobs:
4848
- name: Checkout
4949
uses: actions/checkout@v4.1.1
5050

51-
- name: Install Dependencies
52-
run: |
53-
sudo apt-get install -y doxygen
54-
pip3 install -r docs/requirements.txt
51+
- name: Install Doxygen
52+
run: sudo apt-get install -y doxygen
53+
54+
- name: Configure Project
55+
uses: threeal/cmake-action@v1.3.0
56+
with:
57+
options: BUILD_DOCS=ON
5558

5659
- name: Build Documentation
57-
run: sphinx-build -b html docs build/docs -W --keep-going
60+
run: cmake --build build --target docs
5861

5962
- name: Upload Documentation
6063
uses: actions/upload-pages-artifact@v3.0.0
6164
with:
62-
path: build/docs
65+
path: build/docs/html

.github/workflows/deploy.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ jobs:
2323
- name: Checkout
2424
uses: actions/checkout@v4.1.1
2525

26-
- name: Install Dependencies
27-
run: |
28-
sudo apt-get install -y doxygen
29-
pip3 install -r docs/requirements.txt
26+
- name: Install Doxygen
27+
run: sudo apt-get install -y doxygen
28+
29+
- name: Configure Project
30+
uses: threeal/cmake-action@v1.3.0
31+
with:
32+
options: BUILD_DOCS=ON
3033

3134
- name: Build Documentation
32-
run: sphinx-build -b html docs docs/build -W --keep-going
35+
run: cmake --build build --target docs
3336

3437
- name: Upload Documentation
3538
uses: actions/upload-pages-artifact@v3.0.0
3639
with:
37-
path: docs/build
40+
path: build/docs/html
3841

3942
- name: Deploy Pages
4043
id: deploy-pages

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,7 @@ if(NOT_SUBPROJECT)
8282
endif()
8383

8484
add_subdirectory(components)
85+
86+
if(NOT_SUBPROJECT AND BUILD_DOCS)
87+
add_subdirectory(docs)
88+
endif()

docs/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
find_package(Python REQUIRED)
2+
3+
message(STATUS "Installing Python dependencies")
4+
execute_process(
5+
COMMAND ${Python_EXECUTABLE} -m pip install -r ${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt
6+
RESULT_VARIABLE RES
7+
ERROR_VARIABLE ERR
8+
OUTPUT_QUIET
9+
)
10+
if(NOT RES EQUAL 0 )
11+
message(FATAL_ERROR "Failed to install Python dependencies:\n${ERR}")
12+
endif()
13+
14+
get_target_property(errors_docs_BINARY_DIR errors_docs BINARY_DIR)
15+
get_target_property(errors_format_docs_BINARY_DIR errors_format_docs BINARY_DIR)
16+
17+
add_custom_command(
18+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
19+
COMMAND ${Python_EXECUTABLE} -m sphinx -b html ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/html -W --keep-going
20+
DEPENDS
21+
${CMAKE_CURRENT_SOURCE_DIR}/conf.py
22+
${CMAKE_CURRENT_SOURCE_DIR}/index.rst
23+
${errors_docs_BINARY_DIR}/errors_docs.stamp
24+
${errors_format_docs_BINARY_DIR}/errors_format_docs.stamp
25+
)
26+
27+
add_custom_target(docs ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
28+
add_dependencies(docs errors_docs errors_format_docs)

0 commit comments

Comments
 (0)