How to do it

The CMakeLists.txt file in the src directory is unchanged. The only changes in the root CMakeLists.txt file are as follows:

  1. We include the UseBreathe.cmake custom module:
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")include(UseBreathe)
  1. We call the add_breathe_doc function. This function is defined in the custom module, and it accepts keyword arguments to set up the combined Doxygen and Sphinx build:
add_breathe_doc(  SOURCE_DIR    ${CMAKE_CURRENT_SOURCE_DIR}/docs  BUILD_DIR    ${CMAKE_CURRENT_BINARY_DIR}/_build  CACHE_DIR    ${CMAKE_CURRENT_BINARY_DIR}/_doctrees  HTML_DIR    ${CMAKE_CURRENT_BINARY_DIR}/html  DOXY_FILE    ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in  CONF_FILE    ${CMAKE_CURRENT_SOURCE_DIR}/docs/conf.py.in TARGET_NAME ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.