| 1 |
option(libadplug_BUILD_DOCUMENTATION "Build documentation" "${libadplug_IS_TOP_LEVEL}") |
| 2 |
if(NOT libadplug_BUILD_DOCUMENTATION) |
| 3 |
return() |
| 4 |
endif() |
| 5 |
|
| 6 |
find_program(MAKEINFO_EXECUTABLE |
| 7 |
NAMES makeinfo |
| 8 |
DOC "makeinfo executable location" |
| 9 |
) |
| 10 |
|
| 11 |
include(GNUInstallDirs) |
| 12 |
|
| 13 |
set(VERSION "${PROJECT_VERSION}") |
| 14 |
set(sharedstatedir "${SHAREDSTATEDIR}") |
| 15 |
configure_file(adplugdb.1.in "${CMAKE_CURRENT_BINARY_DIR}/doc/adplugdb.1") |
| 16 |
|
| 17 |
if(NOT MAKEINFO_EXECUTABLE) |
| 18 |
if(NOT WIN32) |
| 19 |
message(STATUS "makeinfo not found") |
| 20 |
endif() |
| 21 |
return() |
| 22 |
endif() |
| 23 |
|
| 24 |
if(CMAKE_VERSION VERSION_LESS 3.20) |
| 25 |
function(convert_to_tex result path) |
| 26 |
get_filename_component(base_name "${file}" NAME_WLE) |
| 27 |
set(tex_name "${base_name}.tex") |
| 28 |
set(${result} "${tex_name}" PARENT_SCOPE) |
| 29 |
endfunction() |
| 30 |
|
| 31 |
function(get_input_path result path) |
| 32 |
get_filename_component(output_path "${path}" ABSOLUTE) |
| 33 |
set(${result} "${output_path}" PARENT_SCOPE) |
| 34 |
endfunction() |
| 35 |
else() |
| 36 |
function(convert_to_tex result path) |
| 37 |
cmake_path(GET path STEM LAST_ONLY base_name) |
| 38 |
set(tex_name "${base_name}.tex") |
| 39 |
set(${result} "${tex_name}" PARENT_SCOPE) |
| 40 |
endfunction() |
| 41 |
|
| 42 |
function(get_input_path result path) |
| 43 |
cmake_path(ABSOLUTE_PATH path OUTPUT_VARIABLE output_path) |
| 44 |
set(${result} "${output_path}" PARENT_SCOPE) |
| 45 |
endfunction() |
| 46 |
endif() |
| 47 |
|
| 48 |
|
| 49 |
set(LIBADPLUG_INFO_FILE "${CMAKE_CURRENT_BINARY_DIR}/libadplug.info") |
| 50 |
set(LIBADPLUG_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/version.texi") |
| 51 |
|
| 52 |
file(TIMESTAMP "${CMAKE_CURRENT_SOURCE_DIR}/libadplug.texi" LIBADPLUG_TEXI_UPDATED "%d %B %Y" UTC) |
| 53 |
file(TIMESTAMP "${CMAKE_CURRENT_SOURCE_DIR}/libadplug.texi" LIBADPLUG_TEXI_MONTH_UPDATED "%B %Y" UTC) |
| 54 |
|
| 55 |
set(at @) |
| 56 |
|
| 57 |
configure_file(version.texi.in "${LIBADPLUG_VERSION_FILE}") |
| 58 |
|
| 59 |
set(SOURCES libadplug.texi fdl.texi "${LIBADPLUG_VERSION_FILE}") |
| 60 |
|
| 61 |
get_input_path(input_f libadplug.texi) |
| 62 |
|
| 63 |
add_custom_command( |
| 64 |
COMMAND |
| 65 |
"${MAKEINFO_EXECUTABLE}" -o "${LIBADPLUG_INFO_FILE}" "${input_f}" |
| 66 |
OUTPUT "${LIBADPLUG_INFO_FILE}" |
| 67 |
DEPENDS ${SOURCES} |
| 68 |
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" |
| 69 |
COMMENT "Building documentation" |
| 70 |
VERBATIM |
| 71 |
) |
| 72 |
|
| 73 |
add_custom_target(libadplug_doc ALL DEPENDS "${LIBADPLUG_INFO_FILE}") |
| 74 |
|