From 81259475b66c0f987664ac49c62014358baa5cc7 Mon Sep 17 00:00:00 2001 From: Tobias Rehbein Date: Fri, 19 Jan 2024 20:54:23 +0100 Subject: [PATCH 1/3] cmake: Fix the option to disable man pages This commit fixes the handling of the `FREECIV_ENABLE_MANPAGES` option, leveraging the fact, that an `option` call is a no-op if the value is already set. While here, allow users on non-Unix systems to build manpages. Closes #2155 --- docs/CMakeLists.txt | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 975975cadc..302eeeee44 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -4,7 +4,6 @@ find_package(Sphinx QUIET) if(SPHINX_FOUND) message(STATUS "Sphinx Found, configuring.") - option(FREECIV_ENABLE_MANPAGES "Enable manpages" ON) set(SPHINX_SOURCE ${CMAKE_SOURCE_DIR}/docs) set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}) set(SPHINX_MAN ${CMAKE_CURRENT_BINARY_DIR}/man) @@ -16,14 +15,19 @@ if(SPHINX_FOUND) COMMENT "Generating documentation with Sphinx") # We only create man pages on Unix - if(UNIX AND NOT APPLE) - add_custom_target(man-pages ALL - COMMAND - ${SPHINX_EXECUTABLE} -b man ${SPHINX_SOURCE} ${SPHINX_MAN} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating manual pages with Sphinx") + if((UNIX AND NOT APPLE) OR FREECIV_ENABLE_MANPAGES) + option(FREECIV_ENABLE_MANPAGES "Enable manpages" ON) + + if(FREECIV_ENABLE_MANPAGES) + add_custom_target(man-pages ALL + COMMAND + ${SPHINX_EXECUTABLE} -b man ${SPHINX_SOURCE} ${SPHINX_MAN} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating manual pages with Sphinx") + endif() endif() else() message(STATUS "Sphinx NOT Found.") - option(FREECIV_ENABLE_MANPAGES "Enable manpages" OFF) endif() + +option(FREECIV_ENABLE_MANPAGES "Enable manpages" OFF) From 4e1df752f5698458721e3578cc9d9a76c632affa Mon Sep 17 00:00:00 2001 From: Tobias Rehbein Date: Sat, 20 Jan 2024 12:58:47 +0100 Subject: [PATCH 2/3] Remove unnecessary statement --- docs/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 302eeeee44..7a904861cb 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -29,5 +29,3 @@ if(SPHINX_FOUND) else() message(STATUS "Sphinx NOT Found.") endif() - -option(FREECIV_ENABLE_MANPAGES "Enable manpages" OFF) From 5826d3ced3d62fc2a8b10810ce62c633ef1ea5e8 Mon Sep 17 00:00:00 2001 From: Tobias Rehbein Date: Sun, 21 Jan 2024 13:20:01 +0100 Subject: [PATCH 3/3] cmake: sphinx is a hard dependency for manpages If the user requests to build manpages by setting `FREECIV_ENABLE_MANPAGES` to `ON`, `sphinx` is now treated as a hard dependency. While here simplify the code and re-add the default option set to `OFF`, as requested per review. --- docs/CMakeLists.txt | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 7a904861cb..f1e50a86cf 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,6 +1,10 @@ # CMakeLists for Freeciv21 Docs -find_package(Sphinx QUIET) +if(FREECIV_ENABLE_MANPAGES) + find_package(Sphinx REQUIRED) +else() + find_package(Sphinx QUIET) +endif() if(SPHINX_FOUND) message(STATUS "Sphinx Found, configuring.") @@ -14,18 +18,19 @@ if(SPHINX_FOUND) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating documentation with Sphinx") - # We only create man pages on Unix + # We only create man pages on Unix or if the user explicitly requested it. if((UNIX AND NOT APPLE) OR FREECIV_ENABLE_MANPAGES) option(FREECIV_ENABLE_MANPAGES "Enable manpages" ON) - if(FREECIV_ENABLE_MANPAGES) - add_custom_target(man-pages ALL - COMMAND - ${SPHINX_EXECUTABLE} -b man ${SPHINX_SOURCE} ${SPHINX_MAN} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating manual pages with Sphinx") - endif() + add_custom_target(man-pages ALL + COMMAND + ${SPHINX_EXECUTABLE} -b man ${SPHINX_SOURCE} ${SPHINX_MAN} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating manual pages with Sphinx") endif() else() message(STATUS "Sphinx NOT Found.") endif() + +# Default to OFF, if FREECIV_ENABLE_MANPAGES is not set yet. +option(FREECIV_ENABLE_MANPAGES "Enable manpages" OFF)