Skip to content

Commit 19187f7

Browse files
committed
Update docs
1 parent 3a23716 commit 19187f7

File tree

4 files changed

+112
-53
lines changed

4 files changed

+112
-53
lines changed

docs/cmake-modules/PHP/Extensions.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,51 @@ https://bugs.php.net/53141
3737
TODO: Improve this or simplify the sorting complexities in its entierity. PHP
3838
dependencies are handled very basically ATM.
3939

40-
Exposed macro:
40+
## Exposed macro
4141

4242
```cmake
4343
php_extensions_add(subdirectory)
4444
```
45+
46+
## Custom CMake properties
47+
48+
* `PHP_ALL_EXTENSIONS`
49+
50+
Global property with a list of all PHP extensions in the ext directory.
51+
52+
* `PHP_ALWAYS_ENABLED_EXTENSIONS`
53+
54+
This global property contains a list of always enabled PHP extensions which
55+
don't need the `HAVE_<extension-name>` preprocessor macros defined in the PHP
56+
configuration header and can be considered as part of the core PHP engine.
57+
58+
* `PHP_EXTENSIONS`
59+
60+
This global property contains a list of all enabled PHP extensions for the
61+
current configuration. Extensions are sorted by the directory priority (see
62+
`PHP_PRIORITY` property) and extension dependencies (added with CMake command
63+
`add_dependencies()`).
64+
65+
* `PHP_PRIORITY`
66+
67+
This optional directory property controls the order of the PHP extensions
68+
added with the `add_subdirectory()`. Directory added with `add_subdirectory()`
69+
won't be visible in the configuration phase for the directories added before.
70+
Priority number can be used to add the extension subdirectory prior (0..100)
71+
or later (\>100) to other extensions. By default extensions are sorted
72+
alphabetically and added in between. This enables having extension variables
73+
visible in depending extensions.
74+
75+
* `PHP_ZEND_EXTENSION`
76+
77+
Extensions can utilize this custom target property, which designates the
78+
extension as a Zend extension rather than a standard PHP extension. Zend
79+
extensions function similarly to regular PHP extensions, but they are loaded
80+
using the `zend_extension` INI directive and possess an internally distinct
81+
structure with additional hooks. Typically employed for advanced
82+
functionalities like debuggers and profilers, Zend extensions offer enhanced
83+
capabilities.
84+
85+
```cmake
86+
set_target_properties(php_<extension_name> PROPERTIES PHP_ZEND_EXTENSION TRUE)
87+
```

