Skip to content

Commit 341494e

Browse files
committed
Rename SAPI_<SAPI_NAME> variables to PHP_SAPI_<SAPI_NAME>
This is a first mitigation step to start taking care of the global state annoyances. All cache variables of some project should be scoped inside some namespace. In CMake's case, at the time of writing, this can be taken care of prefixing all variable names. For example, with 'PHP_'. Specifically, this issue is noticed when using the CMake's `FetchContent` module, where concerns with cache variables overrides from one project to the other can happen as the same CMakeCache.txt file is used for the entire build.
1 parent 018e39b commit 341494e

File tree

14 files changed

+99
-99
lines changed

14 files changed

+99
-99
lines changed

cmake/cmake/presets/all-disabled.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"EXT_XMLREADER": false,
2929
"EXT_XMLWRITER": false,
3030

31-
"SAPI_CGI": false,
32-
"SAPI_PHPDBG": false
31+
"PHP_SAPI_CGI": false,
32+
"PHP_SAPI_PHPDBG": false
3333
}
3434
},
3535
{

cmake/cmake/presets/all-enabled.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@
7070
"EXT_ZIP": true,
7171
"EXT_ZLIB": true,
7272

73-
"SAPI_EMBED": true,
74-
"SAPI_FPM": true,
75-
"SAPI_FPM_ACL": true,
76-
"SAPI_FPM_APPARMOR": true,
77-
"SAPI_FPM_SELINUX": true,
78-
"SAPI_FPM_SYSTEMD": true,
79-
"SAPI_LITESPEED": true
73+
"PHP_SAPI_EMBED": true,
74+
"PHP_SAPI_FPM": true,
75+
"PHP_SAPI_FPM_ACL": true,
76+
"PHP_SAPI_FPM_APPARMOR": true,
77+
"PHP_SAPI_FPM_SELINUX": true,
78+
"PHP_SAPI_FPM_SYSTEMD": true,
79+
"PHP_SAPI_LITESPEED": true
8080
}
8181
},
8282
{

cmake/pear/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ block()
100100
if(NOT TARGET PHP::SAPI::cli)
101101
message(
102102
FATAL_ERROR
103-
"The 'PHP_PEAR' option requires PHP CLI SAPI. Please, set 'SAPI_CLI' to "
104-
"'ON'."
103+
"The 'PHP_PEAR' option requires PHP CLI SAPI. Please, set 'PHP_SAPI_CLI' "
104+
"to 'ON'."
105105
)
106106
endif()
107107

cmake/sapi/apache2handler/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Configure the `apache2handler` PHP SAPI.
55
6-
## SAPI_APACHE2HANDLER
6+
## PHP_SAPI_APACHE2HANDLER
77
88
* Default: `OFF`
99
* Values: `ON|OFF`
@@ -30,15 +30,15 @@ cmake -B php-build -DAPACHE2HANDLER=ON -DApache_EXECUTABLE=/opt/apache2/bin/apxs
3030

3131
include(FeatureSummary)
3232

33-
option(SAPI_APACHE2HANDLER "Enable the shared Apache 2 handler SAPI module")
33+
option(PHP_SAPI_APACHE2HANDLER "Enable the shared Apache 2 handler SAPI module")
3434

3535
add_feature_info(
3636
"sapi/apache2handler"
37-
SAPI_APACHE2HANDLER
37+
PHP_SAPI_APACHE2HANDLER
3838
"Apache HTTP server module"
3939
)
4040

41-
if(NOT SAPI_APACHE2HANDLER)
41+
if(NOT PHP_SAPI_APACHE2HANDLER)
4242
return()
4343
endif()
4444

cmake/sapi/cgi/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Configure the `cgi` PHP SAPI.
55
6-
## SAPI_CGI
6+
## PHP_SAPI_CGI
77
88
* Default: `ON`
99
* Values: `ON|OFF`
@@ -14,15 +14,15 @@ Enable the PHP CGI (Common Gateway Interface) SAPI executable module.
1414
include(CheckStructHasMember)
1515
include(FeatureSummary)
1616

17-
option(SAPI_CGI "Enable the CGI (Common Gateway Interface) SAPI" ON)
17+
option(PHP_SAPI_CGI "Enable the CGI (Common Gateway Interface) SAPI" ON)
1818

1919
add_feature_info(
2020
"sapi/cgi"
21-
SAPI_CGI
21+
PHP_SAPI_CGI
2222
"Common Gateway Interface executable"
2323
)
2424

25-
if(NOT SAPI_CGI)
25+
if(NOT PHP_SAPI_CGI)
2626
return()
2727
endif()
2828

cmake/sapi/cli/CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
44
Configure the `cli` PHP SAPI.
55
6-
## SAPI_CLI
6+
## PHP_SAPI_CLI
77
88
* Default: `ON`
99
* Values: `ON|OFF`
1010
1111
Enable the PHP CLI (Command-Line Interpreter/Interface) SAPI executable module.
1212
13-
## SAPI_CLI_WIN_NO_CONSOLE
13+
## PHP_SAPI_CLI_WIN_NO_CONSOLE
1414
1515
* Default: `OFF`
1616
* Values: `ON|OFF`
@@ -28,27 +28,27 @@ include(CheckSymbolExists)
2828
include(CMakeDependentOption)
2929
include(FeatureSummary)
3030

31-
option(SAPI_CLI "Enable the CLI SAPI module" ON)
31+
option(PHP_SAPI_CLI "Enable the CLI SAPI module" ON)
3232
add_feature_info(
3333
"sapi/cli"
34-
SAPI_CLI
34+
PHP_SAPI_CLI
3535
"Command-Line Interpreter/Interface executable"
3636
)
3737

3838
cmake_dependent_option(
39-
SAPI_CLI_WIN_NO_CONSOLE
39+
PHP_SAPI_CLI_WIN_NO_CONSOLE
4040
"Build additional CLI SAPI without console (no output is given)"
4141
OFF
42-
[[SAPI_CLI AND CMAKE_SYSTEM_NAME STREQUAL "Windows"]]
42+
[[PHP_SAPI_CLI AND CMAKE_SYSTEM_NAME STREQUAL "Windows"]]
4343
OFF
4444
)
4545
add_feature_info(
4646
"sapi/cli console-less"
47-
SAPI_CLI_WIN_NO_CONSOLE
47+
PHP_SAPI_CLI_WIN_NO_CONSOLE
4848
"additional executable without console output"
4949
)
5050

51-
if(NOT SAPI_CLI)
51+
if(NOT PHP_SAPI_CLI)
5252
return()
5353
endif()
5454

@@ -130,7 +130,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
130130
)
131131
endif()
132132

