forked from luxonis/depthai-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
65 lines (56 loc) · 2.29 KB
/
CMakeLists.txt
File metadata and controls
65 lines (56 loc) · 2.29 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# This list specifies building of documentation using CMake
# Specify path separator
set(SYS_PATH_SEPARATOR ";")
if(UNIX)
set(SYS_PATH_SEPARATOR ":")
endif()
# Get doxygen build location form doxygen target
get_target_property(DOXYGEN_OUTPUT_DIR doxygen DOXYGEN_OUTPUT_DIR)
message(STATUS "Retrieved doxygen output dir from doxygen target: ${DOXYGEN_OUTPUT_DIR}")
# Add input and output information for conf.py
set(SPHINX_SOURCE ${CMAKE_CURRENT_LIST_DIR}/source)
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx)
# Add year information
string(TIMESTAMP build_year "%Y")
# Configure sphinx for the build
configure_file(conf.py.in "${CMAKE_CURRENT_BINARY_DIR}/conf.py" @ONLY)
# Sphinx is required to build python documentation
# Find Python sphinx, by checking python -m sphinx
message(STATUS "Checking for sphinx")
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m sphinx --version RESULT_VARIABLE error OUTPUT_QUIET ERROR_QUIET)
if(error)
set(message "Checking for sphinx - not found, target 'sphinx' not available")
if(NOT enforce)
message(STATUS ${message})
else()
message(FATAL_ERROR ${message})
endif()
# Exit
return()
else()
message(STATUS "Checking for sphinx - found, target 'sphinx' available")
file(COPY ${SPHINX_SOURCE}/_static DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
# Ready up sphinx - needed values configured in conf.py
add_custom_target(sphinx ALL
${CMAKE_COMMAND} -E env
# Environment variables
# PATH (dlls)
"PATH=${HUNTER_INSTALL_PREFIX}/bin${SYS_PATH_SEPARATOR}$ENV{PATH}"
# Python path (to find compiled module)
"PYTHONPATH=$<TARGET_FILE_DIR:${TARGET_NAME}>${SYS_PATH_SEPARATOR}$ENV{PYTHONPATH}"
# ASAN in case of sanitizers
"${ASAN_ENVIRONMENT_VARS}"
############ SPHINX
${PYTHON_EXECUTABLE} -m sphinx -c ${CMAKE_CURRENT_BINARY_DIR} -W --keep-going -b html ${SPHINX_SOURCE} ${SPHINX_BUILD}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating documentation with Sphinx"
VERBATIM
COMMAND_EXPAND_LISTS
)
# Add dependency to library
add_dependencies(sphinx ${TARGET_NAME})
# Add dependency to doxygen (C++) if exists
if(TARGET doxygen)
add_dependencies(sphinx doxygen)
endif()
endif()