-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathenable_bitbots_docs.cmake.in
More file actions
34 lines (30 loc) · 1.68 KB
/
enable_bitbots_docs.cmake.in
File metadata and controls
34 lines (30 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function(enable_bitbots_docs)
# create directories necessary for sphinx
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/docs/_build/doxyoutput)
file(COPY @CMAKE_INSTALL_PREFIX@/share/bitbots_docs/files/_static DESTINATION ${CMAKE_SOURCE_DIR}/docs)
# copy default configuration files from bitbots_docs into target package
# but only do so when the target does not yet exist to prevent overriding of manual edits
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/docs/index.rst)
file(COPY @CMAKE_INSTALL_PREFIX@/share/bitbots_docs/files/index.rst DESTINATION ${CMAKE_SOURCE_DIR}/docs)
endif()
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/docs/conf.py)
file(COPY @CMAKE_INSTALL_PREFIX@/share/bitbots_docs/files/conf.py DESTINATION ${CMAKE_SOURCE_DIR}/docs)
endif()
# figure out if we have python files in the current package and only do sphinx-apidoc if we do
file(GLOB_RECURSE files_py CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/src/*.py)
list(LENGTH files_py num_files_py)
if (num_files_py)
add_custom_target(Documentation
COMMENT "Building documentation from source"
COMMAND sphinx-apidoc src/${PROJECT_NAME} -o docs/pyapi
COMMAND sphinx-build docs docs/_out -b html
BYPRODUCTS docs/_out docs/cppapi docs/pyapi
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
else()
add_custom_target(Documentation
COMMENT "Building documentation from source"
COMMAND sphinx-build docs docs/_out -b html
BYPRODUCTS docs/_out docs/cppapi docs/pyapi
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
endfunction()