133-
if(SAPI_CLI_WIN_NO_CONSOLE)
133+
if(PHP_SAPI_CLI_WIN_NO_CONSOLE)
134134
add_executable(php_sapi_cli_win_no_console)
135135
add_executable(PHP::SAPI::cli_win_no_console ALIAS php_sapi_cli_win_no_console)
136136

cmake/sapi/embed/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Configure the `embed` PHP SAPI.
55
6-
## SAPI_EMBED
6+
## PHP_SAPI_EMBED
77
88
* Default: `OFF`
99
* Values: `ON|OFF`
@@ -19,15 +19,15 @@ to use PHP.
1919

2020
include(FeatureSummary)
2121

22-
option(SAPI_EMBED "Enable the Embed SAPI module")
22+
option(PHP_SAPI_EMBED "Enable the Embed SAPI module")
2323

2424
add_feature_info(
2525
"sapi/embed"
26-
SAPI_EMBED
26+
PHP_SAPI_EMBED
2727
"module for embedding PHP into application"
2828
)
2929

30-
if(NOT SAPI_EMBED)
30+
if(NOT PHP_SAPI_EMBED)
3131
return()
3232
endif()
3333

cmake/sapi/fpm/CMakeLists.txt

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ Configure the `fpm` PHP SAPI.
66
> [!NOTE]
77
> PHP FPM is not available when the target system is Windows.
88
9-
## SAPI_FPM
9+
## PHP_SAPI_FPM
1010
1111
* Default: `OFF`
1212
* Values: `ON|OFF`
1313
1414
Enable the FastCGI Process Manager (FPM) SAPI module.
1515
16-
## SAPI_FPM_USER
16+
## PHP_SAPI_FPM_USER
1717
1818
* Default: `nobody`
1919
2020
Set the user for running PHP FPM.
2121
22-
## SAPI_FPM_GROUP
22+
## PHP_SAPI_FPM_GROUP
2323
2424
* Default: `nobody`
2525
2626
Set the group for running PHP FPM. For a system user, this should usually be set
2727
in a way to match the FPM username.
2828
29-
## SAPI_FPM_ACL
29+
## PHP_SAPI_FPM_ACL
3030
3131
* Default: `OFF`
3232
* Values: `ON|OFF`
@@ -40,7 +40,7 @@ Where to find ACL installation on the system, can be customized with the
4040
> This option is not available when the target system is Darwin (macOS) as this
4141
> system doesn't have ACL.
4242
43-
## SAPI_FPM_APPARMOR
43+
## PHP_SAPI_FPM_APPARMOR
4444
4545
* Default: `OFF`
4646
* Values: `ON|OFF`
@@ -54,7 +54,7 @@ Where to find AppArmor installation on the system, can be customized with the
5454
> This option is not available when the target system is Darwin (macOS) as this
5555
> system doesn't have AppArmor.
5656
57-
## SAPI_FPM_SELINUX
57+
## PHP_SAPI_FPM_SELINUX
5858
5959
* Default: `OFF`
6060
* Values: `ON|OFF`
@@ -68,7 +68,7 @@ Where to find SELinux installation on the system, can be customized with the
6868
> This option is not available when the target system is Darwin (macOS) as this
6969
> system doesn't have SELinux.
7070
71-
## SAPI_FPM_SYSTEMD
71+
## PHP_SAPI_FPM_SYSTEMD
7272
7373
* Default: `OFF`
7474
* Values: `ON|OFF`
@@ -102,84 +102,84 @@ include(PHP/Set)
102102
# FPM configuration.
103103
################################################################################
104104

