Skip to content

Commit 8d6ddb5

Browse files
authored
Rename SAPI_<SAPI_NAME> variables to PHP_SAPI_<SAPI_NAME> (#27)
This is a first mitigation step to start taking care of the global state annoyances. All cache variables of some project should ideally 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 `FetchContent` module, where cache variable names can collide from one project to the other as the same `CMakeCache.txt` file is used for the entire build. Some more cache variables are also synced in the PHP SAPIs.
1 parent 018e39b commit 8d6ddb5

File tree

14 files changed

+114
-114
lines changed

14 files changed

+114
-114
lines changed

cmake/cmake/presets/all-disabled.json

+2-2
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

+7-7
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

+2-2
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

+6-6
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

@@ -88,9 +88,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX" AND EXISTS ${Apache_LIBEXECDIR}/httpd.exp)
8888
check_linker_flag(
8989
C
9090
"LINKER:-brtl;LINKER:-bI${Apache_LIBEXECDIR}/httpd.exp"
91-
_HAVE_BRTL_FLAG_C
91+
_PHP_HAVE_BRTL_FLAG_C
9292
)
93-
if(_HAVE_BRTL_FLAG_C)
93+
if(_PHP_HAVE_BRTL_FLAG_C)
9494
target_link_options(
9595
php_sapi_apache2handler
9696
PRIVATE

cmake/sapi/cgi/CMakeLists.txt

+4-4
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

+18-18
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
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`
1717
18-
Build console-less CLI SAPI. Same as the main CLI SAPI but without console (no
19-
output is given).
18+
Build additional console-less CLI SAPI executable (executable name `php-win`).
19+
Same as the main CLI SAPI (`php`) but without the console (no output is given).
2020
2121
> [!NOTE]
2222
> This option is only available when the target system is Windows.
@@ -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,12 +130,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
130130
)
131131
endif()
132132

133-
if(SAPI_CLI_WIN_NO_CONSOLE)
134-
add_executable(php_sapi_cli_win_no_console)
135-
add_executable(PHP::SAPI::cli_win_no_console ALIAS php_sapi_cli_win_no_console)
133+
if(PHP_SAPI_CLI_WIN_NO_CONSOLE)
134+
add_executable(php_sapi_cli_win)
135+
add_executable(PHP::SAPI::cli_win ALIAS php_sapi_cli_win)
136136

137137
target_sources(
138-
php_sapi_cli_win_no_console
138+
php_sapi_cli_win
139139
PRIVATE
140140
cli_win32.c
141141
php_cli_process_title.c
@@ -144,26 +144,26 @@ if(SAPI_CLI_WIN_NO_CONSOLE)
144144
)
145145

146146
set_target_properties(
147-
php_sapi_cli_win_no_console
147+
php_sapi_cli_win
148148
PROPERTIES
149149
OUTPUT_NAME ${PHP_PROGRAM_PREFIX}php-win${PHP_PROGRAM_SUFFIX}
150150
)
151151

152152
target_compile_definitions(
153-
php_sapi_cli_win_no_console
153+
php_sapi_cli_win
154154
PRIVATE
155155
ZEND_ENABLE_STATIC_TSRMLS_CACHE
156156
)
157157

158158
target_link_libraries(
159-
php_sapi_cli_win_no_console
159+
php_sapi_cli_win
160160
PRIVATE
161161
PHP::SAPI
162162
shell32
163163
)
164164

165165
target_link_options(
166-
php_sapi_cli_win_no_console
166+
php_sapi_cli_win
167167
PRIVATE
168168
/stack:67108864
169169
)

cmake/sapi/embed/CMakeLists.txt

+4-4
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

0 commit comments

Comments
 (0)