Skip to content

Commit 98d58d5

Browse files
committed
Update docs
1 parent 7143b6c commit 98d58d5

File tree

3 files changed

+52
-39
lines changed

3 files changed

+52
-39
lines changed

docs/cmake-intro.md

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ understanding of its fundamentals.
3737

3838
## 1. Command-line usage
3939

40-
[CMake](https://cmake.org/) is an open-source cross-platform build system
41-
generator created by Kitware and contributors. It is invoked on command line
42-
using `cmake` command. When working with CMake, there are two primary phases:
43-
the configuration and generation phase, followed by the build phase.
40+
[CMake](https://cmake.org/) is an open-source, cross-platform build system
41+
generator created by Kitware and contributors. It is invoked from the command
42+
line using the `cmake` command. When working with CMake, there are two primary
43+
phases: the configuration and generation phase, followed by the build phase.
4444

4545
### 1.1. Configuration and generation phase
4646

@@ -71,7 +71,7 @@ cmake --build build-directory --parallel
7171
> source directory (when source and build directories are the same):
7272
>
7373
> ```sh
74-
> cmake .
74+
> cmake . # Same as: cmake -S . -B .
7575
> cmake --build . --parallel
7676
> ```
7777
>
@@ -81,10 +81,8 @@ cmake --build build-directory --parallel
8181
> within the source directory:
8282
>
8383
> ```sh
84-
> mkdir build-directory
85-
> cd build-directory
86-
> cmake ..
87-
> cmake --build . --parallel
84+
> cmake -B build-directory
85+
> cmake --build build-directory --parallel
8886
> ```
8987
9088
## 2. CMakeLists.txt
@@ -282,18 +280,32 @@ project. There are primarily two types: libraries and executables.
282280
add_executable(php php.c php_2.c ...)
283281
284282
# Create a library target
285-
add_library(extension OBJECT|MODULE|SHARED|STATIC extension.c src.c ...)
283+
add_library(extension extension.c src.c ...)
284+
```
285+
286+
Library can also have a type specified. For example, a shared library:
287+
288+
```cmake
289+
add_library(extension SHARED extension.c src.c)
286290
```
287291

288-
The keywords `OBJECT`, `MODULE`, `SHARED`, and `STATIC` specify how the library
289-
is built. `OBJECT` libraries will compile source files to binary object files
290-
without the linking step. These objects can be then referenced in other CMake
291-
targets. `SHARED` libraries can be linked dynamically or dynamically loaded at
292-
program runtime with `dlopen()` on *nix systems, or `LoadLibrary()` on Windows.
293-
`MODULE` library is a special CMake concept that prevents such targets to be
294-
linked dynamically with `target_link_libraries()` and are intended to be only
295-
dynamically loaded during runtime. `STATIC` library is an archive of built
296-
object files that can be linked to other targets.
292+
> [!IMPORTANT]
293+
> There are several library types:
294+
>
295+
> ```cmake
296+
> add_library(<name> [OBJECT|MODULE|SHARED|STATIC] <sources>...)
297+
> ```
298+
>
299+
> The keywords `OBJECT`, `MODULE`, `SHARED`, and `STATIC` specify how the
300+
> library is built. `OBJECT` libraries will compile source files to binary
301+
> object files without the linking step. These objects can be then referenced in
302+
> other CMake targets. `SHARED` libraries can be linked dynamically or
303+
> dynamically loaded at program runtime with `dlopen()` on *nix systems, or
304+
> `LoadLibrary()` on Windows. `MODULE` library is a special CMake concept that
305+
> prevents such targets to be linked dynamically with `target_link_libraries()`
306+
> and are intended to be only dynamically loaded during runtime. `STATIC`
307+
> library is an archive of built object files that can be linked to other
308+
> targets.
297309
298310
The concepts of executable and library targets can be illustrated through
299311
examples of using a compiler like `gcc`.
@@ -323,9 +335,9 @@ gcc -c -o src.o src.c
323335

324336
### 4.3. SHARED library
325337

326-
CMake automatically adds sensible linker flags when building SHARED library. For
327-
example, `-shared`, `-Wl,-soname,extension.so`, position-independent code flag
328-
`-fPIC`, and similar.
338+
CMake automatically adds sensible linker flags when building `SHARED` library.
339+
For example, `-shared`, `-Wl,-soname,extension.so`, position-independent code
340+
flag `-fPIC`, and similar.
329341

330342
```sh
331343
# Compile each source file to a binary object file with the -fPIC
@@ -337,10 +349,10 @@ gcc -fPIC -shared -Wl,-soname,extension.so -o extension.so extension.o src.o
337349

338350
### 4.4. MODULE library
339351

340-
The MODULE library, on the other hand, is similar to the SHARED. However, CMake
341-
uses slightly different flags and treats it differently in CMake code. A MODULE
342-
library cannot be linked with `target_link_libraries()` in CMake, and certain
343-
handling inside CMake differs.
352+
The `MODULE` library, on the other hand, is similar to the `SHARED`. However,
353+
CMake uses slightly different flags and treats it differently in CMake code. A
354+
`MODULE` library cannot be linked with `target_link_libraries()` in CMake, and
355+
certain handling inside CMake differs.
344356

345357
```sh
346358
# Compile each source file to a binary object file with the -fPIC
@@ -350,8 +362,8 @@ gcc -fPIC -c -o src.o src.c
350362
gcc -fPIC -shared -o extension.so extension.o src.o
351363
```
352364

353-
Both MODULE and SHARED libraries can be loaded with `dlopen`-alike functionality
354-
during program runtime. For example:
365+
Both `MODULE` and `SHARED` libraries can be loaded with `dlopen`-alike
366+
functionality during program runtime. For example:
355367

356368
```c
357369
/* main.c */
@@ -370,7 +382,7 @@ int main(void)
370382
371383
### 4.5. STATIC library
372384
373-
STATIC libraries are intended to be linked statically to other libraries or
385+
`STATIC` libraries are intended to be linked statically to other libraries or
374386
executables where they become part of the final binary.
375387
376388
```sh

docs/cmake-modules/PHP/Install.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ See: [Install.cmake](https://github.com/petk/php-build-system/tree/master/cmake/
44

55
Set the `CMAKE_INSTALL_*` variables inside the `install(CODE|SCRIPT)`.
66

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.
7+
This is built on top of the CMake's
8+
[`GNUInstallDirs`](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html)
9+
module and the
10+
[`install()`](https://cmake.org/cmake/help/latest/command/install.html) command.
11+
At the time of writing, CMake documentation mentions special cases where, for
12+
example, the `CMAKE_INSTALL_FULL_SYSCONFDIR` variable becomes the `/etc`, when
13+
the install prefix is `/usr`, and similar.
1114

1215
However, some of these special cases aren't taken into account when using the
13-
`install()` commands.
16+
`install()` commands. See: https://gitlab.kitware.com/cmake/cmake/-/issues/25852
1417

1518
This module exposes the following function:
1619

@@ -27,8 +30,3 @@ php_install(CODE "
2730
message(STATUS \"CMAKE_INSTALL_SYSCONFDIR=\${CMAKE_INSTALL_SYSCONFDIR}\")
2831
")
2932
```
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/differences.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,6 @@ build system:
110110

111111
* Build with Clang on 32-bit systems.
112112
See: https://github.com/php/php-src/issues/14467
113+
114+
* Zend/zend_vm_gen.php deprecation warnings on 32-bit systems.
115+
See: https://github.com/php/php-src/issues/15899

0 commit comments

Comments
 (0)