105-
option(SAPI_FPM "Enable the FPM SAPI module")
105+
option(PHP_SAPI_FPM "Enable the FPM SAPI module")
106106
add_feature_info(
107107
"sapi/fpm"
108-
SAPI_FPM
108+
PHP_SAPI_FPM
109109
"FastCGI Process Manager"
110110
)
111111

112112
php_set(
113-
SAPI_FPM_USER
113+
PHP_SAPI_FPM_USER
114114
TYPE STRING
115-
IF SAPI_FPM
115+
IF PHP_SAPI_FPM
116116
VALUE "nobody"
117117
DOC "Set the user for running PHP FPM (default: nobody)"
118118
)
119119

120120
php_set(
121-
SAPI_FPM_GROUP
121+
PHP_SAPI_FPM_GROUP
122122
TYPE STRING
123-
IF SAPI_FPM
123+
IF PHP_SAPI_FPM
124124
VALUE "nobody"
125125
DOC
126126
"Set the group for running PHP FPM. For a system user, this should usually "
127127
"be set to match the FPM username (default: nobody)"
128128
)
129129

130130
php_set(
131-
SAPI_FPM_ACL
131+
PHP_SAPI_FPM_ACL
132132
TYPE BOOL
133-
IF [[SAPI_FPM AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin"]]
133+
IF [[PHP_SAPI_FPM AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin"]]
134134
VALUE OFF
135135
DOC "Use POSIX Access Control Lists"
136136
)
137137
add_feature_info(
138138
"sapi/fpm ACL"
139-
SAPI_FPM_ACL
139+
PHP_SAPI_FPM_ACL
140140
"POSIX Access Control Lists integration"
141141
)
142142

143143
php_set(
144-
SAPI_FPM_APPARMOR
144+
PHP_SAPI_FPM_APPARMOR
145145
TYPE BOOL
146-
IF [[SAPI_FPM AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin"]]
146+
IF [[PHP_SAPI_FPM AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin"]]
147147
VALUE OFF
148148
DOC "Enable the AppArmor confinement through libapparmor"
149149
)
150150
add_feature_info(
151151
"sapi/fpm AppArmor"
152-
SAPI_FPM_APPARMOR
152+
PHP_SAPI_FPM_APPARMOR
153153
"application confinement integration"
154154
)
155155

156156
php_set(
157-
SAPI_FPM_SELINUX
157+
PHP_SAPI_FPM_SELINUX
158158
TYPE BOOL
159-
IF [[SAPI_FPM AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin"]]
159+
IF [[PHP_SAPI_FPM AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin"]]
160160
VALUE OFF
161161
DOC "Enable the SELinux policy library support"
162162
)
163163
add_feature_info(
164164
"sapi/fpm SELinux"
165-
SAPI_FPM_SELINUX
165+
PHP_SAPI_FPM_SELINUX
166166
"security policy integration"
167167
)
168168

169169
php_set(
170-
SAPI_FPM_SYSTEMD
170+
PHP_SAPI_FPM_SYSTEMD
171171
TYPE BOOL
172-
IF [[SAPI_FPM AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin"]]
172+
IF [[PHP_SAPI_FPM AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin"]]
173173
VALUE OFF
174174
DOC "Enable the systemd integration"
175175
)
176176
add_feature_info(
177177
"sapi/fpm systemd"
178-
SAPI_FPM_SYSTEMD
178+
PHP_SAPI_FPM_SYSTEMD
179179
"system and service manager integration"
180180
)
181181

182-
if(NOT SAPI_FPM)
182+
if(NOT PHP_SAPI_FPM)
183183
return()
184184
endif()
185185

@@ -458,7 +458,7 @@ endif()
458458
# Configure FPM from configuration options.
459459
################################################################################
460460

461-
if(SAPI_FPM_SYSTEMD)
461+
if(PHP_SAPI_FPM_SYSTEMD)
462462
find_package(Systemd 209)
463463
set_package_properties(
464464
Systemd
@@ -480,7 +480,7 @@ else()
480480
set(PHP_FPM_SYSTEMD "simple")
481481
endif()
482482

483-
if(SAPI_FPM_ACL)
483+
if(PHP_SAPI_FPM_ACL)
484484
set(ACL_USE_USER_GROUP TRUE)
485485
find_package(ACL)
486486
set_package_properties(
@@ -502,7 +502,7 @@ if(SAPI_FPM_ACL)
502502
endif()
503503
endif()
504504

505-
if(SAPI_FPM_APPARMOR)
505+
if(PHP_SAPI_FPM_APPARMOR)
506506
find_package(AppArmor)
507507
set_package_properties(
508508
AppArmor
@@ -518,7 +518,7 @@ if(SAPI_FPM_APPARMOR)
518518
endif()
519519
endif()
520520

521-
if(SAPI_FPM_SELINUX)
521+
if(PHP_SAPI_FPM_SELINUX)
522522
find_package(SELinux)
523523
set_package_properties(
524524
SELinux
@@ -581,8 +581,8 @@ php_configure_file(
581581
VARIABLES
582582
prefix "$<INSTALL_PREFIX>"
583583
php_fpm_prefix "$<INSTALL_PREFIX>"
584-
php_fpm_user "${SAPI_FPM_USER}"
585-
php_fpm_group "${SAPI_FPM_GROUP}"
584+
php_fpm_user "${PHP_SAPI_FPM_USER}"
585+
php_fpm_group "${PHP_SAPI_FPM_GROUP}"
586586
EXPANDED_DATADIR "$<PATH:ABSOLUTE_PATH,NORMALIZE,${CMAKE_INSTALL_DATADIR},$<INSTALL_PREFIX>>"
587587
)
588588

0 commit comments

Comments
 (0)