From e706c044511e7b4ca792475b8b4642b34059378c Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 3 May 2021 16:25:21 +0100 Subject: [PATCH] Add the man pages to the 'make install' target. doc/CMakeLists.txt now sets a variable indicating that we either have, or can build, each individual man page. And when we call our installed_program() function to mark a program as official enough to put in 'make install', that function also installs the man page similarly if it exists, and warns if not. For the convenience of people building-and-installing from the .tar.gz we ship, I've arranged that they can still get the man pages installed without needing Halibut: the previous commit ensured that the prebuilt man pages are still in the tarball, and this one arranges that if we don't have Halibut but we do have prebuilt man pages, then we can 'build' them by copying from the prebuilt versions. --- CMakeLists.txt | 2 ++ cmake/platforms/unix.cmake | 8 ++++++++ doc/CMakeLists.txt | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24f7981e..1680223d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ project(putty LANGUAGES C) include(cmake/setup.cmake) +# Scan the docs directory first, so that when we start calling +# installed_program(), we'll know if we have man pages available add_subdirectory(doc) add_compile_definitions(HAVE_CMAKE_H) diff --git a/cmake/platforms/unix.cmake b/cmake/platforms/unix.cmake index 080896a6..c586577d 100644 --- a/cmake/platforms/unix.cmake +++ b/cmake/platforms/unix.cmake @@ -8,6 +8,7 @@ include(CheckIncludeFile) include(CheckLibraryExists) include(CheckSymbolExists) include(CheckCSourceCompiles) +include(GNUInstallDirs) set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_DEFAULT_SOURCE -D_GNU_SOURCE) @@ -120,4 +121,11 @@ function(installed_program target) # CMAKE_INSTALL_BINDIR. install(TARGETS ${target}) endif() + + if(HAVE_MANPAGE_${target}_1) + install(FILES ${CMAKE_BINARY_DIR}/doc/${target}.1 + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) + else() + message(WARNING "Could not build man page ${target}.1") + endif() endfunction() diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 5ebd2032..8404b994 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -103,6 +103,14 @@ macro(manpage title section) DEPENDS mancfg.but man-${title}.but) list(APPEND manpage_outputs ${title}.${section}) + set(HAVE_MANPAGE_${title}_${section} ON PARENT_SCOPE) + elseif(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} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${title}.${section}) + list(APPEND manpage_outputs ${title}.${section}) + set(HAVE_MANPAGE_${title}_${section} ON PARENT_SCOPE) endif() endmacro()