Skip to content

Commit 6ed17ad

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 22d40f5 + 862ee8b commit 6ed17ad

File tree

8 files changed

+267
-210
lines changed

8 files changed

+267
-210
lines changed

bin/check-cmake.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,10 @@ function getProjectModules(): array
213213
],
214214
'PHP/CheckCompilerFlag' => ['php_check_compiler_flag'],
215215
'PHP/ConfigureFile' => ['php_configure_file'],
216+
'PHP/Extensions' => ['php_extensions_add'],
216217
'PHP/Install' => ['php_install'],
217218
'PHP/PkgConfigGenerator' => ['pkgconfig_generate_pc'],
219+
'PHP/SAPIs' => ['php_sapis_add'],
218220
'PHP/SearchLibraries' => ['php_search_libraries'],
219221
'PHP/SystemExtensions' => ['PHP::SystemExtensions'],
220222
];

cmake/CMakeLists.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,8 @@ message("
3232
Configuring SAPI modules
3333
------------------------
3434
")
35-
add_subdirectory(sapi/apache2handler)
36-
add_subdirectory(sapi/cgi)
37-
add_subdirectory(sapi/cli)
38-
add_subdirectory(sapi/embed)
39-
add_subdirectory(sapi/fpm)
40-
add_subdirectory(sapi/fuzzer)
41-
add_subdirectory(sapi/litespeed)
42-
add_subdirectory(sapi/phpdbg)
35+
include(PHP/SAPIs)
36+
php_sapis_add(sapi)
4337

4438
message("
4539
Configuring PHP extensions

cmake/cmake/Requirements.cmake

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -141,61 +141,6 @@ endif()
141141
################################################################################
142142
find_package(Sendmail)
143143

144-
################################################################################
145-
# Check if at least one SAPI is enabled.
146-
################################################################################
147-
function(_php_check_enabled_sapis)
148-
set(at_least_one_sapi_is_enabled FALSE)
149-
150-
file(
151-
GLOB_RECURSE
152-
subdirectories
153-
LIST_DIRECTORIES TRUE
154-
${PHP_SOURCE_DIR}/sapi/*/
155-
sapi/*/CMakeLists.txt
156-
)
157-
158-
foreach(dir ${subdirectories})
159-
if(NOT EXISTS ${dir}/CMakeLists.txt)
160-
continue()
161-
endif()
162-
163-
cmake_path(GET dir FILENAME sapi_name)
164-
string(TOUPPER ${sapi_name} sapi_name)
165-
166-
if(NOT DEFINED SAPI_${sapi_name})
167-
file(READ ${dir}/CMakeLists.txt content)
168-
169-
string(
170-
REGEX MATCH
171-
"option\\(SAPI_${sapi_name}[ \t\r\n]+.*\"[ \t\r\n]+([A-Z]+)\\)"
172-
_
173-
${content}
174-
)
175-
176-
if(CMAKE_MATCH_1 STREQUAL "ON")
177-
set(at_least_one_sapi_is_enabled TRUE)
178-
break()
179-
endif()
180-
endif()
181-
182-
if(SAPI_${sapi_name})
183-
set(at_least_one_sapi_is_enabled TRUE)
184-
break()
185-
endif()
186-
endforeach()
187-
188-
if(NOT at_least_one_sapi_is_enabled)
189-
message(
190-
WARNING
191-
"None of the PHP SAPIs have been enabled. If this is intentional, you "
192-
"can disregard this warning."
193-
)
194-
endif()
195-
endfunction()
196-
197-
_php_check_enabled_sapis()
198-
199144
################################################################################
200145
# Find Valgrind.
201146
################################################################################

cmake/cmake/modules/PHP/AddCustomCommand.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ function(php_add_custom_command)
8888
return()
8989
endif()
9090

91+
if(NOT TARGET php_cli)
92+
return()
93+
endif()
94+
9195
if(NOT CMAKE_CROSSCOMPILING)
9296
set(PHP_EXECUTABLE "$<TARGET_FILE:php_cli>")
9397
elseif(CMAKE_CROSSCOMPILING AND CMAKE_CROSSCOMPILING_EMULATOR)

cmake/cmake/modules/PHP/Extensions.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ include_guard(GLOBAL)
9393
define_property(
9494
GLOBAL
9595
PROPERTY PHP_ALL_EXTENSIONS
96-
BRIEF_DOCS "A list of all extensions in the ext directory"
96+
BRIEF_DOCS "A list of all PHP extensions in the ext directory"
9797
)
9898

9999
define_property(
@@ -116,7 +116,7 @@ set_property(GLOBAL PROPERTY PHP_ALWAYS_ENABLED_EXTENSIONS
116116
define_property(
117117
GLOBAL
118118
PROPERTY PHP_EXTENSIONS
119-
BRIEF_DOCS "A list of all enabled extensions"
119+
BRIEF_DOCS "A list of all enabled PHP extensions"
120120
)
121121

122122
define_property(
@@ -128,7 +128,7 @@ define_property(
128128
define_property(
129129
TARGET
130130
PROPERTY PHP_ZEND_EXTENSION
131-
BRIEF_DOCS "Whether the extension target is Zend extension"
131+
BRIEF_DOCS "Whether the PHP extension target is Zend extension"
132132
)
133133

134134
################################################################################

cmake/cmake/modules/PHP/FeatureSummary.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,18 @@ block()
4141
if(parent AND feature MATCHES "^${parent} ")
4242
set(item " * ${feature}")
4343
else()
44-
set(item " * ${feature}")
44+
set(type)
45+
if(feature MATCHES "^ext/([^ ]+)$")
46+
if(CMAKE_MATCH_1)
47+
get_target_property(type php_${CMAKE_MATCH_1} TYPE)
48+
if(type MATCHES "^(MODULE|SHARED)_LIBRARY$")
49+
set(type " (shared)")
50+
else()
51+
set(type)
52+
endif()
53+
endif()
54+
endif()
55+
set(item " * ${feature}${type}")
4556
set(parent "${feature}")
4657
endif()
4758

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#[=============================================================================[
2+
Add subdirectories of PHP SAPIs via `add_subdirectory()`.
3+
4+
This module is responsible for traversing `CMakeLists.txt` files of PHP SAPIs
5+
and adding them via `add_subdirectory()`.
6+
7+
## Exposed macro
8+
9+
```cmake
10+
php_sapis_add(subdirectory)
11+
```
12+
13+
## Custom CMake properties
14+
15+
* `PHP_ALL_SAPIS`
16+
17+
Global property with a list of all PHP SAPIs in the sapi directory.
18+
19+
* `PHP_SAPIS`
20+
21+
This global property contains a list of all enabled PHP SAPIs for the current
22+
configuration.
23+
#]=============================================================================]
24+
25+
macro(php_sapis_add directory)
26+
_php_sapis_get(${directory} directories)
27+
28+
# Add subdirectories of PHP SAPIs.
29+
foreach(dir ${directories})
30+
cmake_path(GET dir FILENAME sapi)
31+
message(STATUS "Checking ${sapi} SAPI")
32+
list(APPEND CMAKE_MESSAGE_CONTEXT "sapi/${sapi}")
33+
unset(sapi)
34+
35+
add_subdirectory("${dir}")
36+
37+
list(POP_BACK CMAKE_MESSAGE_CONTEXT)
38+
39+
_php_sapis_post_configure("${dir}")
40+
endforeach()
41+
42+
_php_sapis_validate()
43+
44+
unset(directories)
45+
unset(sapis)
46+
endmacro()
47+
48+
# Get a list of subdirectories related to PHP SAPIs.
49+
function(_php_sapis_get directory result)
50+
file(GLOB paths ${directory}/*/CMakeLists.txt)
51+
52+
set(directories "")
53+
54+
foreach(path ${paths})
55+
cmake_path(GET path PARENT_PATH dir)
56+
list(APPEND directories "${dir}")
57+
58+
# Add SAPI name to a list of all SAPIs.
59+
cmake_path(GET dir FILENAME sapi)
60+
set_property(GLOBAL APPEND PROPERTY PHP_ALL_SAPIS ${module})
61+
endforeach()
62+
63+
set(${result} ${directories} PARENT_SCOPE)
64+
endfunction()
65+
66+
# Configure SAPI after its CMakeLists.txt is added.
67+
function(_php_sapis_post_configure directory)
68+
cmake_path(GET directory FILENAME sapi)
69+
70+
if(NOT TARGET php_${sapi})
71+
return()
72+
endif()
73+
74+
set_property(GLOBAL APPEND PROPERTY PHP_SAPIS ${sapi})
75+
76+
if(NOT TARGET PHP::${sapi})
77+
get_target_property(type php_${sapi} TYPE)
78+
79+
if(type STREQUAL "EXECUTABLE")
80+
add_executable(PHP::${sapi} ALIAS php_${sapi})
81+
else()
82+
add_library(PHP::${sapi} ALIAS php_${sapi})
83+
endif()
84+
endif()
85+
endfunction()
86+
87+
# Check if at least one SAPI is enabled.
88+
function(_php_sapis_validate)
89+
get_cmake_property(sapis PHP_SAPIS)
90+
if(NOT sapis)
91+
message(
92+
WARNING
93+
"None of the PHP SAPIs have been enabled. If this is intentional, you "
94+
"can disregard this warning."
95+
)
96+
endif()
97+
endfunction()

0 commit comments

Comments
 (0)