-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
72 lines (63 loc) · 2.01 KB
/
CMakeLists.txt
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019-2021, Intel Corporation
#
find_program(SRC2MAN NAMES src2man)
find_program(GROFF NAMES groff)
find_program(FIND NAMES find)
find_program(DIFF NAMES diff)
find_program(GAWK NAMES gawk) # required by src2man
find_program(PANDOC NAMES pandoc)
if(NOT PANDOC)
message(WARNING "pandoc not found - Markdown documentation will not be generated")
endif()
if(SRC2MAN AND GROFF AND FIND AND DIFF AND GAWK)
# create man pages from sources
set(man3_list ${CMAKE_SOURCE_DIR}/doc/manuals_3.txt)
set(man7_list ${CMAKE_SOURCE_DIR}/doc/manuals_7.txt)
add_custom_target(doc ALL
COMMAND ${CMAKE_SOURCE_DIR}/utils/src2mans.sh
${CMAKE_SOURCE_DIR}/src ${man3_list} ${man7_list}
${CMAKE_SOURCE_DIR}/utils/mans_header.md)
add_custom_target(doc-fix
COMMAND ${CMAKE_SOURCE_DIR}/utils/src2mans.sh
${CMAKE_SOURCE_DIR}/src ${man3_list} ${man7_list}
${CMAKE_SOURCE_DIR}/utils/mans_header.md
fix)
file(STRINGS ${man3_list} man3)
file(STRINGS ${man7_list} man7)
#
# It is just:
# list(TRANSFORM man3 PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
# but 'list(TRANSFORM' requires CMake>=v3.12
#
set(new_man3 "")
foreach(item IN LISTS man3)
set(new_man3 "${CMAKE_CURRENT_BINARY_DIR}/${item};${new_man3}")
endforeach()
set(new_man7 "")
foreach(item IN LISTS man7)
set(new_man7 "${CMAKE_CURRENT_BINARY_DIR}/${item};${new_man7}")
endforeach()
# install manpages
install(FILES ${new_man3}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
install(FILES ${new_man7}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man7)
else()
if(NOT SRC2MAN)
message(WARNING "src2man not found - man pages will not be generated")
endif()
if(NOT GROFF)
message(WARNING "groff not found - man pages will not be generated")
endif()
if(NOT FIND)
message(WARNING "find not found - man pages will not be generated")
endif()
if(NOT DIFF)
message(WARNING "diff not found - man pages will not be generated")
endif()
if(NOT GAWK)
message(WARNING "gawk not found - man pages will not be generated")
endif()
endif()