From 550abf8c29542dfc2aa2b4b4b178c63821fee3b8 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 14 Aug 2014 11:57:13 +0000 Subject: [PATCH] Add SPHINX_WARNINGS_AS_ERRORS CMake option to allow warnings to not be treated as errors (which is still the default). This is useful when working on documentation that has existing errors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215634 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/modules/AddSphinxTarget.cmake | 9 ++++++++- cmake/modules/FindSphinx.cmake | 2 ++ docs/CMake.rst | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cmake/modules/AddSphinxTarget.cmake b/cmake/modules/AddSphinxTarget.cmake index fc28a494078..b78afc173cb 100644 --- a/cmake/modules/AddSphinxTarget.cmake +++ b/cmake/modules/AddSphinxTarget.cmake @@ -8,12 +8,19 @@ function (add_sphinx_target builder project) set(SPHINX_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${builder}") set(SPHINX_DOC_TREE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees") set(SPHINX_TARGET_NAME docs-${project}-${builder}) + + if (SPHINX_WARNINGS_AS_ERRORS) + set(SPHINX_WARNINGS_AS_ERRORS_FLAG "-W") + else() + set(SPHINX_WARNINGS_AS_ERRORS_FLAG "") + endif() + add_custom_target(${SPHINX_TARGET_NAME} COMMAND ${SPHINX_EXECUTABLE} -b ${builder} -d "${SPHINX_DOC_TREE_DIR}" -q # Quiet: no output other than errors and warnings. - -W # Warnings are errors. + ${SPHINX_WARNINGS_AS_ERRORS_FLAG} # Treat warnings as errors if requested "${CMAKE_CURRENT_SOURCE_DIR}" # Source "${SPHINX_BUILD_DIR}" # Output COMMENT diff --git a/cmake/modules/FindSphinx.cmake b/cmake/modules/FindSphinx.cmake index a2adcae7326..9d252e8b70a 100644 --- a/cmake/modules/FindSphinx.cmake +++ b/cmake/modules/FindSphinx.cmake @@ -23,3 +23,5 @@ find_package_handle_standard_args(Sphinx # Provide options for controlling different types of output option(SPHINX_OUTPUT_HTML "Output standalone HTML files" ON) option(SPHINX_OUTPUT_MAN "Output man pages" ON) + +option(SPHINX_WARNINGS_AS_ERRORS "When building documentation treat warnings as errors" ON) diff --git a/docs/CMake.rst b/docs/CMake.rst index fca02ef889e..1da123419dc 100644 --- a/docs/CMake.rst +++ b/docs/CMake.rst @@ -363,6 +363,10 @@ LLVM-specific variables is enabled). Currently the only target added is ``docs-llvm-man``. Defaults to ON. +**SPHINX_WARNINGS_AS_ERRORS**:BOOL + If enabled then sphinx documentation warnings will be treated as + errors. Defaults to ON. + Executing the test suite ========================