Skip to content

Commit f4d2dce

Browse files
Build - optionally build docs, if sphinx-build is available.
1 parent e90b1b4 commit f4d2dce

1 file changed

Lines changed: 37 additions & 25 deletions

File tree

docs/CMakeLists.txt

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2019, 2020 David Cattermole.
1+
# Copyright (C) 2019, 2020, 2025 David Cattermole.
22
#
33
# This file is part of mmSolver.
44
#
@@ -27,8 +27,15 @@ configure_file(
2727
${CMAKE_CURRENT_SOURCE_DIR}/source/conf.py
2828
@ONLY)
2929

30+
find_program(SPHINX_BUILD sphinx-build)
31+
if(SPHINX_BUILD)
32+
message(STATUS "Found sphinx-build: ${SPHINX_BUILD}")
33+
set(SPHINX_AVAILABLE TRUE)
34+
else()
35+
message(WARNING "sphinx-build not found. Documentation will not be built.")
36+
set(SPHINX_AVAILABLE FALSE)
37+
endif()
3038

31-
# Build Documentation (using Python Sphinx)
3239
set(input_files
3340
source/index.rst
3441
source/introduction.rst
@@ -45,30 +52,35 @@ set(input_files
4552
source/mmSolver.utils.rst
4653
)
4754

48-
# Get the location where the build files will be generated
49-
get_maya_module_os_name(os_name)
50-
set(BUILD_DOCS_DIR "build_${os_name}_maya${MAYA_VERSION}")
55+
# Build Documentation (using Python Sphinx)
56+
if(SPHINX_AVAILABLE)
57+
# Get the location where the build files will be generated.
58+
get_maya_module_os_name(os_name)
59+
set(BUILD_DOCS_DIR "build_${os_name}_maya${MAYA_VERSION}")
5160

52-
set(input_file source/index.html)
53-
set(output_file ${BUILD_DOCS_DIR}/html/py-modindex.html)
54-
add_custom_command(
55-
OUTPUT ${output_file}
56-
COMMAND ${CMAKE_COMMAND} -E copy ${input_file} ${BUILD_DOCS_DIR}/html/index.html
57-
COMMAND make html
58-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
59-
DEPENDS ${input_files}
60-
)
61+
set(input_file source/index.html)
62+
set(output_file ${BUILD_DOCS_DIR}/html/py-modindex.html)
63+
add_custom_command(
64+
OUTPUT ${output_file}
65+
COMMAND ${CMAKE_COMMAND} -E copy ${input_file} ${BUILD_DOCS_DIR}/html/index.html
66+
COMMAND make html
67+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
68+
DEPENDS ${input_files}
69+
)
6170

62-
add_custom_target(
63-
build_documentation ALL
64-
DEPENDS ${output_file}
65-
COMMENT "Building Documentation (with Sphinx) (${input_file})..."
66-
)
71+
add_custom_target(
72+
build_documentation ALL
73+
DEPENDS ${output_file}
74+
COMMENT "Building Documentation (with Sphinx) (${input_file})..."
75+
)
6776

68-
if (MMSOLVER_BUILD_PLUGIN)
69-
add_dependencies(mmSolver build_documentation)
70-
endif ()
77+
if (MMSOLVER_BUILD_PLUGIN)
78+
add_dependencies(mmSolver build_documentation)
79+
endif ()
7180

72-
# Install Documentation
73-
install(DIRECTORY "${BUILD_DOCS_DIR}/html/"
74-
DESTINATION "${MODULE_FULL_NAME}/docs/html")
81+
# Install Documentation
82+
install(DIRECTORY "${BUILD_DOCS_DIR}/html/"
83+
DESTINATION "${MODULE_FULL_NAME}/docs/html")
84+
else()
85+
message(STATUS "Skipping documentation build because sphinx-build is not available")
86+
endif()

0 commit comments

Comments
 (0)