summaryrefslogtreecommitdiff
path: root/docs/man/CMakeLists.txt
blob: b1b901b05e758a180a906169ad5821e7b0de583f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58

set(manuals
	gendiff.1 rpm2cpio.8
	rpm.8 rpmbuild.8 rpmdb.8 rpmkeys.8 rpmsign.8 rpmspec.8
	rpmdeps.8 rpmgraph.8 rpmlua.8 rpm-misc.8 rpmsort.8
)

if (WITH_ARCHIVE)
	list(APPEND manuals rpm2archive.8)
endif()

if (ENABLE_PLUGINS)
	list(APPEND manuals rpm-plugins.8
		rpm-plugin-prioreset.8 rpm-plugin-syslog.8)
	if (WITH_AUDIT)
		list(APPEND manuals rpm-plugin-audit.8)
	endif()
	if (WITH_DBUS)
		list(APPEND manuals
			rpm-plugin-dbus-announce.8 rpm-plugin-systemd-inhibit.8)
	endif()
	if (WITH_FAPOLICYD)
		list(APPEND manuals rpm-plugin-fapolicyd.8)
	endif()
	if (WITH_IMAEVM)
		list(APPEND manuals rpm-plugin-ima.8)
	endif()
	if (WITH_SELINUX)
		list(APPEND manuals rpm-plugin-selinux.8)
	endif()
endif()

foreach(man ${manuals})
	unset(fn)
	if (EXISTS ${PANDOC})
		add_custom_command(OUTPUT ${man} COMMAND ${PANDOC}
				${CMAKE_CURRENT_SOURCE_DIR}/${man}.md
				-s -t man -o ${man} DEPENDS ${man}.md)
		set(fn ${CMAKE_CURRENT_BINARY_DIR}/${man})
	else()
		# dist tarballs have pre-built manuals in the source dir
		if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${man})
			set(fn ${CMAKE_CURRENT_SOURCE_DIR}/${man})
		endif()
	endif()
	if (fn)
		get_filename_component(ext ${fn} EXT)
		string(REPLACE "." "man" section ${ext})
		install(FILES ${fn}
			DESTINATION ${CMAKE_INSTALL_MANDIR}/${section})
	endif()
endforeach()
if (fn)
	add_custom_target(man ALL DEPENDS ${manuals})
else()
	message(WARNING "pandoc not available and not a dist tarball, man pages not available")
endif()