Skip to content

Commit

Permalink
add support for building manpages
Browse files Browse the repository at this point in the history
  • Loading branch information
trws committed Aug 22, 2023
1 parent c2f0fa4 commit ff3a002
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .configure-custom.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/sh

ENABLE_VARS="code-coverage|yes|ENABLE_COVERAGE"
ENABLE_VARS="code-coverage|On|ENABLE_COVERAGE docs|On|ENABLE_DOCS"
DISABLE_VARS="docs|Off|ENABLE_DOCS"
ENABLE_ENABLE_COVERAGE_DOC="enable coverage analysis"
ENABLE_ENABLE_DOCS_DOC="enable building manpages"
ENABLE_DISABLE_DOCS_DOC="disable building manpages"
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ message(STATUS "Building flux-sched version ${FLUX_SCHED_VER}")
if(POLICY CMP0140)
cmake_policy(SET CMP0140 NEW)
endif()
# Option to Enable SPHINX
option( SPHINX "Enable SPHINX" OFF )

# Option to AS_HELP_STRING([--disable-docs
option( DOCS "Enable docs generation" OFF )

set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ standard to use")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -180,7 +175,7 @@ add_subdirectory( etc )
add_subdirectory( src )
add_subdirectory( resource )
add_subdirectory( qmanager )
# add_subdirectory( doc )
add_subdirectory( doc )
add_subdirectory( t )

if(ENABLE_COVERAGE)
Expand Down
50 changes: 50 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
set(3VALUE_OPTS On Off Try)
set(ENABLE_DOCS "Try" CACHE STRING "Enables documentation")

if(ENABLE_DOCS) # only matches On
set(REQ_DOCS REQUIRED)
endif()
find_program(SPHINX NAMES sphinx-build sphinx-build2 ${REQ_DOCS})

if(SPHINX AND ENABLE_DOCS)

set(man5_inputs
man5/flux-config-sched-fluxion-qmanager.rst
man5/flux-config-sched-fluxion-resource.rst
)
foreach(file ${man5_inputs})
string(REPLACE ".rst" ".5" out ${file})
list(APPEND man5_outputs ${CMAKE_CURRENT_BINARY_DIR}/${out})
endforeach()

add_custom_target(manpages
ALL
DEPENDS
man5/index.rst
${man5_inputs}
COMMAND
PYTHONPATH=$ENV{PYTHONPATH}:${CMAKE_CURRENT_SOURCE_DIR}
SPHINX_BUILDDIR=${CMAKE_CURRENT_BINARY_DIR}
${Python_EXECUTABLE} -m sphinx -b man ${CMAKE_CURRENT_SOURCE_DIR} ./man5
BYPRODUCTS
${man5_outputs}
)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man5
TYPE MAN
FILES_MATCHING PATTERN "*.5" PATTERN ".doctrees" EXCLUDE
)
add_custom_target(html
DEPENDS
man5/index.rst
${man5_inputs}
COMMAND
PYTHONPATH=$ENV{PYTHONPATH}:${CMAKE_CURRENT_SOURCE_DIR}
SPHINX_BUILDDIR=${CMAKE_CURRENT_BINARY_DIR}
${Python_EXECUTABLE} -m sphinx -b html ${CMAKE_CURRENT_SOURCE_DIR} ./html
BYPRODUCTS
${man5_outputs}
)
add_custom_target(docs
DEPENDS html manpages)
endif()

0 comments on commit ff3a002

Please sign in to comment.