docs/cmake-modules/PHP/PkgConfigGenerator.md

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ pkgconfig_generate_pc(
2222
<pc-template-file>
2323
<pc-file-output>
2424
TARGET <target>
25-
[INSTALL_DESTINATION <path>]
26-
[VARIABLES [<variable> <value>] [<variable_2>:BOOL <value_2>...] ...]
27-
[SKIP_BOOL_NORMALIZATION]
25+
[VARIABLES <variable> <value> ...]
2826
)
2927
```
3028

@@ -33,19 +31,16 @@ template.
3331

3432
* `TARGET`
3533
Name of the target for getting libraries.
36-
* `INSTALL_DESTINATION`
37-
Path to the pkgconfig directory where generated .pc file will be installed to.
38-
Usually it is `${CMAKE_INSTALL_LIBDIR}/pkgconfig`. If not provided, .pc file
39-
will not be installed.
4034
* `VARIABLES`
41-
Pairs of variable names and values. To pass booleans, append ':BOOL' to the
42-
variable name. For example:
35+
Pairs of variable names and values. Variable values support generator
36+
expressions. For example:
4337

4438
```cmake
4539
pkgconfig_generate_pc(
4640
...
4741
VARIABLES
48-
variable_name:BOOL "${variable_name}"
42+
debug "$<IF:$<CONFIG:Debug>,yes,no>"
43+
variable "$<IF:$<BOOL:${VARIABLE}>,yes,no>"
4944
)
5045
```
5146

@@ -57,10 +52,3 @@ template.
5752
The custom PHP specific `$<PHP_EXPAND:path>` generator expression can be used
5853
in variable values. It is automatically replaced to `<install-prefix>/path`
5954
if `path` is relative, or to just `path` if `path` is absolute.
60-
61-
* `SKIP_BOOL_NORMALIZATION`
62-
CMake booleans have values `yes`, `no`, `true`, `false`, `on`, `off`, `1`,
63-
`0`, they can even be case insensitive and so on. By default, all booleans
64-
(`var:BOOL`, see above) are normalized to values `yes` or `no`. If this option
65-
is given, boolean values are replaced in .pc template with the CMake format
66-
instead (they will be replaced to `ON` or `OFF` and similar).

docs/cmake-modules/PHP/ThreadSafety.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@ See: [ThreadSafety.cmake](https://github.com/petk/php-build-system/tree/master/c
44

55
Check for thread safety, a.k.a. ZTS (Zend thread safety) build.
66

7-
Cache variables:
7+
## Cache variables
88

99
* `ZTS`
10+
1011
Whether PHP thread safety is enabled.
12+
13+
## Custom CMake properties
14+
15+
* `PHP_THREAD_SAFETY`
16+
17+
When thread safety is enabled (either by the configuration variable
18+
`PHP_THREAD_SAFETY` or automatically by the `apache2handler` PHP SAPI module),
19+
also a custom target property `PHP_THREAD_SAFETY` is added to the
20+
`PHP::configuration` target, which can be then used in generator expressions
21+
during the generation phase to determine thread safety enabled from the
22+
configuration phase. For example, the `PHP_EXTENSION_DIR` configuration
23+
variable needs to be set depending on the thread safety.

docs/cmake.md

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ works and how it can be used.
1515
* [6. CMake minimum version for PHP](#6-cmake-minimum-version-for-php)
1616
* [7. Interface library](#7-interface-library)
1717
* [8. PHP CMake modules](#8-php-cmake-modules)
18-
* [9. PHP extensions](#9-php-extensions)
19-
* [9.1. Properties](#91-properties)
20-
* [10. PHP SAPI (Server API) modules](#10-php-sapi-server-api-modules)
21-
* [11. Generated files](#11-generated-files)
22-
* [11.1. Parser and lexer files](#111-parser-and-lexer-files)
23-
* [12. Performance](#12-performance)
24-
* [13. Testing](#13-testing)
25-
* [14. Windows notes](#14-windows-notes)
26-
* [14.1. Module-definition (.def) files](#141-module-definition-def-files)
18+
* [9. Custom CMake properties](#9-custom-cmake-properties)
19+
* [10. PHP extensions](#10-php-extensions)
20+
* [11. PHP SAPI (Server API) modules](#11-php-sapi-server-api-modules)
21+
* [12. Generated files](#12-generated-files)
22+
* [12.1. Parser and lexer files](#121-parser-and-lexer-files)
23+
* [13. Performance](#13-performance)
24+
* [14. Testing](#14-testing)
25+
* [15. Windows notes](#15-windows-notes)
26+
* [15.1. Module-definition (.def) files](#151-module-definition-def-files)
2727

2828
## 1. Directory structure
2929

@@ -321,7 +321,39 @@ include(PHP/NewModule)
321321
* [PHP/CheckCompilerFlag](/docs/cmake-modules/PHP/CheckCompilerFlag.md)
322322
* [PHP/SearchLibraries](/docs/cmake-modules/PHP/SearchLibraries.md)
323323

324-
## 9. PHP extensions
324+
## 9. Custom CMake properties
325+
326+
* `PHP_ALL_EXTENSIONS`
327+
328+
Global property set by the [`PHP/Extensions`](cmake-modules/PHP/Extensions.md)
329+
module.
330+
331+
* `PHP_ALWAYS_ENABLED_EXTENSIONS`
332+
333+
Global property set by the [`PHP/Extensions`](cmake-modules/PHP/Extensions.md)
334+
module.
335+
336+
* `PHP_EXTENSIONS`
337+
338+
Global property set by the [`PHP/Extensions`](cmake-modules/PHP/Extensions.md)
339+
module.
340+
341+
* `PHP_PRIORITY`
342+
343+
Directory property set by the
344+
[`PHP/Extensions`](cmake-modules/PHP/Extensions.md) module.
345+
346+
* `PHP_THREAD_SAFETY`
347+
348+
Target property set by the
349+
[`PHP/ThreadSafety`](cmake-modules/PHP/ThreadSafety.md) module on the
350+
`PHP::configuration` target, when thread safety is enabled.
351+
352+
* `PHP_ZEND_EXTENSION`
353+
354+
See the [`PHP/Extensions`](cmake-modules/PHP/Extensions.md) module.
355+
356+
## 10. PHP extensions
325357

326358
PHP has several ways to install PHP extensions:
327359

@@ -374,24 +406,7 @@ the extension's source directory.
374406
Example of `CMakeLists.txt` for PHP extensions can be found in the
375407
`ext/skeleton` directory.
376408

377-
### 9.1. Properties
378-
379-
Extensions can utilize the following custom CMake properties:
380-
381-
* `PHP_ZEND_EXTENSION`
382-
383-
This property designates the extension as a Zend extension rather than a
384-
standard PHP extension. Zend extensions function similarly to regular PHP
385-
extensions, but they are loaded using the `zend_extension` INI directive and
386-
possess an internally distinct structure with additional hooks. Typically
387-
employed for advanced functionalities like debuggers and profilers, Zend
388-
extensions offer enhanced capabilities.
389-
390-
```cmake
391-
set_target_properties(php_<extension_name> PROPERTIES PHP_ZEND_EXTENSION TRUE)
392-
```
393-
394-
## 10. PHP SAPI (Server API) modules
409+
## 11. PHP SAPI (Server API) modules
395410

396411
PHP works through the concept of SAPI modules located in the `sapi` directory.
397412

@@ -409,7 +424,7 @@ There are other SAPI modules located in the ecosystem:
409424
* [ngx-php](https://github.com/rryqszq4/ngx-php)
410425
* ...
411426

412-
## 11. Generated files
427+
## 12. Generated files
413428

414429
During the build process, there are several files generated, some of which are
415430
also tracked in the Git repository for a smoother workflow:
@@ -440,7 +455,7 @@ also tracked in the Git repository for a smoother workflow:
440455
└─ zend_config.w32.h # Zend engine configuration header for Windows
441456
```
442457

