From 73cf57742e8ce2729de3765b277e95e43dc6a1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 24 May 2026 18:03:12 +0200 Subject: [PATCH] doc: make pygmentize optional at build time If pygmentize is not found, the build now emits a CMake warning and proceeds with an empty dark theme stylesheet rather than aborting. A non-zero exit from pygmentize is also downgraded from SEND_ERROR to WARNING for the same reason. This restores the pre-existing behavior where the documentation could be built without any pygments tooling installed (Asciidoctor then renders code blocks as plain text). --- doc/CMakeLists.txt | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 6113ac43d..04fb087ae 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -40,14 +40,20 @@ if(ENABLE_MAN OR ENABLE_DOC) # is generated below and scoped via @media in docinfo.html.in. set(PYGMENTS_LIGHT_STYLE "default") set(PYGMENTS_DARK_STYLE "monokai") - find_program(PYGMENTIZE_EXECUTABLE pygmentize REQUIRED) - execute_process( - COMMAND "${PYGMENTIZE_EXECUTABLE}" -O "classprefix=tok-" -f html -a "pre.pygments" -S "${PYGMENTS_DARK_STYLE}" - OUTPUT_VARIABLE PYGMENTS_DARK_CSS - RESULT_VARIABLE _pygmentize_result - ) - if(NOT _pygmentize_result EQUAL 0) - message(SEND_ERROR "Failed to generate pygments CSS for dark theme (style: ${PYGMENTS_DARK_STYLE})") + find_program(PYGMENTIZE_EXECUTABLE pygmentize) + set(PYGMENTS_DARK_CSS "") + if(PYGMENTIZE_EXECUTABLE) + execute_process( + COMMAND "${PYGMENTIZE_EXECUTABLE}" -O "classprefix=tok-" -f html -a "pre.pygments" -S "${PYGMENTS_DARK_STYLE}" + OUTPUT_VARIABLE PYGMENTS_DARK_CSS + RESULT_VARIABLE _pygmentize_result + ) + if(NOT _pygmentize_result EQUAL 0) + message(WARNING "Failed to generate pygments CSS for dark theme (style: ${PYGMENTS_DARK_STYLE}); doc will be built without dark theme syntax highlighting") + set(PYGMENTS_DARK_CSS "") + endif() + else() + message(WARNING "pygmentize not found (install python3-pygments); doc will be built without syntax highlighting colors") endif() configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/docinfo.html.in"