From 4714262c3d6a07d1d48a7fab44316280094e9589 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 12 Nov 2015 21:29:25 -0500 Subject: [PATCH] cmake: simplify manpage generation --- CMakeLists.txt | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 528e64041..acf09e86a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,31 +72,34 @@ INSTALL( DESTINATION /etc/sway/ ) -ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.1 - COMMAND ${A2X_COMMAND} --no-xmllint --doctype manpage --format manpage - -D ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}/sway.1.txt - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sway.1.txt -) +add_custom_target(man ALL) -ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.5 - COMMAND ${A2X_COMMAND} --no-xmllint --doctype manpage --format manpage - -D ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}/sway.5.txt - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sway.5.txt -) +function (add_manpage name section) + add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.${section}" + COMMAND "${A2X_COMMAND}" + --no-xmllint + --doctype manpage + --format manpage + -D "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/${name}.${section}.txt" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.${section}.txt" + COMMENT "Generating manpage for ${name}.${section}") -ADD_CUSTOM_TARGET(man ALL - DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.1 - DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.5) + add_custom_target("man-${name}.${section}" + DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/${name}.${section}") + add_dependencies(man + "man-${name}.${section}") -INSTALL( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.1 - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1 -) + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}.${section}" + DESTINATION "share/man/man${section}" + COMPONENT documentation) +endfunction () -INSTALL( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.5 - DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man5 -) +add_manpage(sway 1) +add_manpage(sway 5) INSTALL( FILES ${PROJECT_SOURCE_DIR}/sway.desktop