Skip to content

Commit 4874f95

Browse files
Build - Fix documentation installation.
1 parent db3827e commit 4874f95

File tree

3 files changed

+52
-19
lines changed

3 files changed

+52
-19
lines changed

docs/CMakeLists.txt

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,23 @@ set(input_files
5252
source/mmSolver.utils.rst
5353
)
5454

55-
# Build Documentation (using Python Sphinx)
56-
if(SPHINX_AVAILABLE)
57-
# Normalize the path to avoid escape sequence issues on Windows.
58-
file(TO_CMAKE_PATH "${BUILD_DOCS_DIR_BASE}" BUILD_DOCS_DIR_BASE)
59-
message(STATUS "Documentation build directory: ${BUILD_DOCS_DIR_BASE}")
55+
# Normalize the path to avoid escape sequence issues on Windows.
56+
file(TO_CMAKE_PATH "${BUILD_DOCS_DIR_BASE}" BUILD_DOCS_DIR_BASE)
57+
58+
set(DOCS_LOCAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/")
59+
set(DOCS_MODULE_DIR "${MODULE_FULL_NAME}/docs/")
6060

61-
# Ensure the external build directory exists.
62-
file(MAKE_DIRECTORY ${BUILD_DOCS_DIR_BASE})
61+
message(STATUS "Documentation local directory: ${DOCS_LOCAL_DIR}")
62+
message(STATUS "Documentation build directory: ${BUILD_DOCS_DIR_BASE}")
63+
message(STATUS "Documentation module directory: ${DOCS_MODULE_DIR}")
6364

64-
set(input_file source/index.html)
65-
set(output_file ${BUILD_DOCS_DIR_BASE}/html/py-modindex.html)
65+
# Ensure the external build directory exists.
66+
file(MAKE_DIRECTORY ${BUILD_DOCS_DIR_BASE})
6667

68+
# Build Documentation (using Python Sphinx)
69+
set(input_file "${CMAKE_CURRENT_SOURCE_DIR}/source/index.html")
70+
set(output_file "${BUILD_DOCS_DIR_BASE}/html/py-modindex.html")
71+
if(SPHINX_AVAILABLE)
6772
if(WIN32)
6873
set(DOCS_WRAPPER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/build_docs_with_venv.bat)
6974
else()
@@ -77,20 +82,48 @@ if(SPHINX_AVAILABLE)
7782
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
7883
DEPENDS ${input_files}
7984
)
80-
8185
add_custom_target(
8286
build_documentation ALL
87+
# TODO: Can we be smarter about what the documentation
88+
# target depends on? For example listing all the Python
89+
# code and the HTML and images for the site?
8390
DEPENDS ${output_file}
8491
COMMENT "Building Documentation (with Sphinx) (${input_file})..."
8592
)
93+
else()
94+
# Without Sphinx, we just copy the placeholder page, so our
95+
# installed package always has a file it can open.
96+
add_custom_command(
97+
OUTPUT ${output_file}
98+
COMMAND ${CMAKE_COMMAND} -E copy ${input_file} ${BUILD_DOCS_DIR_BASE}/html/index.html
99+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
100+
DEPENDS ${input_files}
101+
)
102+
add_custom_target(
103+
build_documentation ALL
104+
# TODO: Can we be smarter about what the documentation
105+
# target depends on? For example listing all the Python
106+
# code and the HTML and images for the site?
107+
DEPENDS ${output_file}
108+
COMMENT "Building Documentation (with placeholder file) (${input_file})..."
109+
)
110+
endif()
86111

87-
if (MMSOLVER_BUILD_PLUGIN)
88-
add_dependencies(mmSolver build_documentation)
89-
endif ()
112+
if (MMSOLVER_BUILD_PLUGIN)
113+
add_dependencies(mmSolver build_documentation)
114+
endif ()
90115

91-
# Install Documentation
92-
install(DIRECTORY "${BUILD_DOCS_DIR_BASE}/html/"
93-
DESTINATION "${MODULE_FULL_NAME}/docs/html")
116+
# Install Documentation.
117+
if(EXISTS "${BUILD_DOCS_DIR_BASE}")
118+
# NOTE: We already copied the placeholder file above, so we can
119+
# install that, even if nothing else exists.
120+
install(DIRECTORY "${BUILD_DOCS_DIR_BASE}/"
121+
DESTINATION "${DOCS_MODULE_DIR}")
122+
elseif(EXISTS "${DOCS_LOCAL_DIR}")
123+
# Install fallback documentation if sphinx-build is not available.
124+
message(STATUS "Installing fallback documentation from ${CMAKE_CURRENT_SOURCE_DIR}/docs/build/")
125+
install(DIRECTORY "${DOCS_LOCAL_DIR} "
126+
DESTINATION "${DOCS_MODULE_DIR}")
94127
else()
95-
message(STATUS "Skipping documentation build because sphinx-build is not available")
128+
message(WARNING "No documentation found to install. Skipping documentation installation.")
96129
endif()

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PAPER =
1111
# Use environment variable if set, otherwise fall back to local
1212
# directory.
1313
ifdef BUILD_DOCS_DIR_BASE
14-
BUILDDIR = $(BUILD_DOCS_DIR_BASE)/cmake_linux_maya$(MAYA_VERSION)_Release
14+
BUILDDIR = $(BUILD_DOCS_DIR_BASE)
1515
else
1616
BUILDDIR = build_linux_maya$(MAYA_VERSION)
1717
endif

docs/make.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ REM
1010
REM Use environment variable if set, otherwise fall back to local
1111
REM directory.
1212
if defined BUILD_DOCS_DIR_BASE (
13-
set BUILDDIR=%BUILD_DOCS_DIR_BASE%/cmake_win64_maya%MAYA_VERSION%_Release
13+
set BUILDDIR=%BUILD_DOCS_DIR_BASE%
1414
) else (
1515
set BUILDDIR=build_win64_maya%MAYA_VERSION%
1616
)

0 commit comments

Comments
 (0)