From f6931a9ead56400cdea4cdd4252476ee34ce5901 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 26 Apr 2023 22:56:30 +1000 Subject: [PATCH] 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. --- source/creator/CMakeLists.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 3462fcd5b99..14bb46d60c3 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -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 )