blob: 535b9e3162a3a6b116c502cae74bc73341b38a7f (
about) (
plain) (
blame)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#
# InspIRCd -- Internet Relay Chat Daemon
#
# Copyright (C) 2026 Sadie Powell <sadie@sadiepowell.dev>
#
# This file is part of InspIRCd. InspIRCd is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
message(FATAL_ERROR "You must run CMake using the CMakeLists.txt in the root directory!")
endif()
function(configure_script FILE DIR TYPE)
file(STRINGS "${FILE}.in" LINES)
set(CURRENT_STATE TRUE)
set(PROCESSED_LINES)
set(STATE_STACK)
foreach(FILE_LINE IN LISTS LINES)
if(FILE_LINE MATCHES "^[ \t]*#[ \t]*cmakeifdef[ \t]+([A-Za-z0-9_]+)[\t ]?")
list(APPEND STATE_STACK "${CURRENT_STATE}")
if(CURRENT_STATE AND ${CMAKE_MATCH_1})
set(CURRENT_STATE TRUE)
else()
set(CURRENT_STATE FALSE)
endif()
continue()
elseif(FILE_LINE MATCHES "^[ \t]*#[ \t]*cmakeifndef[ \t]+([A-Za-z0-9_]+)[\t ]?")
list(APPEND STATE_STACK "${CURRENT_STATE}")
if(CURRENT_STATE AND NOT ${CMAKE_MATCH_1})
set(CURRENT_STATE TRUE)
else()
set(CURRENT_STATE FALSE)
endif()
continue()
elseif(FILE_LINE MATCHES "^[ \t]*#[ \t]*cmakeelse[\t ]?")
list(GET STATE_STACK -1 PARENT_STATE)
if(PARENT_STATE AND NOT CURRENT_STATE)
set(CURRENT_STATE TRUE)
else()
set(CURRENT_STATE FALSE)
endif()
continue()
elseif(FILE_LINE MATCHES "^[ \t]*#[ \t]*cmakeendif[\t ]?")
if(STATE_STACK)
list(POP_BACK STATE_STACK CURRENT_STATE)
else()
set(CURRENT_STATE TRUE)
endif()
continue()
endif()
if(CURRENT_STATE)
string(CONFIGURE "${FILE_LINE}" PROCESSED_LINE @ONLY)
string(APPEND PROCESSED_LINES "${PROCESSED_LINE}\n")
endif()
endforeach()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${FILE}" "${PROCESSED_LINES}")
install_owned(
${TYPE} "${CMAKE_CURRENT_BINARY_DIR}/${FILE}"
DESTINATION ${DIR}
${ARGN}
)
endfunction()
configure_script("help.txt" ${CONFIG_DIR} FILES)
if(NOT WIN32)
configure_script("deploy-tls.sh" ${SCRIPT_DIR} PROGRAMS)
configure_script("inspircd" ${SCRIPT_DIR} PROGRAMS)
configure_script("inspircd-test-tls.1" ${MANUAL_DIR} FILES)
configure_script("inspircd.1" ${MANUAL_DIR} FILES)
configure_script("logrotate" ${SCRIPT_DIR} FILES)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
configure_script("org.inspircd.plist" ${SCRIPT_DIR} FILES)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
configure_script("apparmor" ${SCRIPT_DIR} FILES)
configure_script("inspircd.openrc" ${SCRIPT_DIR} PROGRAMS)
configure_script("inspircd.service" ${SCRIPT_DIR} FILES)
endif()
endif()
|