1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Fix cyclic dependency in docs build.

If Halibut is not available to build the docs, but on the other hand
pre-built man pages already exist (e.g. because you unpacked a source
zip file with them already provided), then docs/CMakeLists.txt creates
a set of build rules that copy the pre-built man pages from the source
directory to the build directory.

However, if the source and build directories are the _same_, this
creates a set of cyclic dependencies, i.e. files which depend directly
on themselves. Some build tools (in particular 'ninja') will report
this as an error.

In that situation, the simple fix is to leave off the build rules
completely: if the man pages are already where the build will want
them to end up, there need not be any build rule to do anything about
them.
This commit is contained in:
Simon Tatham 2022-09-01 19:33:44 +01:00
parent 15f097f399
commit b01173c6b7

View File

@ -119,6 +119,18 @@ macro(register_manpage title section)
endif()
endmacro()
if(NOT HALIBUT)
# If we don't have Halibut available to rebuild the man pages from
# source, we must check whether the build and source directories
# correspond, so as to suppress the build rules that copy them from
# the source dir to the build dir. (Otherwise, someone unpacking
# putty-src.zip and building on a system without Halibut will find
# that there's a circular dependency in the makefile, which at least
# Ninja complains about.)
get_filename_component(DOCBUILDDIR ${CMAKE_CURRENT_BINARY_DIR} REALPATH)
get_filename_component(DOCSRCDIR ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
endif()
macro(manpage title section)
if(HALIBUT)
add_custom_command(OUTPUT ${title}.${section}
@ -128,7 +140,8 @@ macro(manpage title section)
DEPENDS
mancfg.but man-${title}.but)
register_manpage(${title} ${section})
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section})
elseif(NOT (DOCBUILDDIR STREQUAL DOCSRCDIR)
AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section})
add_custom_command(OUTPUT ${title}.${section}
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section} ${title}.${section}