443-
### 11.1. Parser and lexer files
458+
### 12.1. Parser and lexer files
444459

445460
So-called parser files are generated with
446461
[bison](https://www.gnu.org/software/bison/) tool from `*.y` source files to C
@@ -537,7 +552,7 @@ cmake -S <source-dir> -B <build-dir>
537552
cmake --build <build-dir> -t php_generate_files
538553
```
539554

540-
## 12. Performance
555+
## 13. Performance
541556

542557
When CMake is doing configuration phase, the profiling options can be used to do
543558
build system performance analysis of CMake files.
@@ -548,7 +563,7 @@ cmake --profiling-output ./profile.json --profiling-format google-trace ../php-s
548563

549564
![CMake profiling](/docs/images/cmake-profiling.png)
550565

551-
## 13. Testing
566+
## 14. Testing
552567

553568
PHP source code tests (`*.phpt` files) are written in PHP and are executed with
554569
`run-tests.php` script from the very beginning of the PHP development. When
@@ -580,9 +595,9 @@ using the `CMakePresets.json` file and its `testPresets` field.
580595
ctest --preset all-enabled
581596
```
582597

583-
## 14. Windows notes
598+
## 15. Windows notes
584599

585-
### 14.1. Module-definition (.def) files
600+
### 15.1. Module-definition (.def) files
586601

587602
[Module-definition (.def) files](https://learn.microsoft.com/en-us/cpp/build/reference/module-definition-dot-def-files)
588603
are added to certain php-src folders where linker needs them when building DLL.

0 commit comments

Comments
 (0)