Compared to the previous recipe, we will modify the root CMakeLists.txt file, and will also implement a function (add_sphinx_doc):
- After appending the cmake folder to the CMAKE_MODULE_PATH, we include the UseSphinxDoc.cmake custom module, as follows:
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")include(UseSphinxDoc)
- The UseSphinxDoc.cmake module defines the add_sphinx_doc function. We call this function with keyword arguments, in order to set up our Sphinx documentation build. The custom documentation target will be called docs:
add_sphinx_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}/sphinx_html ...