cmake: use curldown to build man pages

This throws away the previous HTML and PDF producers, to mimic what
Makefile.am does as faithfully as possible.

Closes #12753
This commit is contained in:
Richard Levitte 2024-01-22 07:49:08 +01:00 committed by Daniel Stenberg
parent 1647017826
commit ea0b575dab
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 20 additions and 34 deletions

View file

@ -2355,6 +2355,7 @@ Richard Gorton
Richard Gray
Richard Hosking
Richard Hsu
Richard Levitte
Richard Marion
Richard Michael
Richard Moore

View file

@ -27,41 +27,27 @@ include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
function(add_manual_pages _listname)
foreach(_file IN LISTS ${_listname})
set(_rofffile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
if(_file STREQUAL "libcurl-symbols.3")
# Special case, an auto-generated file.
set(_srcfile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
string(REPLACE ".3" ".md" _mdfile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
else()
set(_srcfile "${CMAKE_CURRENT_SOURCE_DIR}/${_file}")
string(REPLACE ".3" ".md" _mdfile "${CMAKE_CURRENT_SOURCE_DIR}/${_file}")
endif()
string(REPLACE ".3" ".html" _htmlfile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
add_custom_command(OUTPUT "${_htmlfile}"
COMMAND roffit "--mandir=${CMAKE_CURRENT_SOURCE_DIR}" "${_srcfile}" > "${_htmlfile}"
DEPENDS "${_srcfile}"
add_custom_command(OUTPUT "${_rofffile}"
COMMAND ${PROJECT_SOURCE_DIR}/scripts/cd2nroff ${_mdfile} > ${_rofffile}
DEPENDS "${_mdfile}"
VERBATIM
)
string(REPLACE ".3" ".pdf" _pdffile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
string(REPLACE ".3" ".ps" _psfile "${CMAKE_CURRENT_BINARY_DIR}/${_file}")
# XXX any reason why groff -Tpdf (for gropdf) is not used?
add_custom_command(OUTPUT "${_pdffile}"
COMMAND groff -Tps -man "${_srcfile}" > "${_psfile}"
COMMAND ps2pdf "${_psfile}" "${_pdffile}"
COMMAND "${CMAKE_COMMAND}" -E remove "${_psfile}"
DEPENDS "${_srcfile}"
#BYPRODUCTS "${_psfile}"
VERBATIM
)
# "BYPRODUCTS" for add_custom_command requires CMake 3.2. For now hope that
# the temporary files are removed (i.e. the command is not interrupted).
endforeach()
endfunction()
add_custom_command(OUTPUT libcurl-symbols.3
add_custom_command(OUTPUT libcurl-symbols.md
COMMAND
"${PERL_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/mksymbolsmanpage.pl" <
"${CMAKE_CURRENT_SOURCE_DIR}/symbols-in-versions" > libcurl-symbols.3
"${CMAKE_CURRENT_SOURCE_DIR}/symbols-in-versions" > libcurl-symbols.md
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/symbols-in-versions"
"${CMAKE_CURRENT_SOURCE_DIR}/mksymbolsmanpage.pl"
@ -69,10 +55,10 @@ add_custom_command(OUTPUT libcurl-symbols.3
)
add_manual_pages(man_MANS)
string(REPLACE ".3" ".html" HTMLPAGES "${man_MANS}")
string(REPLACE ".3" ".pdf" PDFPAGES "${man_MANS}")
add_custom_target(html DEPENDS ${HTMLPAGES})
add_custom_target(pdf DEPENDS ${PDFPAGES})
add_custom_target(man ALL DEPENDS ${man_MANS})
if(NOT CURL_DISABLE_INSTALL)
install(FILES "$<LIST:TRANSFORM,${man_MANS},PREPEND,${CMAKE_CURRENT_BINARY_DIR}/>"
DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
endif()
add_subdirectory(opts)

View file

@ -26,10 +26,9 @@ transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.
include("${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
add_manual_pages(man_MANS)
string(REPLACE ".3" ".html" HTMLPAGES "${man_MANS}")
string(REPLACE ".3" ".pdf" PDFPAGES "${man_MANS}")
add_custom_target(opts-html DEPENDS ${HTMLPAGES})
add_custom_target(opts-pdf DEPENDS ${PDFPAGES})
add_dependencies(html opts-html)
add_dependencies(pdf opts-pdf)
add_custom_target(opts-man DEPENDS ${man_MANS})
add_dependencies(man opts-man)
if(NOT CURL_DISABLE_INSTALL)
install(FILES "$<LIST:TRANSFORM,${man_MANS},PREPEND,${CMAKE_CURRENT_BINARY_DIR}/>"
DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
endif()