From b01173c6b7f2321ab4514561e4db1eaf34fb3555 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 1 Sep 2022 19:33:44 +0100 Subject: [PATCH] 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. --- doc/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 2852d9c5..fb4c0c70 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -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}