Files
swift-mirror/cmake/modules/SwiftManpage.cmake
Alex Langford 61be4d969f [CMake][NFC] Introduce component targets for proper dependency tracking
This commit introduces a CMake target for each component, adds install targets
for them, and switches build-script-impl to use the target `install-components`
for installation. Each of the targets for each component depends on each
of the individual targets and outputs that are associated with the
corresponding swift-component.

This is equivalent to what already exists, because right now install rules are
only generated for components that we want to install. Therefore, this commit
should be an NFC.

This is a resubmission (with modifications) of an earlier change. I originally
committed this but there were problems with some installation rules.
2019-08-22 10:16:50 -07:00

47 lines
1.3 KiB
CMake

include(CMakeParseArguments)
find_program(POD2MAN pod2man)
# Create a target to create a man page from a pod file.
#
# manpage(
# SOURCE foobar.pod
# PAGE_HEADER "text"
# MAN_FILE_BASENAME foobar
# MAN_SECTION N
# INSTALL_IN_COMPONENT comp
# )
function(manpage)
cmake_parse_arguments(
MP # prefix
"" # options
"SOURCE;PAGE_HEADER;MAN_FILE_BASENAME;MAN_SECTION;INSTALL_IN_COMPONENT" # single-value args
"" # multi-value args
${ARGN})
if(NOT POD2MAN)
message(FATAL_ERROR "Need pod2man installed to generate man page")
endif()
set(output_file_name
"${CMAKE_CURRENT_BINARY_DIR}/${MP_MAN_FILE_BASENAME}.${MP_MAN_SECTION}")
add_custom_command_target(
manpage_target
COMMAND
"${POD2MAN}" "--section" "${MP_MAN_SECTION}"
"--center" "${MP_PAGE_HEADER}" "--release=\"swift ${SWIFT_VERSION}\""
"--name" "${MP_MAN_FILE_BASENAME}"
"--stderr"
"${MP_SOURCE}" > "${output_file_name}"
OUTPUT "${output_file_name}"
DEPENDS "${MP_SOURCE}"
ALL)
add_dependencies(${MP_INSTALL_IN_COMPONENT} ${manpage_target})
swift_install_in_component(FILES "${output_file_name}"
DESTINATION "share/man/man${MP_MAN_SECTION}"
COMPONENT "${MP_INSTALL_IN_COMPONENT}")
endfunction()