@@ -43,68 +43,73 @@ add_subdirectory(_themes)
4343set (SPHINX_DOCUMENTATION_DIR "${CMAKE_CURRENT_BINARY_DIR} " )
4444set (SPHINX_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR} /_build" )
4545
46+ foreach (format ${PGR_WORKSHOP_DOC_TARGETS} )
4647
47- # build the locale files
48- if (LOCALE)
49- add_custom_target (locale ALL
50- COMMAND ${SPHINX_EXECUTABLE}
48+ message (STATUS "format=${format} " )
49+ if ("${format} " STREQUAL "locale" )
5150
52- -b gettext
51+ find_program (SPHINX_INTL_EXECUTABLE
52+ NAMES sphinx-intl
53+ DOC "Sphinx Documentation Builder (sphinx-doc.org)"
54+ )
5355
54- # the location of the documentation to be build
55- "${CMAKE_CURRENT_BINARY_DIR} "
56- "${CMAKE_SOURCE_DIR} /locale/pot"
56+ if (SPHINX_INTL_EXECUTABLE)
5757
58- COMMAND sphinx-intl update -d ${CMAKE_SOURCE_DIR} /locale -l ${SPHINXINTL_LANGUAGE} > locale_changes.txt
59- DEPENDS "conf.py"
58+ add_custom_target (locale
59+ COMMAND ${SPHINX_EXECUTABLE}
60+ -b gettext
61+ -c "${SPHINX_DOCUMENTATION_DIR} "
62+ "${SPHINX_DOCUMENTATION_DIR} "
63+ "${CMAKE_SOURCE_DIR} /locale/pot"
6064
61- COMMENT "Generating POT & PO files ..."
62- )
63- add_dependencies (locale examples general-intro advanced appendix basic un_sdg scripts interactions)
64- add_dependencies (doc locale)
65- endif ()
65+ COMMAND ${SPHINX_INTL_EXECUTABLE} update
66+ -d ${CMAKE_SOURCE_DIR} /locale
67+ -l en > locale_changes.txt
6668
69+ COMMENT "Generating POT and PO files"
70+ SOURCES ${PROJECT_DOC_FILES} )
6771
72+ add_dependencies ("${format} " examples general-intro advanced appendix basic un_sdg scripts interactions)
73+ add_dependencies (doc "${format} " )
6874
69- foreach (target ${PGR_WORKSHOP_DOC_TARGETS} )
70- add_custom_target (${target} ALL
71- COMMENT "Building documentation with Sphinx" )
75+ else ()
7276
73- configure_file ("forward.html" "${SPHINX_BUILD_DIR} /${target} /index.html" )
77+ message (WARNING "sphinx-intl not found.
78+ Not building the pot and po locale files" )
7479
75- foreach (lang ${PGR_WORKSHOP_BUILD_LANGUAGES} )
76- if (lang STREQUAL "en" )
77- set (WARNINGS_TO_ERRORS "" )
78- else ()
79- set (WARNINGS_TO_ERRORS "" )
8080 endif ()
81- message (STATUS "lang ${lang} " )
82- message (STATUS "WARNINGS_TO_ERRORS ${WARNINGS_TO_ERRORS} " )
8381
82+ else ()
8483
85- add_custom_target (
86- "${target} -${lang} "
87- COMMAND ${SPHINX_EXECUTABLE}
84+ add_custom_target ("${format} "
85+ COMMENT "Building ${format} documentation with Sphinx" )
8886
89- -b ${target}
90- -c "${CMAKE_CURRENT_BINARY_DIR} "
91- -D language =' ${lang} '
87+ configure_file (
88+ "${CMAKE_CURRENT_SOURCE_DIR} /forward.html "
89+ " ${SPHINX_BUILD_DIR} / ${format} /index.html" )
9290
93- # Convert warnings to errors
94- ${WARNINGS_TO_ERRORS}
91+ foreach (lang ${PGR_WORKSHOP_BUILD_LANGUAGES} )
9592
96- # the location of the documentation to be build
97- "${CMAKE_CURRENT_BINARY_DIR} "
93+ add_custom_target (
94+ "${format} -${lang} "
95+ COMMAND ${SPHINX_EXECUTABLE}
96+ -c ${CMAKE_CURRENT_BINARY_DIR}
97+ -d ${CMAKE_CURRENT_BINARY_DIR} /doctrees
98+ -b ${format}
99+ -D language ='${lang} '
100+ ${sphinx_flags}
101+ "${CMAKE_CURRENT_BINARY_DIR} "
102+ "${SPHINX_BUILD_DIR} /${format} /${lang} "
98103
99- #where the documentations is written
100- "${SPHINX_BUILD_DIR} /${target} /${lang} "
104+ COMMENT "Generating ${format} /${lang} documentation"
105+ DEPENDS "conf.py"
106+ )
107+ add_dependencies ("${format} -${lang} " examples general-intro advanced appendix basic un_sdg scripts interactions)
108+ add_dependencies ("${format} " "${format} -${lang} " )
109+ endforeach ()
101110
102- COMMENT "Generating ${target} /${lang} documentation ${WARNINGS_TO_ERRORS} ..."
111+ add_dependencies (doc "${format} " )
112+
113+ endif ()
103114
104- DEPENDS "conf.py"
105- )
106- add_dependencies ("${target} -${lang} " examples general-intro advanced appendix basic un_sdg scripts interactions)
107- add_dependencies ("${target} " "${target} -${lang} " )
108- endforeach ()
109- add_dependencies (doc "${target} " )
110115endforeach ()
0 commit comments