diff --git a/cmake/FindDocutils.cmake b/cmake/FindDocutils.cmake index 28fe3de..3417fd2 100644 --- a/cmake/FindDocutils.cmake +++ b/cmake/FindDocutils.cmake @@ -32,8 +32,17 @@ if(RST2HTML_EXECUTABLE) set(infile ${CMAKE_CURRENT_SOURCE_DIR}/${it}) set(outfile ${CMAKE_CURRENT_BINARY_DIR}/${basename}.html) - add_custom_command(OUTPUT ${outfile} COMMAND ${RST2HTML_EXECUTABLE} - ARGS ${infile} ${outfile} DEPENDS ${infile}) + # Unfortunately, cmake does not remove any generated target of a + # failed build. So a build with with warnings that are considered + # fatal (--exit-status=2) will not be retried. + # Execute the command twice to get a full list of warnings and errors, + # but to avoid generating the target if there were warnings or errors. + add_custom_command( OUTPUT ${outfile} + COMMAND ${RST2HTML_EXECUTABLE} + ARGS ${RST2HTML_FLAGS} --halt=4 ${infile} /dev/null + COMMAND ${RST2HTML_EXECUTABLE} + ARGS ${RST2HTML_FLAGS} --quiet ${infile} ${outfile} + DEPENDS ${infile}) endforeach() endmacro() endif() diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index a0f204b..0ddc750 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -6,6 +6,8 @@ if(NOT DEFINED USE_RST2HTML) set(USE_RST2HTML -1) endif(NOT DEFINED USE_RST2HTML) +SET(RST2HTML_FLAGS --exit-status=2) + SET(REQUIRE_HTML_DOCUMENTATION_DOC "Convert rst documents to html or fail") SET(DISABLE_HTML_DOCUMENTATION_DOC "Don't convert rst documents to html") OPTION(REQUIRE_HTML_DOCUMENTATION ${REQUIRE_HTML_DOCUMENTATION_DOC} False)