Skip to content

Commit 6443d33

Browse files
committed
Merge branch 'PHP-8.4'
2 parents c8846fd + cac2ba9 commit 6443d33

File tree

5 files changed

+49
-35
lines changed

5 files changed

+49
-35
lines changed

cmake/cmake/BuildTypes.cmake

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ block()
2020
else()
2121
set(
2222
allowedBuildTypes
23-
Debug # Debug info, assertions, not optimized.
24-
DebugAssertions # Custom PHP debug build type with assertions enabled
25-
# in the RelWithDebInfo mode: optimized, debug info,
26-
# assertions.
23+
Debug # Not optimized, debug info, assertions.
24+
DebugAssertions # Custom PHP debug build type based on RelWithDebInfo:
25+
# optimized, debug info, assertions.
2726
MinSizeRel # Same as Release but optimized for size rather than
2827
# speed.
29-
Release # No debug info, no assertions, optimized.
30-
RelWithDebInfo # Debug info, optimized, no assertions.
28+
Release # Optimized, no debug info, no assertions.
29+
RelWithDebInfo # Optimized, debug info, no assertions.
3130
)
3231

3332
set_property(
@@ -48,19 +47,22 @@ block()
4847
endif()
4948
endblock()
5049

51-
target_compile_definitions(
52-
php_configuration
53-
INTERFACE
54-
$<IF:$<CONFIG:Debug,DebugAssertions>,ZEND_DEBUG=1,ZEND_DEBUG=0>
55-
)
56-
5750
# Set CMAKE_<LANG>_FLAGS_<CONFIG> variables for the DebugAssertions build type.
58-
foreach(prefix CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_ASM_FLAGS)
51+
# These should ideally be set for all languages needed for the project scope
52+
# before adding binary targets that need these flags (for example, PHP
53+
# extensions or SAPIs).
54+
foreach(lang C CXX ASM)
5955
string(
6056
REGEX REPLACE
6157
"(-DNDEBUG|/DNDEBUG)"
6258
""
63-
${prefix}_DEBUGASSERTIONS
64-
"${${prefix}_RELWITHDEBINFO}"
59+
CMAKE_${lang}_FLAGS_DEBUGASSERTIONS
60+
"${CMAKE_${lang}_FLAGS_RELWITHDEBINFO}"
6561
)
6662
endforeach()
63+
64+
target_compile_definitions(
65+
php_configuration
66+
INTERFACE
67+
$<IF:$<CONFIG:Debug,DebugAssertions>,ZEND_DEBUG=1,ZEND_DEBUG=0>
68+
)

cmake/cmake/Configuration.cmake

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,25 +182,24 @@ set(
182182
)
183183
mark_as_advanced(PHP_EXTENSION_DIR)
184184

185+
# Assemble the PHP_EXTENSION_DIR default value.
185186
block()
186187
if(NOT PHP_EXTENSION_DIR)
187188
file(READ ${PHP_SOURCE_DIR}/Zend/zend_modules.h content)
188189
string(REGEX MATCH "#define ZEND_MODULE_API_NO ([0-9]*)" _ "${content}")
189-
set(zend_module_api_no ${CMAKE_MATCH_1})
190+
set(zendModuleApiNo ${CMAKE_MATCH_1})
190191

191-
set(extension_dir "${CMAKE_INSTALL_LIBDIR}/php")
192+
set(
193+
extensionDir
194+
"${CMAKE_INSTALL_LIBDIR}/php/${zendModuleApiNo}$<$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>:-zts>$<$<BOOL:$<CONFIG>>:-$<CONFIG>>"
195+
)
192196

193-
# This resembles the PHP Autotools --with-layout=GNU:
194-
set(extension_dir "${extension_dir}/${zend_module_api_no}")
195-
set(extension_dir "${extension_dir}$<$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>:-zts>")
196-
set(extension_dir "${extension_dir}$<$<CONFIG:Debug,DebugAssertions>:-debug>")
197-
# This would be the PHP Autotools --with-layout=PHP (default):
198-
# set(extension_dir "${extension_dir}/extensions")
199-
# set(extension_dir "${extension_dir}/$<IF:$<CONFIG:Debug,DebugAssertions>,debug,no-debug>")
200-
# set(extension_dir "${extension_dir}$<IF:$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>,-zts,-non-zts>")
201-
# set(extension_dir "${extension_dir}-${zend_module_api_no}")
197+
# This would resemble the PHP Autotools --with-layout=GNU:
198+
#set(extensionDir "${CMAKE_INSTALL_LIBDIR}/php/${zendModuleApiNo}$<$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>:-zts>$<$<CONFIG:Debug,DebugAssertions>:-debug>")
199+
# This would ressemble the PHP Autotools --with-layout=PHP (default):
200+
#set(extensionDir "${CMAKE_INSTALL_LIBDIR}/php/extensions/$<IF:$<CONFIG:Debug,DebugAssertions>,debug,no-debug>$<IF:$<BOOL:$<TARGET_PROPERTY:php_configuration,PHP_THREAD_SAFETY>>,-zts,-non-zts>-${zendModuleApiNo}")
202201

203-
set_property(CACHE PHP_EXTENSION_DIR PROPERTY VALUE "${extension_dir}")
202+
set_property(CACHE PHP_EXTENSION_DIR PROPERTY VALUE "${extensionDir}")
204203
endif()
205204
endblock()
206205

docs/cmake/PHP_EXTENSION_DIR.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# `PHP_EXTENSION_DIR`
2+
3+
Default: `${CMAKE_INSTALL_LIBDIR}/php/<ZEND_MODULE_API_NO>(-zts)-${CMAKE_BUILD_TYPE}`
4+
5+
Default directory for dynamically loadable PHP extensions. If left empty, it is
6+
determined automatically. Can be overridden at runtime using the PHP
7+
`extension_dir` INI directive. By default, it is a relative path inside the
8+
installation prefix (`CMAKE_INSTALL_PREFIX`) path. The `ZEND_MODULE_API_NO` is a
9+
value from the `Zend/zend_modules.h`.
10+
11+
For example, default value for the `Release` build type with thread safety
12+
enabled would be `lib/php/20230901-zts-Release`. After the default installation
13+
prefix is prepended, it is `/usr/local/lib/php/202309-zts-Release` (on *nix
14+
systems) and `C:/Program Files/PHP/lib/php/202309-zts-Release` on Windows.

docs/configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ documentation.
165165

166166
## 3. PHP configuration
167167

168+
* [`PHP_EXTENSION_DIR`](/docs/cmake/PHP_EXTENSION_DIR.md)
169+
168170
* `PHP_BUILD_ARCH`
169171

170172
Default: `${CMAKE_SYSTEM_PROCESSOR}`

docs/php-installation.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,8 @@ PHP CMake-based build system specific installation cache variables:
333333
Default: `php`
334334
* `PHP_PEAR_TEMP_DIR` - path where PEAR writes temporary files;
335335
Default: `/tmp/pear` (on *nix), `C:/temp/pear` on Windows.
336-
* `PHP_EXTENSION_DIR` - path containing shared PHP extensions;
337-
Default: `<ZEND_MODULE_API_NO>-<ZTS>-<DEBUG>`, for example,
338-
`20230901-zts-debug` for thread-safe debug build, or `20230901` for
339-
non-thread-safe build
336+
* [`PHP_EXTENSION_DIR`](/docs/cmake/PHP_EXTENSION_DIR.md) - path containing
337+
shared PHP extensions;
340338

341339
### 4.1. Installation directory structure
342340

@@ -359,8 +357,8 @@ PHP installation directory structure when using CMake:
359357
└─📂 Zend # └─📂 Zend
360358
└─📂 ${CMAKE_INSTALL_LIBDIR} # └─📂 lib
361359
└─📂 php # └─📂 php
362-
─📂 20230901-zts-debug... # ├─📂 20230901-zts-debug...
363-
└─📂 build # └─📂 build
360+
─📂 build # ├─📂 build
361+
└─📂 ${PHP_EXTENSION_DIR} # └─📂 20230901-zts-Debug...
364362
└─📂 pkgconfig # └─📂 pkgconfig
365363
├─📄 php-embed.pc # ├─📄 php-embed.pc
366364
└─📄 php.pc # └─📄 php.pc
@@ -425,8 +423,7 @@ root directory:
425423
"PHP_BUILD_PROVIDER": "Acme",
426424
"PHP_BUILD_COMPILER": "GCC",
427425
"PHP_BUILD_ARCH": "x86_64",
428-
"PHP_VERSION_LABEL": "-acme",
429-
"PHP_EXTENSION_DIR": "lib/php83/extensions"
426+
"PHP_VERSION_LABEL": "-acme"
430427
}
431428
}
432429
],

0 commit comments

Comments
 (0)