diff --git a/README.rst b/README.rst index c4f39afda..73f107c99 100644 --- a/README.rst +++ b/README.rst @@ -158,6 +158,11 @@ In addition to the normal CMake build options (like ``CMAKE_INSTALL_PREFIX``), f - Rust_CARGO=path - the path to cargo. If not set, cmake will check $PATH and ~/.cargo/bin - Rust_CARGO_TARGET=target - the target to pass to cargo. Set this for cross-compilation. - WITH_DOCS=ON|OFF - whether to build the documentation. By default, this is ON when Sphinx is installed. +- FISH_INDENT_FOR_BUILDING_DOCS - useful for cross-compilation. + Set this to the path to the ``fish_indent`` executable to use for building HTML docs. + By default, ``${CMAKE_BINARY_DIR}/fish_indent`` will be used. + If that's not runnable on the compile host, + you can build a native one with ``cargo build --bin fish_indent`` and set this to ``$PWD/target/debug/fish_indent``. - FISH_USE_SYSTEM_PCRE2=ON|OFF - whether to use an installed pcre2. This is normally autodetected. - WITH_GETTEXT=ON|OFF - whether to include translations. - extra_functionsdir, extra_completionsdir and extra_confdir - to compile in an additional directory to be searched for functions, completions and configuration snippets diff --git a/cmake/Docs.cmake b/cmake/Docs.cmake index 48482a12d..4bdeda194 100644 --- a/cmake/Docs.cmake +++ b/cmake/Docs.cmake @@ -12,12 +12,21 @@ set(SPHINX_BUILD_DIR "${SPHINX_ROOT_DIR}/build") set(SPHINX_HTML_DIR "${SPHINX_ROOT_DIR}/html") set(SPHINX_MANPAGE_DIR "${SPHINX_ROOT_DIR}/man") -# sphinx-docs uses fish_indent for highlighting. -# Prepend the output dir of fish_indent to PATH. +set(FISH_INDENT_FOR_BUILDING_DOCS "" CACHE FILEPATH "Path to fish_indent executable for building HTML docs") + +if(FISH_INDENT_FOR_BUILDING_DOCS) + get_filename_component(FISH_INDENT_DIR "${FISH_INDENT_FOR_BUILDING_DOCS}" DIRECTORY) + set(SPHINX_HTML_FISH_INDENT_PATH ${FISH_INDENT_DIR}) + set(SPHINX_HTML_FISH_INDENT_DEP) +else() + set(SPHINX_HTML_FISH_INDENT_PATH ${CMAKE_BINARY_DIR}) + set(SPHINX_HTML_FISH_INDENT_DEP fish_indent) +endif() + add_custom_target(sphinx-docs mkdir -p ${SPHINX_HTML_DIR}/_static/ COMMAND env FISH_BUILD_VERSION_FILE=${CMAKE_CURRENT_BINARY_DIR}/${FBVF} - PATH="${CMAKE_BINARY_DIR}:$$PATH" + PATH="${SPHINX_HTML_FISH_INDENT_PATH}:$$PATH" ${SPHINX_EXECUTABLE} -j auto -q -b html @@ -25,7 +34,10 @@ add_custom_target(sphinx-docs -d "${SPHINX_ROOT_DIR}/.doctrees-html" "${SPHINX_SRC_DIR}" "${SPHINX_HTML_DIR}" - DEPENDS CHECK-FISH-BUILD-VERSION-FILE ${SPHINX_SRC_DIR}/fish_indent_lexer.py fish_indent + DEPENDS + CHECK-FISH-BUILD-VERSION-FILE + ${SPHINX_SRC_DIR}/fish_indent_lexer.py + ${SPHINX_HTML_FISH_INDENT_DEP} COMMENT "Building HTML documentation with Sphinx") add_custom_target(sphinx-manpages