|
1 | | -# Function to configure the book file and add a custom target to build it. |
2 | | -function(BuildBook LANGUAGE AUTHORS) |
3 | | - # Set the variables for substitution. |
4 | | - set(AUTHORS "${AUTHORS}") |
| 1 | +function(BuildBook LANGUAGE) |
5 | 2 | set(LANGUAGE "${LANGUAGE}") |
6 | 3 | set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") |
7 | 4 | set(TARGET_DIR "${ROOT_DIR}/src/${LANGUAGE}") |
8 | 5 |
|
9 | | - # Create a custom target that calls mdbook with the generated config. |
10 | | - if(EXISTS "${TARGET_DIR}/SUMMARY.md") |
11 | | - # Configure the template file with the substitutions. |
12 | | - configure_file( |
13 | | - ${ROOT_DIR}/book-template.config |
14 | | - ${TARGET_DIR}/book.toml |
15 | | - @ONLY |
16 | | - ) |
17 | | - |
18 | | - message(STATUS "Building book for language: ${LANGUAGE}") |
19 | | - execute_process( |
20 | | - COMMAND mdbook build -d ${ROOT_DIR}/book/${LANGUAGE} |
21 | | - WORKING_DIRECTORY ${TARGET_DIR} |
22 | | - ) |
23 | | - else() |
24 | | - message(WARNING "Skipping '${LANGUAGE}' – SUMMARY.md not found at ${SUMMARY_FILE}") |
| 6 | + if(NOT EXISTS "${TARGET_DIR}/SUMMARY.md") |
| 7 | + message(WARNING "Skipping '${LANGUAGE}' – SUMMARY.md not found at ${TARGET_DIR}") |
| 8 | + return() |
| 9 | + endif() |
| 10 | + |
| 11 | + if(NOT EXISTS "${TARGET_DIR}/book.toml") |
| 12 | + message(WARNING "Skipping '${LANGUAGE}' – book.toml not found at ${TARGET_DIR}") |
| 13 | + return() |
25 | 14 | endif() |
| 15 | + |
| 16 | + message(STATUS "Building book for language: ${LANGUAGE}") |
| 17 | + execute_process( |
| 18 | + COMMAND mdbook build -d ${ROOT_DIR}/book/${LANGUAGE} |
| 19 | + WORKING_DIRECTORY ${TARGET_DIR} |
| 20 | + ) |
26 | 21 | endfunction() |
27 | 22 |
|
28 | 23 | # Create configurations for both languages. |
29 | | -BuildBook("en" "Karn Kaul") |
30 | | -BuildBook("zh-TW" "Mes") |
| 24 | +BuildBook("en") |
| 25 | +BuildBook("zh-TW") |
0 commit comments