CMake: only generate & install the man-page when it may be outdated

Check if the man-page is missing or older than files that generate it
before re-running the generator.

Previously the install target would re-run the man-page generator
every time, even when no other changes to the build were detected.
This commit is contained in:
Campbell Barton
2023-04-26 22:56:30 +10:00
parent bdaf8e3715
commit f6931a9ead

View File

@@ -1659,14 +1659,20 @@ endif()
if(UNIX AND NOT APPLE)
if(NOT WITH_PYTHON_MODULE)
if(WITH_DOC_MANPAGE)
# Only run the command to generate the man-page when it may be outdated.
# The `IS_NEWER_THAN` checks always run when files are missing.
install(
CODE "\
execute_process(\
COMMAND \
\"${CMAKE_SOURCE_DIR}/doc/manpage/blender.1.py\" \
--blender \"${EXECUTABLE_OUTPUT_PATH}/blender\" \
--output \"${CMAKE_CURRENT_BINARY_DIR}/blender.1\"\
)"
set(BLENDER_BIN \"${EXECUTABLE_OUTPUT_PATH}/blender\")\n\
set(MANPAGE_GEN \"${CMAKE_SOURCE_DIR}/doc/manpage/blender.1.py\")\n\
set(MANPAGE_OUT \"${CMAKE_CURRENT_BINARY_DIR}/blender.1\")\n\
if(\n\
($\{BLENDER_BIN\} IS_NEWER_THAN $\{MANPAGE_OUT\}) OR\n\
($\{MANPAGE_GEN\} IS_NEWER_THAN $\{MANPAGE_OUT\})\n\
)\n\
execute_process(COMMAND $\{MANPAGE_GEN\} --blender $\{BLENDER_BIN\} --output $\{MANPAGE_OUT\})\n\
endif()\n\
"
DEPENDS blender
)