Files
swift-mirror/cmake/modules/SwiftManpage.cmake
Alex Langford 3d9a28925b [CMake] Modify swift_install_in_component to support cmake install components
CMake supports the notion of installation components. Right now we have some
custom code for supporting swift components. I think that for installation
purposes, it would be nice to use the CMake component system.

This should be a non-functional change. We should still only be generating
install rules for targets and files in components we want to install, and we
still use the install ninja target to install everything.
2019-04-19 14:06:11 -07:00

46 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(
unused_var
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)
swift_install_in_component(FILES "${output_file_name}"
DESTINATION "share/man/man${MP_MAN_SECTION}"
COMPONENT "${MP_INSTALL_IN_COMPONENT}")
endfunction()