2024-10-09 18:08:00 +03:00
|
|
|
include(today)
|
2022-08-16 11:01:50 +03:00
|
|
|
include(GNUInstallDirs)
|
2024-10-02 23:37:35 +03:00
|
|
|
include(CleaningConfigureFile)
|
2022-08-16 11:01:50 +03:00
|
|
|
|
2024-10-09 18:08:00 +03:00
|
|
|
get_filename_component(INSTALL_FREERDP_MAN_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE)
|
|
|
|
|
2017-01-16 13:34:32 +03:00
|
|
|
function(install_freerdp_man manpage section)
|
2024-02-21 13:37:28 +03:00
|
|
|
if(WITH_MANPAGES)
|
|
|
|
install(FILES ${manpage} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${section})
|
|
|
|
endif()
|
2017-01-16 13:34:32 +03:00
|
|
|
endfunction()
|
2023-12-14 16:13:53 +03:00
|
|
|
|
2024-03-19 14:19:07 +03:00
|
|
|
function(generate_and_install_freerdp_man_from_template name_base section api)
|
2024-02-21 13:37:28 +03:00
|
|
|
if(WITH_MANPAGES)
|
2024-03-19 14:19:07 +03:00
|
|
|
if (WITH_BINARY_VERSIONING)
|
|
|
|
set(manpage "${CMAKE_CURRENT_BINARY_DIR}/${name_base}${api}.${section}")
|
|
|
|
else()
|
|
|
|
set(manpage "${CMAKE_CURRENT_BINARY_DIR}/${name_base}.${section}")
|
|
|
|
endif()
|
2024-10-02 23:37:35 +03:00
|
|
|
cleaning_configure_file(${name_base}.${section}.in ${manpage})
|
2024-03-19 14:19:07 +03:00
|
|
|
install_freerdp_man(${manpage} ${section})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2024-10-09 18:08:00 +03:00
|
|
|
# Generate an install target for a manpage.
|
|
|
|
#
|
|
|
|
# This is not as simple as it looks like:
|
|
|
|
#
|
|
|
|
# 1. extract the raw file names (files that require configure_file end with .in, ready to use files
|
|
|
|
# with .1 or some other manpage related number)
|
|
|
|
# 2. do the same for every dependency
|
|
|
|
# 3. create a command to run during build. Add a few defined symbols by default
|
|
|
|
# 4. add variable names passed to the function to the command
|
|
|
|
# 5. run CMake -P as custom_target during build.
|
|
|
|
# * run configure_file for all .in files
|
|
|
|
# * concatenate all manpage sections to the target manpage
|
|
|
|
# 6. create the actual install target
|
|
|
|
function(generate_and_install_freerdp_man_from_xml target section dependencies variable_names)
|
2024-03-19 14:19:07 +03:00
|
|
|
if(WITH_MANPAGES)
|
2024-10-09 18:08:00 +03:00
|
|
|
get_target_property(name_base "${target}" OUTPUT_NAME)
|
2024-05-16 10:36:27 +03:00
|
|
|
set(template "${target}.${section}")
|
|
|
|
set(MANPAGE_NAME "${name_base}")
|
|
|
|
set(manpage "${name_base}.${section}")
|
2024-02-21 13:37:28 +03:00
|
|
|
|
|
|
|
# We need the variable ${MAN_TODAY} to contain the current date in ISO
|
2024-10-09 18:08:00 +03:00
|
|
|
# format to replace it in the cleaning_configure_file step.
|
2024-02-21 13:37:28 +03:00
|
|
|
include(today)
|
|
|
|
|
|
|
|
TODAY(MAN_TODAY)
|
|
|
|
|
2024-10-09 18:08:00 +03:00
|
|
|
set(GENERATE_COMMAND
|
|
|
|
-Dtemplate=\"${template}\"
|
|
|
|
-DMANPAGE_NAME=\"${MANPAGE_NAME}\"
|
|
|
|
-Dmanpage=\"${manpage}\"
|
|
|
|
-DMAN_TODAY=\"${MAN_TODAY}\"
|
|
|
|
-DCURRENT_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
|
|
|
|
-DCURRENT_BINARY_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"
|
|
|
|
-Dtarget="${target}"
|
|
|
|
-Dsection="${section}"
|
|
|
|
-Ddependencies="${dependencies}"
|
|
|
|
)
|
2024-02-21 13:37:28 +03:00
|
|
|
|
2024-10-09 18:08:00 +03:00
|
|
|
foreach(var IN ITEMS ${variable_names})
|
|
|
|
list(APPEND GENERATE_COMMAND
|
|
|
|
-D${var}=${${var}}
|
|
|
|
)
|
2024-02-21 13:37:28 +03:00
|
|
|
endforeach()
|
|
|
|
|
2024-10-09 18:08:00 +03:00
|
|
|
list(APPEND GENERATE_COMMAND
|
|
|
|
-P \"${INSTALL_FREERDP_MAN_SCRIPT_DIR}/GenerateManpages.cmake\"
|
|
|
|
)
|
2024-03-19 14:19:07 +03:00
|
|
|
|
2024-10-09 18:08:00 +03:00
|
|
|
add_custom_target(${manpage}.target ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} ${GENERATE_COMMAND}
|
|
|
|
DEPENDS generate_argument_manpage.target
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
)
|
2024-02-21 13:37:28 +03:00
|
|
|
|
2024-03-19 14:19:07 +03:00
|
|
|
install_freerdp_man(${CMAKE_CURRENT_BINARY_DIR}/${manpage} ${section})
|
2023-12-14 16:13:53 +03:00
|
|
|
endif()
|
|
|
|
endfunction()
|