From a27e369d29f176a662178917c1357c0af84bdcbd Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Wed, 26 Jul 2023 18:48:33 +0200 Subject: [PATCH] cmake for docs integrated --- cmake/helpers.cmake | 6 ++++++ docs/CMakeLists.txt | 32 ++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index 822942c8..da3c42cf 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -18,6 +18,12 @@ # functions and macros definitions # +# +# Allow to fimnd cmake modules in this directory +# +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}" ${CMAKE_MODULE_PATH}) + + # # Show VARIABLE = value on configuration stage # diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 945cdff6..1edddf80 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,11 +1,22 @@ -cmake_minimum_required (VERSION 3.16) - -project ("zenoh-cpp-docs") - -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake" ${CMAKE_MODULE_PATH}) - -find_package(Doxygen REQUIRED) -find_package(Sphinx REQUIRED) +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) + cmake_minimum_required (VERSION 3.16) + project(zenohcxx_docs) +else() + message(STATUS "zenoh-cxx docs") + include(../cmake/helpers.cmake) +endif() + +find_package(Doxygen) +if(NOT DOXYGEN_FOUND) + message(STATUS "Doxygen not found, skipping docs") + return() +endif() + +find_package(Sphinx) +if(NOT SPHINX_FOUND) + message(STATUS "Sphinx not found, skipping docs") + return() +endif() # Find all the public headers @@ -35,10 +46,15 @@ add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE}) set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}) set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/docs/sphinx) + +file (GLOB_RECURSE RST_FILES *.rst) add_custom_target(Sphinx ALL + DEPENDS conf.py ${RST_FILES} ${DOXYGEN_INDEX_FILE} COMMAND ${SPHINX_EXECUTABLE} -b html # Tell Breathe where to find the Doxygen output -Dbreathe_projects.zenohcpp=${DOXYGEN_OUTPUT_DIR}/xml ${SPHINX_SOURCE} ${SPHINX_BUILD} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating documentation with Sphinx") + +add_custom_target(docs ALL DEPENDS Sphinx) \ No newline at end of file