Skip to content

Commit 45b4e45

Browse files
committed
Fix deferred messages and enhance feature summary output
1 parent 79bc9e9 commit 45b4e45

File tree

11 files changed

+152
-157
lines changed

11 files changed

+152
-157
lines changed

bin/init.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ endif()
123123

124124
file(GLOB_RECURSE patches ${PHP_ROOT_DIR}/patches/${PHP_VERSION}/*.patch)
125125

126-
foreach(patch ${patches})
126+
foreach(patch IN LISTS patches)
127127
# Apply the patch with Git.
128128
execute_process(
129129
COMMAND ${GIT_EXECUTABLE} apply --ignore-whitespace "${patch}"

bin/php.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ function(php_download)
235235

236236
# Download PHP tarball.
237237
if(NOT EXISTS ${PHP_TARBALL})
238-
foreach(url ${urls})
238+
foreach(url IN LISTS urls)
239239
php_check_url(${url} found)
240240

241241
if(found)
@@ -299,7 +299,7 @@ function(php_prepare_sources)
299299
string(REGEX MATCH [[^([0-9]+\.[0-9]+)]] _ "${PHP_VERSION}")
300300
file(GLOB_RECURSE patches ${PHP_ROOT_DIR}/patches/${CMAKE_MATCH_1}/*.patch)
301301

302-
foreach(patch ${patches})
302+
foreach(patch IN LISTS patches)
303303
# Execute the patch command.
304304
execute_process(
305305
COMMAND ${GIT_EXECUTABLE} apply --ignore-whitespace "${patch}"

cmake/CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ include(cmake/CMakeDefaults.cmake)
55

66
message(STATUS "Initializing PHP build system")
77
message(STATUS "=============================")
8-
message(STATUS "")
98

109
message(STATUS "CMake version: ${CMAKE_VERSION}")
1110
message(STATUS "CMake generator: ${CMAKE_GENERATOR}")
@@ -42,22 +41,22 @@ add_subdirectory(win32)
4241
add_subdirectory(main)
4342
add_subdirectory(scripts)
4443

45-
# Check thread safety.
46-
include(PHP/ThreadSafety)
47-
4844
# Generate *_arginfo.h headers from *.stub.php sources.
4945
include(PHP/Stubs)
5046

47+
# Check thread safety.
48+
include(PHP/ThreadSafety)
49+
5150
# Execute all deferred calls. Calls are additionally sorted with natural
5251
# comparison method by their IDs. If call hasn't set any ID number, CMake
5352
# assigns it a default value of __<number>.
5453
block()
5554
cmake_language(DEFER GET_CALL_IDS ids)
5655
list(SORT ids COMPARE NATURAL)
57-
foreach(id ${ids})
56+
foreach(id IN LISTS ids)
5857
cmake_language(DEFER GET_CALL ${id} call)
5958
list(POP_FRONT call command)
60-
message(STATUS "Executing deferred call: ${command}")
59+
message(VERBOSE "Executing deferred call: ${command}")
6160
cmake_language(CALL ${command} ${call})
6261
cmake_language(DEFER CANCEL_CALL ${id})
6362
endforeach()

cmake/cmake/Testing.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ block()
1717
endif()
1818

1919
get_property(extensions GLOBAL PROPERTY PHP_EXTENSIONS)
20-
foreach(extension ${extensions})
20+
foreach(extension IN LISTS extensions)
2121
get_target_property(type php_${extension} TYPE)
2222
if(type MATCHES "^(MODULE|SHARED)_LIBRARY$")
2323
get_target_property(isZendExtension php_${extension} PHP_ZEND_EXTENSION)

cmake/cmake/modules/PHP/FeatureSummary.cmake

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,19 @@ include_guard(GLOBAL)
3333

3434
include(FeatureSummary)
3535

36-
# Add new item to the summary preamble with dotted leader:
37-
# " * <what> ..................... : <value>"
38-
function(php_feature_summary_preamble_add_item what value output)
36+
# Add new item to the summary preamble with dotted leader.
37+
function(php_feature_summary_preamble_add_item label value output)
38+
# If preamble is already set, use it to calculate column width, otherwise use
39+
# predefined helper template.
3940
if(${output})
40-
# If preamble is already set, get first line to calculate column width:
41-
string(REGEX MATCH "^ \\\* ([^\r\n]+ [.]+) : " _ "${${output}}")
41+
set(template "${${output}}")
4242
else()
43-
# Helper template to calculate column width:
44-
set(template " * <what> ..................... : <value>")
45-
string(REGEX MATCH [[^ \* (<what> [.]+)]] _ "${template}")
43+
set(template " * <label> .................... : <value>")
4644
endif()
4745

46+
string(REGEX MATCH "^ \\\* ([^\r\n]+ [.]+) : " _ "${template}")
4847
string(LENGTH "${CMAKE_MATCH_1}" width)
49-
string(LENGTH "${what}" length)
48+
string(LENGTH "${label}" length)
5049
math(EXPR numberOfDots "${width} - ${length} - 1")
5150

5251
if(numberOfDots GREATER 0)
@@ -56,26 +55,23 @@ function(php_feature_summary_preamble_add_item what value output)
5655
set(leader)
5756
endif()
5857

59-
string(APPEND ${output} " * ${what}${leader}: ${value}\n")
58+
string(APPEND ${output} " * ${label}${leader}: ${value}\n")
6059
set("${output}" "${${output}}" PARENT_SCOPE)
6160
endfunction()
6261

6362
# Get summary preamble.
6463
function(php_feature_summary_preamble result)
65-
get_target_property(zendVersion Zend::Zend VERSION)
66-
get_target_property(zendExtensionApiNumber Zend::Zend ZEND_EXTENSION_API_NO)
67-
get_target_property(zendModuleApiNumber Zend::Zend ZEND_MODULE_API_NO)
68-
69-
set(preamble)
70-
string(
71-
APPEND
72-
preamble
73-
" * PHP version ................ : ${PHP_VERSION}\n"
74-
" * PHP API version ............ : ${PHP_API_VERSION}\n"
75-
" * Zend Engine version ........ : ${zendVersion}\n"
76-
" * Zend extension API number .. : ${zendExtensionApiNumber}\n"
77-
" * Zend module API number ..... : ${zendModuleApiNumber}\n"
78-
)
64+
php_feature_summary_preamble_add_item("${PROJECT_NAME} version" "${PROJECT_VERSION}" preamble)
65+
php_feature_summary_preamble_add_item("PHP API version" "${PHP_API_VERSION}" preamble)
66+
67+
if(TARGET Zend::Zend)
68+
get_target_property(zendVersion Zend::Zend VERSION)
69+
get_target_property(zendExtensionApi Zend::Zend ZEND_EXTENSION_API_NO)
70+
get_target_property(zendModuleApi Zend::Zend ZEND_MODULE_API_NO)
71+
php_feature_summary_preamble_add_item("Zend Engine version" "${zendVersion}" preamble)
72+
php_feature_summary_preamble_add_item("Zend extension API number" "${zendExtensionApi}" preamble)
73+
php_feature_summary_preamble_add_item("Zend module API number" "${zendModuleApi}" preamble)
74+
endif()
7975

8076
if(CMAKE_C_COMPILER_LOADED)
8177
set(compiler)
@@ -152,8 +148,15 @@ function(php_feature_summary)
152148
string(PREPEND item "with ")
153149
endif()
154150
string(PREPEND item " - ")
151+
152+
set(indentation " ")
155153
else()
156-
set(parent "${feature}")
154+
if(feature MATCHES "^(ext|sapi)/")
155+
set(parent "${feature}")
156+
else()
157+
unset(parent)
158+
endif()
159+
157160
string(REGEX REPLACE "^(ext|sapi)/" "" item "${feature}")
158161
string(PREPEND item " * ")
159162
if(feature MATCHES "^ext/([^ ]+)$")
@@ -164,10 +167,13 @@ function(php_feature_summary)
164167
endif()
165168
endif()
166169
endif()
170+
171+
set(indentation " ")
167172
endif()
168173

169174
get_property(description GLOBAL PROPERTY _CMAKE_${feature}_DESCRIPTION)
170175
if(description)
176+
string(REPLACE "\n" "\n${indentation}" description "${description}")
171177
string(APPEND item ", ${description}")
172178
endif()
173179

cmake/cmake/modules/PHP/ThreadSafety.cmake

Lines changed: 58 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ Check for thread safety, a.k.a. ZTS (Zend thread safety) build.
2020
during the generation phase to determine thread safety enabled from the
2121
configuration phase. For example, the `PHP_EXTENSION_DIR` configuration
2222
variable needs to be set depending on the thread safety.
23+
24+
## Basic usage
25+
26+
```cmake
27+
# CMakeLists.txt
28+
include(PHP/ThreadSafety)
29+
```
2330
#]=============================================================================]
2431

2532
include_guard(GLOBAL)
@@ -32,68 +39,55 @@ define_property(
3239
BRIEF_DOCS "Whether the PHP has thread safety enabled"
3340
)
3441

35-
function(_php_thread_safety)
36-
message(CHECK_START "Checking whether to enable thread safety (ZTS)")
37-
38-
add_feature_info(
39-
"Thread safety (ZTS)"
40-
PHP_THREAD_SAFETY
41-
"safe execution in multi-threaded environments"
42-
)
43-
44-
if(NOT PHP_THREAD_SAFETY)
45-
message(CHECK_FAIL "no")
46-
return()
47-
endif()
48-
49-
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
50-
set(THREADS_ENABLE_SYSTEM_EXTENSIONS TRUE)
51-
find_package(Threads)
52-
set_package_properties(
53-
Threads
54-
PROPERTIES
55-
TYPE REQUIRED
56-
PURPOSE "Necessary to enable PHP thread safety."
57-
)
58-
59-
if(Threads_FOUND)
60-
message(CHECK_PASS "yes")
61-
else()
62-
message(CHECK_FAIL "failed")
63-
endif()
64-
65-
target_link_libraries(php_configuration INTERFACE Threads::Threads)
66-
67-
set(ZTS TRUE PARENT_SCOPE)
68-
69-
# Add ZTS compile definition. Some PHP headers might not have php_config.h
70-
# directly available. For example, some Zend headers.
71-
target_compile_definitions(php_configuration INTERFACE ZTS)
72-
73-
# Set custom target property on the PHP configuration target.
74-
set_target_properties(php_configuration PROPERTIES PHP_THREAD_SAFETY ON)
75-
76-
# Add compile definitions for POSIX threads conformance.
77-
# TODO: Recheck these definitions since many of them are deprecated or
78-
# obsolete in favor of the compiler automatic definitions when using threading
79-
# flag on such system.
80-
target_compile_definitions(
81-
php_configuration
82-
INTERFACE
83-
$<$<AND:$<PLATFORM_ID:SunOS>,$<COMPILE_LANGUAGE:ASM,C,CXX>>:_POSIX_PTHREAD_SEMANTICS;_REENTRANT>
84-
$<$<AND:$<PLATFORM_ID:FreeBSD>,$<COMPILE_LANGUAGE:ASM,C,CXX>>:_REENTRANT;_THREAD_SAFE>
85-
$<$<AND:$<PLATFORM_ID:AIX>,$<COMPILE_LANGUAGE:ASM,C,CXX>>:_THREAD_SAFE>
86-
$<$<AND:$<PLATFORM_ID:Linux,HP-UX,SCO_SV,UNIX_SV,UnixWare>,$<COMPILE_LANGUAGE:ASM,C,CXX>>:_REENTRANT>
87-
)
88-
endfunction()
89-
90-
# Run at the end of the configuration so that apache2handler SAPI can
91-
# automatically enable thread safety by setting PHP_THREAD_SAFETY to 'ON'
92-
# during the configuration. Elsewhere, thread safety should be opt-in and
93-
# automatic enabling in the configuration phase shouldn't be encouraged.
94-
cmake_language(
95-
DEFER
96-
DIRECTORY ${PHP_SOURCE_DIR}
97-
ID 1 # Run before other calls so ZTS variable is added in main/php_config.h.
98-
CALL _php_thread_safety
42+
message(CHECK_START "Checking whether to enable thread safety (ZTS)")
43+
44+
add_feature_info(
45+
"Thread safety (ZTS)"
46+
PHP_THREAD_SAFETY
47+
"safe execution in multi-threaded environments"
48+
)
49+
50+
if(NOT PHP_THREAD_SAFETY)
51+
message(CHECK_FAIL "no")
52+
return()
53+
endif()
54+
55+
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
56+
set(THREADS_ENABLE_SYSTEM_EXTENSIONS TRUE)
57+
find_package(Threads)
58+
set_package_properties(
59+
Threads
60+
PROPERTIES
61+
TYPE REQUIRED
62+
PURPOSE "Necessary to enable PHP thread safety."
63+
)
64+
65+
if(Threads_FOUND)
66+
message(CHECK_PASS "yes")
67+
else()
68+
message(CHECK_FAIL "failed")
69+
endif()
70+
71+
target_link_libraries(php_configuration INTERFACE Threads::Threads)
72+
73+
set(ZTS TRUE)
74+
75+
# Add ZTS compile definition. Some PHP headers might not have php_config.h
76+
# directly available. For example, some Zend headers.
77+
target_compile_definitions(php_configuration INTERFACE ZTS)
78+
79+
# Set custom target property on the PHP configuration target.
80+
set_target_properties(php_configuration PROPERTIES PHP_THREAD_SAFETY ON)
81+
82+
# Add compile definitions for POSIX threads conformance.
83+
# TODO: Recheck these definitions since many of them are deprecated or
84+
# obsolete in favor of the compiler automatic definitions when using threading
85+
# flag on such system.
86+
target_compile_definitions(
87+
php_configuration
88+
INTERFACE
89+
$<$<AND:$<PLATFORM_ID:SunOS>,$<COMPILE_LANGUAGE:ASM,C,CXX>>:_POSIX_PTHREAD_SEMANTICS;_REENTRANT>
90+
$<$<AND:$<PLATFORM_ID:FreeBSD>,$<COMPILE_LANGUAGE:ASM,C,CXX>>:_REENTRANT;_THREAD_SAFE>
91+
$<$<AND:$<PLATFORM_ID:AIX>,$<COMPILE_LANGUAGE:ASM,C,CXX>>:_THREAD_SAFE>
92+
$<$<AND:$<PLATFORM_ID:Linux,HP-UX,SCO_SV,UNIX_SV,UnixWare>,$<COMPILE_LANGUAGE:ASM,C,CXX>>:_REENTRANT>
9993
)

cmake/ext/oci8/CMakeLists.txt

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -111,40 +111,29 @@ target_sources(
111111

112112
set(PHP_OCI8_INSTANT_CLIENT "")
113113

114-
# Warn about Apache if oci8 extension is enabled on Linux without PHP_SIGCHILD.
115-
function(_php_oci8_notice)
116-
if(
117-
PHP_SIGCHILD
118-
OR PHP_OCI8_INSTANT_CLIENT
119-
OR CMAKE_SYSTEM_NAME STREQUAL "Windows"
120-
)
121-
return()
114+
# Run at the end of the configuration: Warn about Apache if oci8 extension is
115+
# enabled on Linux without PHP_SIGCHILD.
116+
if(NOT PHP_OCI8_INSTANT_CLIENT AND NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
117+
if(PHP_SOURCE_DIR)
118+
set(dir ${PHP_SOURCE_DIR})
119+
else()
120+
set(dir ${CMAKE_CURRENT_SOURCE_DIR})
122121
endif()
123-
124-
message(NOTICE "
125-
+--------------------------------------------------------------------+
126-
| The oci8 extension notice: |
127-
| If you encounter <defunc> processes when using a local Oracle |
128-
| database, set the value BEQUEATH_DETACH=YES in Oracle Net's |
129-
| sqlnet.ora file on the PHP host, or set the environment variable |
130-
| BEQUEATH_DETACH to YES before starting Apache. If the problem |
131-
| still occurs, then recompile PHP and specify --enable-sigchild |
132-
| when configuring. |
133-
+--------------------------------------------------------------------+
134-
")
135-
endfunction()
136-
137-
# Run at the end of the configuration.
138-
if(PHP_SOURCE_DIR)
139-
set(dir ${PHP_SOURCE_DIR})
140-
else()
141-
set(dir ${CMAKE_CURRENT_SOURCE_DIR})
122+
cmake_language(DEFER DIRECTORY ${dir} CALL php_oci8_notice)
142123
endif()
143-
cmake_language(
144-
DEFER
145-
DIRECTORY ${dir}
146-
CALL _php_oci8_notice
147-
)
124+
function(php_oci8_notice)
125+
cmake_language(DEFER CALL message NOTICE [[
126+
127+
The oci8 extension notice:
128+
129+
If you encounter <defunc> processes when using a local Oracle
130+
database, set the value 'BEQUEATH_DETACH=YES' in Oracle Net's
131+
'sqlnet.ora' file on the PHP host, or set the environment variable
132+
'BEQUEATH_DETACH' to 'YES' before starting Apache. If the problem
133+
still occurs, then recompile PHP and specify 'PHP_SIGCHILD'
134+
configuration variable.
135+
]])
136+
endfunction()
148137

149138
set(HAVE_OCI8 TRUE)
150139

cmake/ext/opcache/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Enable copying PHP CODE pages into HUGE PAGES.
2222
* Default: `ON`
2323
* Values: `ON|OFF`
2424
25-
Enable JIT (Just-In-Time compiler).
25+
Enable JIT (just-in-time) compilation.
2626
2727
## EXT_OPCACHE_CAPSTONE
2828
@@ -60,7 +60,7 @@ cmake_dependent_option(
6060

6161
cmake_dependent_option(
6262
EXT_OPCACHE_JIT
63-
"Enable JIT"
63+
"Enable JIT (just-in-time) compilation"
6464
ON
6565
EXT_OPCACHE
6666
OFF
@@ -270,7 +270,7 @@ endif()
270270
add_feature_info(
271271
"ext/opcache JIT"
272272
HAVE_JIT
273-
"OPcache Just-In-Time compiling support"
273+
"OPcache just-in-time compilation"
274274
)
275275

276276
add_feature_info(

0 commit comments

Comments
 (0)