aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt53
1 files changed, 28 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 528e6404..acf09e86 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_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
-)
-
-ADD_CUSTOM_TARGET(man ALL
- DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.1
- DEPENDS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.5)
-
-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}/${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/sway.5
- DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man5
-)
+add_custom_target(man ALL)
+
+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-${name}.${section}"
+ DEPENDS
+ "${CMAKE_CURRENT_BINARY_DIR}/${name}.${section}")
+ add_dependencies(man
+ "man-${name}.${section}")
+
+ install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}.${section}"
+ DESTINATION "share/man/man${section}"
+ COMPONENT documentation)
+endfunction ()
+
+add_manpage(sway 1)
+add_manpage(sway 5)
INSTALL(
FILES ${PROJECT_SOURCE_DIR}/sway.desktop