| 1 |
# Attempt to find docbook-to-man binary from docbook2x package |
| 2 |
# |
| 3 |
# This module defines: |
| 4 |
# - DOCBOOK_TO_MAN_EXECUTABLE, path to docbook2x-man binary |
| 5 |
# |
| 6 |
# Note that the binary docbook-to-man in debian systems is a different application |
| 7 |
# than in other distributions. |
| 8 |
# |
| 9 |
# Debian systems |
| 10 |
# * docbook-to-man comes from the package docbook-to-man |
| 11 |
# * docbook2man comes from the package docbook-utils |
| 12 |
# * docbook2x-man comes from the package docbook2x |
| 13 |
# Suse |
| 14 |
# * docbook-to-man comes from the package docbook2x |
| 15 |
# * docbook2man comes from the package docbook-utils-minimal |
| 16 |
# ArchLinux |
| 17 |
# * docbook-to-man comes from the package docbook-to-man |
| 18 |
# * docbook2man comes from the package docbook2x |
| 19 |
# |
| 20 |
# We actually want the binary from docbook2x, which supports XML |
| 21 |
|
| 22 |
#============================================================================= |
| 23 |
# Copyright 2013 Kevin Funk <[email protected]> |
| 24 |
# Copyright 2015 Alex Merry <[email protected]> |
| 25 |
# |
| 26 |
# Distributed under the OSI-approved BSD License (the "License"); |
| 27 |
# see accompanying file Copyright.txt for details. |
| 28 |
# |
| 29 |
# This software is distributed WITHOUT ANY WARRANTY; without even the |
| 30 |
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 31 |
# See the License for more information. |
| 32 |
#============================================================================= |
| 33 |
|
| 34 |
macro(_check_docbook2x_executable) |
| 35 |
if (DOCBOOK_TO_MAN_EXECUTABLE) |
| 36 |
execute_process( |
| 37 |
COMMAND ${DOCBOOK_TO_MAN_EXECUTABLE} --version |
| 38 |
OUTPUT_VARIABLE _output |
| 39 |
ERROR_QUIET |
| 40 |
) |
| 41 |
if("${_output}" MATCHES "docbook2X ([0-9]+\\.[0-9]+\\.[0-9]+)") |
| 42 |
set(DOCBOOK_TO_MAN_EXECUTABLE ${_docbook_to_man_executable}) |
| 43 |
set(Docbook2X_VERSION ${CMAKE_MATCH_1}) |
| 44 |
else() |
| 45 |
unset(DOCBOOK_TO_MAN_EXECUTABLE) |
| 46 |
unset(DOCBOOK_TO_MAN_EXECUTABLE CACHE) |
| 47 |
endif() |
| 48 |
endif() |
| 49 |
endmacro() |
| 50 |
|
| 51 |
if (DOCBOOK_TO_MAN_EXECUTABLE) |
| 52 |
_check_docbook2x_executable() |
| 53 |
else() |
| 54 |
foreach(test_exec docbook2x-man docbook-to-man db2x_docbook2man docbook2man) |
| 55 |
find_program(DOCBOOK_TO_MAN_EXECUTABLE |
| 56 |
NAMES ${test_exec} |
| 57 |
) |
| 58 |
_check_docbook2x_executable() |
| 59 |
if (DOCBOOK_TO_MAN_EXECUTABLE) |
| 60 |
break() |
| 61 |
endif() |
| 62 |
endforeach() |
| 63 |
endif() |
| 64 |
|
| 65 |
include(FindPackageHandleStandardArgs) |
| 66 |
|
| 67 |
find_package_handle_standard_args(Docbook2X |
| 68 |
# TODO: Use FOUND_VAR when requiring CMake 2.8.11 |
| 69 |
# FOUND_VAR Docbook2X_FOUND |
| 70 |
REQUIRED_VARS DOCBOOK_TO_MAN_EXECUTABLE |
| 71 |
VERSION_VAR Docbook2X_VERSION |
| 72 |
) |
| 73 |
set(Docbook2X_FOUND DOCBOOK2X_FOUND) |
| 74 |
|
| 75 |
if (Docbook2X_FOUND) |
| 76 |
macro(install_docbook_man_page name section) |
| 77 |
set(inputfn "man-${name}.${section}.xml") |
| 78 |
set(input "${CMAKE_CURRENT_SOURCE_DIR}/${inputfn}") |
| 79 |
set(outputfn "${name}.${section}") |
| 80 |
set(output "${CMAKE_CURRENT_BINARY_DIR}/${outputfn}") |
| 81 |
set(target "manpage-${outputfn}") |
| 82 |
|
| 83 |
add_custom_command( |
| 84 |
OUTPUT ${output} |
| 85 |
COMMAND ${DOCBOOK_TO_MAN_EXECUTABLE} ${input} |
| 86 |
DEPENDS ${input} |
| 87 |
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
| 88 |
) |
| 89 |
add_custom_target(${target} ALL |
| 90 |
DEPENDS "${output}" |
| 91 |
) |
| 92 |
install( |
| 93 |
FILES ${output} |
| 94 |
DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section} |
| 95 |
) |
| 96 |
endmacro() |
| 97 |
endif() |