Skip to content

Commit ea0cf83

Browse files
committed
[WIP] Add work-in-progress CMakeLists.txt
1 parent 11c1b49 commit ea0cf83

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ configure
88
install-sh
99
missing
1010
src/man*/zh_*/*
11+
CMakeCache.txt
12+
CMakeFiles/
13+
cmake_install.cmake

CMakeLists.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
# SPDX-FileCopyrightText: 2022 Boyuan Yang <073plan@gmail.com>
4+
# SPDX-License-Identifier: CC0-1.0 OR BSD-2-Clause
5+
6+
include(CMakePrintHelpers)
7+
include(GNUInstallDirs)
8+
project(manpages-zh VERSION 1.6.4.0 HOMEPAGE_URL "https://github.com/man-pages-zh/manpages-zh")
9+
10+
option(ENABLE_APPEND_COLOPHON "Append translation information to output man pages" ON)
11+
option(ENABLE_ZHCN "Enable installing zh_CN man pages" ON)
12+
option(ENABLE_ZHTW "Enable installing zh_TW man pages" ON)
13+
14+
set(EXCLUDED_MANPAGES "" CACHE STRING "Man pages that are not installed")
15+
16+
list(LENGTH EXCLUDED_MANPAGES EXCLUDED_MANPAGES_SIZE)
17+
if (EXCLUDED_MANPAGES_SIZE GREATER 0)
18+
message(STATUS "Will exclude total of ${EXCLUDED_MANPAGES_SIZE} man pages.")
19+
set(FILTER_EXCLUDED_MANPAGES 1)
20+
else ()
21+
set(FILTER_EXCLUDED_MANPAGES 0)
22+
endif ()
23+
24+
if (ENABLE_APPEND_COLOPHON)
25+
find_package(Python3 REQUIRED COMPONENTS Interpreter)
26+
endif (ENABLE_APPEND_COLOPHON)
27+
28+
find_program(opencc opencc HINTS "/usr/bin/")
29+
if (opencc_NOTFOUND)
30+
message(FATAL_ERROR "OpenCC not detected on your system")
31+
endif ()
32+
33+
34+
## Actual handling of man pages
35+
set(MANDIR_LIST "man1" "man2" "man3" "man4" "man5" "man6" "man7" "man8" "mann")
36+
37+
foreach (MANDIR ${MANDIR_LIST})
38+
file(GLOB CURRENT_MAN_PAGES "src/${MANDIR}/*.*")
39+
foreach (CURRENT_MAN_PAGE ${CURRENT_MAN_PAGES})
40+
get_filename_component(MAN_PAGE_NAME ${CURRENT_MAN_PAGE} NAME)
41+
if (${MAN_PAGE_NAME} STREQUAL "Makefile.am")
42+
continue()
43+
endif ()
44+
if (FILTER_EXCLUDED_MANPAGES)
45+
if (${MAN_PAGE_NAME} IN_LIST EXCLUDED_MANPAGES)
46+
message(WARNING "Skipping excluded man page ${MAN_PAGE_NAME}...")
47+
continue()
48+
endif ()
49+
endif (FILTER_EXCLUDED_MANPAGES)
50+
# TODO: Process and install this man page
51+
# cmake_print_variables(MAN_PAGE_NAME)
52+
endforeach ()
53+
endforeach ()

0 commit comments

Comments
 (0)