Skip to content

Commit fa41b2e

Browse files
committed
Update docs and fix CS
1 parent baba7d5 commit fa41b2e

File tree

8 files changed

+62
-22
lines changed

8 files changed

+62
-22
lines changed

cmake/ext/opcache/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
include(CheckSymbolExists)
22
include(CMakeDependentOption)
33
include(FeatureSummary)
4-
include(PHP/CheckCompilerFlag)
54
include(PHP/SearchLibraries)
65

76
option(EXT_OPCACHE "Enable the opcache extension" ON)

docs/cmake-modules/PHP/ConfigureFile.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@ php_configure_file(
2323

2424
* `VARIABLES`
2525

26-
Pairs of variable names and values.
26+
Pairs of variable names and values. Variable values support generator
27+
expressions.
2728

2829
The `$<INSTALL_PREFIX>` generator expression can be used in variable values,
2930
which is replaced with installation prefix either set via the
3031
`CMAKE_INSTALL_PREFIX` variable at the configuration phase, or the `--prefix`
3132
option at the `cmake --install` phase.
32-
33-
The custom PHP specific `$<PHP_EXPAND:path>` generator expression can be used
34-
in variable values. It is automatically replaced to `<install-prefix>/path`
35-
if `path` is relative, or to just `path` if `path` is absolute.

docs/cmake-modules/PHP/Install.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# PHP/Install
2+
3+
See: [Install.cmake](https://github.com/petk/php-build-system/tree/master/cmake/cmake/modules/PHP/Install.cmake)
4+
5+
Set the `CMAKE_INSTALL_*` variables inside the `install(CODE|SCRIPT)`.
6+
7+
This is built on top of the CMake's `GNUInstallDirs` module. At the time of
8+
writing, CMake documentation mentions special cases where, for example, the
9+
`CMAKE_INSTALL_FULL_SYSCONFDIR` variable becomes the `/etc`, when the install
10+
prefix is `/usr`, and similar.
11+
12+
However, some of these special cases aren't taken into account when using the
13+
`install()` commands.
14+
15+
This module exposes the following function:
16+
17+
```cmake
18+
php_install(CODE <code> ...)
19+
```
20+
21+
It acts the same as `install(CODE <code> ...)`, except that also the
22+
`CMAKE_INSTALL_*` variables are available inside the <code> argument, like in
23+
the rest of the CMake code.
24+
25+
```cmake
26+
php_install(CODE "
27+
message(STATUS \"CMAKE_INSTALL_SYSCONFDIR=\${CMAKE_INSTALL_SYSCONFDIR}\")
28+
")
29+
```
30+
31+
See:
32+
33+
* https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
34+
* https://cmake.org/cmake/help/latest/command/install.html

docs/cmake-modules/PHP/PkgConfigGenerator.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,3 @@ template.
4848
which is replaced with installation prefix either set via the
4949
`CMAKE_INSTALL_PREFIX` variable at the configuration phase, or the `--prefix`
5050
option at the `cmake --install` phase.
51-
52-
The custom PHP specific `$<PHP_EXPAND:path>` generator expression can be used
53-
in variable values. It is automatically replaced to `<install-prefix>/path`
54-
if `path` is relative, or to just `path` if `path` is absolute.

docs/cmake-modules/Packages/LibXml2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ See: https://cmake.org/cmake/help/latest/module/FindLibXml2.html
1212

1313
The `FetchContent` CMake module does things differently compared to the
1414
`find_package()` flow:
15-
* By default it uses `QUIET` in its `find_package()` call when calling the
15+
* By default, it uses `QUIET` in its `find_package()` call when calling the
1616
`FetchContent_MakeAvailable()`;
1717
* When using `FeatureSummary`, dependencies must be moved manually to
1818
`PACKAGES_FOUND` from the `PACKAGES_NOT_FOUND` global property;

docs/cmake.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ include(PHP/NewModule)
319319

320320
* [PHP/CheckBuiltin](/docs/cmake-modules/PHP/CheckBuiltin.md)
321321
* [PHP/CheckCompilerFlag](/docs/cmake-modules/PHP/CheckCompilerFlag.md)
322+
* [PHP/Install](/docs/cmake-modules/PHP/Install.md)
322323
* [PHP/SearchLibraries](/docs/cmake-modules/PHP/SearchLibraries.md)
323324

324325
## 9. Custom CMake properties

docs/dependencies.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ dependencies.
131131
Quick usage:
132132

133133
```sh
134-
# List of all known package names on the system:
135-
pkgconf --list-package-names
134+
# List of all known packages on the system:
135+
pkgconf --list-all
136136

137137
# Print required linker flags to stdout for given package name:
138138
pkgconf --libs libcrypt
@@ -150,8 +150,8 @@ pkgconf --help
150150
PKG_CONFIG_PATH=/path/to/pkgconfig pkgconf --modversion libcrypt
151151
```
152152

153-
The `pkgconf` ships with M4 macro file `pkg.m4` for Autotools-based build
154-
systems and provides several macros, such as `PKG_CHECK_MODULES`.
153+
The `pkgconf` ships with Autoconf M4 macro file `pkg.m4` for Autotools-based
154+
build systems and provides several macros, such as `PKG_CHECK_MODULES`.
155155

156156
`PKG_CHECK_MODULES` creates so-called precious variables `*_LIBS` and `*_CFLAGS`
157157
for using dependency in the build system. See `./configure --help` for all the

docs/php-installation.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Common practice is to also add program prefix and suffix (for example, to have
167167
EXTENSION_DIR=/path/to/php/extensions \
168168
--with-layout=GNU \
169169
--localstatedir=/var \
170+
--sysconfdir=/etc \
170171
--program-suffix=84 \
171172
# ...
172173
```
@@ -177,7 +178,7 @@ PHP Autotools directory structure with GNU layout:
177178

178179
```sh
179180
📂 <INSTALL_ROOT> # 📂
180-
└─📂 ${prefix} # └─📂 /usr/local/include
181+
└─📂 ${prefix} # └─📂 /usr/local
181182
├─📂 ${bindir} # ├─📂 bin
182183
└─📂 ${sysconfdir} # └─📂 etc
183184
├─📂 php-fpm.d # ├─📂 php-fpm.d
@@ -201,7 +202,7 @@ PHP Autotools directory structure with GNU layout:
201202
└─📂 man8 # └─📂 man8
202203
├─📂 pear # └─📂 pear
203204
└─📂 php # └─📂 php
204-
└─📂 fpm # └─📂 fpm
205+
└─📂 fpm # └─📂 fpm
205206
└─📂 ${localstatedir} # └─📂 var
206207
└─📂 log # └─📂 log
207208
└─📂 ${runstatedir} # └─📂 var/run
@@ -244,7 +245,7 @@ DESTDIR=/stage cmake --install . --prefix /usr
244245
245246
To adjust the installation locations, the
246247
[GNUInstallDirs](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html)
247-
module is used to set additional `CMAKE_INSTALL_*` variables.
248+
module is used to set the `CMAKE_INSTALL_*` variables.
248249

249250
* `CMAKE_INSTALL_BINDIR` - name of the bin directory
250251
* `CMAKE_INSTALL_DATADIR` - name of the etc directory
@@ -310,9 +311,21 @@ PHP installation directory structure when using CMake:
310311
> [!NOTE]
311312
> The `DATAROOTDIR` and `DATADIR` are treated separately to be able to adjust
312313
> only the `DATADIR` with project specific files, while leaving the
313-
> `DATAROOTDIR` intact for man or other files. See also
314+
> `DATAROOTDIR` intact for man or other files. See
314315
> [GNU](https://www.gnu.org/prep/standards/html_node/Directory-Variables.html)
315-
> explanation for more info.
316+
> for more info.
317+
318+
> [!NOTE]
319+
> The CMake `GNUInstallDirs` module also adjusts GNU-related variables according
320+
> to various standards, so there are some special cases.
321+
>
322+
> When the `CMAKE_INSTALL_PREFIX` is set to `/usr`, the `SYSCONFDIR`,
323+
> `LOCALSTATEDIR`, and `RUNSTATEDIR` become `/etc`, `/var`, and
324+
> `/var/run` instead of `/usr/etc`, and `/usr/var`, and `/usr/var/run`. Similar
325+
> adjustments are done when install prefix is `/` or `/opt/...`. See
326+
> [GNUInstallDirs](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html#special-cases)
327+
> for more info. The [PHP/Install](/docs/cmake-modules/PHP/Install.md) bypasses
328+
> some of these adjustmens inside the `install()` command for convenience.
316329
317330
Instead of setting the installation prefix at the configuration phase using
318331
`CMAKE_INSTALL_PREFIX` variable or `--install-prefix` option, there is
@@ -331,13 +344,13 @@ root directory:
331344
"inherits": "all-enabled",
332345
"displayName": "Acme PHP configuration",
333346
"description": "Customized PHP build",
334-
"installDir": "/install/prefix",
347+
"installDir": "/usr",
335348
"cacheVariables": {
336349
"CMAKE_INSTALL_BINDIR": "home/user/.local/bin",
337350
"PHP_BUILD_SYSTEM": "Acme Linux",
338351
"PHP_BUILD_PROVIDER": "Acme",
339352
"PHP_BUILD_COMPILER": "GCC",
340-
"PHP_BUILD_ARCH": "x86",
353+
"PHP_BUILD_ARCH": "x86_64",
341354
"PHP_VERSION_LABEL": "-acme",
342355
"PHP_EXTENSION_DIR": "lib/php83/extensions"
343356
}

0 commit comments

Comments
 (0)