From 2980180da0080ba58111f3f71ef63fe72d877e5a Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Sun, 31 Mar 2019 13:52:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81=20=D0=BF=D0=BE=D0=BC=D0=BE?= =?UTF-8?q?=D1=89=D1=8C=D1=8E=20Breathe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMLibBreathe.cmake | 118 +++++++++++++++++++++++++++------------------ CMLibCommon.cmake | 2 +- 2 files changed, 71 insertions(+), 49 deletions(-) diff --git a/CMLibBreathe.cmake b/CMLibBreathe.cmake index fecab0b..5b4cef9 100644 --- a/CMLibBreathe.cmake +++ b/CMLibBreathe.cmake @@ -1,57 +1,79 @@ -find_package(Doxygen REQUIRED) -find_package(Perl REQUIRED) -set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2) -find_package(PythonInterp REQUIRED) -find_package(Sphinx REQUIRED) -include(FindPythonModule) -find_python_module(breathe REQUIRED) +set(BUILD_BREATHE_DOC AUTO CACHE STRING "Enable documntation in Breathe format") +set_property(CACHE BUILD_BREATHE_DOC PROPERTY STRINGS AUTO ON OFF) + +if(BUILD_BREATHE_DOC STREQUAL AUTO) + find_package(Doxygen) + find_package(Perl) + set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2) + find_package(PythonInterp) + find_package(Sphinx) + include(FindPythonModule) + find_python_module(breathe) + find_python_module(recommonmark) + if(DOXYGEN_FOUND AND PERL_FOUND AND SPHINX_FOUND AND breathe AND recommonmark) + set(BUILD_BREATHE_DOC ON CACHE STRING "Enable documntation in Breathe format" FORCE) + endif() +elseif(BUILD_BREATHE_DOC) + find_package(Doxygen REQUIRED) + find_package(Perl REQUIRED) + set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2) + find_package(PythonInterp REQUIRED) + find_package(Sphinx REQUIRED) + include(FindPythonModule) + find_python_module(breathe REQUIRED) + find_python_module(recommonmark REQUIRED) + set(BUILD_BREATHE_DOC ON CACHE STRING "Enable documntation in Breathe format" FORCE) +else() + set(BUILD_BREATHE_DOC OFF CACHE STRING "Enable documntation in Breathe format" FORCE) +endif() function(add_breathe_doc) - set(options) - set(oneValueArgs - SOURCE_DIR - BUILD_DIR - CACHE_DIR - HTML_DIR - DOXY_FILE - CONF_FILE - TARGET_NAME - COMMENT - ) - set(multiValueArgs) + if(BUILD_BREATHE_DOC AND CMAKE_BUILD_TYPE STREQUAL Release) + set(options) + set(oneValueArgs + SOURCE_DIR + BUILD_DIR + CACHE_DIR + HTML_DIR + DOXY_FILE + CONF_FILE + TARGET_NAME + COMMENT + ) + set(multiValueArgs) - cmake_parse_arguments(BREATHE_DOC - "${options}" - "${oneValueArgs}" - "${multiValueArgs}" - ${ARGN} - ) + cmake_parse_arguments(BREATHE_DOC + "${options}" + "${oneValueArgs}" + "${multiValueArgs}" + ${ARGN} + ) - configure_file( - ${BREATHE_DOC_CONF_FILE} - ${BREATHE_DOC_BUILD_DIR}/conf.py - @ONLY - ) + configure_file( + ${BREATHE_DOC_CONF_FILE} + ${BREATHE_DOC_BUILD_DIR}/conf.py + @ONLY + ) - configure_file( - ${BREATHE_DOC_DOXY_FILE} - ${BREATHE_DOC_BUILD_DIR}/Doxyfile - @ONLY - ) + configure_file( + ${BREATHE_DOC_DOXY_FILE} + ${BREATHE_DOC_BUILD_DIR}/Doxyfile + @ONLY + ) - add_custom_target(${BREATHE_DOC_TARGET_NAME} - COMMAND + add_custom_target(${BREATHE_DOC_TARGET_NAME} + ALL + COMMAND ${SPHINX_EXECUTABLE} - -q - -b html - -c ${BREATHE_DOC_BUILD_DIR} - -d ${BREATHE_DOC_CACHE_DIR} - ${BREATHE_DOC_SOURCE_DIR} - ${BREATHE_DOC_HTML_DIR} - COMMENT + -q + -b html + -c ${BREATHE_DOC_BUILD_DIR} + -d ${BREATHE_DOC_CACHE_DIR} + ${BREATHE_DOC_SOURCE_DIR} + ${BREATHE_DOC_HTML_DIR} + COMMENT "Building ${BREATHE_DOC_TARGET_NAME} documentation with Breathe, Sphinx and Doxygen" - VERBATIM - ) - - message(STATUS "Added ${BREATHE_DOC_TARGET_NAME} [Breathe+Sphinx+Doxygen] target to build documentation") + VERBATIM + ) + endif() endfunction() diff --git a/CMLibCommon.cmake b/CMLibCommon.cmake index f7920f5..7523951 100644 --- a/CMLibCommon.cmake +++ b/CMLibCommon.cmake @@ -33,7 +33,7 @@ include(CMLibBuildTypes) include(CMLibCodeAnalysisPvsStudio) include(cotire) -#include(CMLibBreathe) +include(CMLibBreathe) include(CMLibQtTranslation) include(CMLibToday) include(CMLibConfigHPPGenerate)