Skip to content

Commit abae184

Browse files
committed
Merge branch 'PHP-8.4'
2 parents d439c03 + 51d42da commit abae184

File tree

4 files changed

+127
-20
lines changed

4 files changed

+127
-20
lines changed

cmake/cmake/platforms/Windows.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
111111
set(HAVE_MMAP FALSE)
112112
set(HAVE_MPROTECT FALSE)
113113
set(HAVE_MREMAP FALSE)
114-
set(HAVE_MSCOREE_H TRUE)
115114
set(HAVE_NET_IF_H FALSE)
116115
set(HAVE_NETDB_H FALSE)
117116
set(HAVE_NETINET_IN_H FALSE)

cmake/ext/com_dotnet/CMakeLists.txt

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,46 @@ This extension provides the Component Object Model (COM) and .NET support.
88
> [!NOTE]
99
> This extension is available only when the target system is Windows.
1010
11-
## PHP_EXT_COM_DOTNET
11+
## Requirements
12+
13+
To build this extension, Windows SDK needs to be installed, which includes
14+
the COM support.
15+
16+
To enable also the .NET support in this extension (e.g., the `dotnet` PHP
17+
class), the .NET framework needs to be installed, which provides the
18+
`<mscoree.h>` header. This can be done in several ways:
19+
20+
* in Visual Studio by installing the .NET desktop development workload
21+
* in Visual Studio by installing the .NET framework 4.x component only
22+
* Download and install
23+
[.NET framework](https://dotnet.microsoft.com/en-us/download/dotnet-framework)
24+
manually.
25+
26+
The .NET version 5 and later are not supported as they have removed the
27+
`<mscoree.h>` API.
28+
29+
## Configuration options
30+
31+
### PHP_EXT_COM_DOTNET
1232
1333
* Default: `ON`
1434
* Values: `ON|OFF`
1535
16-
Enable the extension.
36+
Enables the extension.
1737
18-
## PHP_EXT_COM_DOTNET_SHARED
38+
### PHP_EXT_COM_DOTNET_SHARED
1939
2040
* Default: `OFF`
2141
* Values: `ON|OFF`
2242
23-
Build extension as shared.
43+
Builds extension as shared.
44+
45+
### PHP_EXT_COM_DOTNET_ENABLE_DOTNET
46+
47+
* Default: `ON`
48+
* Values: `ON|OFF`
49+
50+
Enables the .NET Framework support.
2451
#]=============================================================================]
2552

2653
cmake_minimum_required(VERSION 3.29...4.0)
@@ -54,6 +81,14 @@ cmake_dependent_option(
5481
OFF
5582
)
5683

84+
cmake_dependent_option(
85+
PHP_EXT_COM_DOTNET_ENABLE_DOTNET
86+
"Enable .NET support"
87+
ON
88+
PHP_EXT_COM_DOTNET
89+
OFF
90+
)
91+
5792
if(NOT PHP_EXT_COM_DOTNET)
5893
return()
5994
endif()
@@ -91,7 +126,20 @@ target_compile_definitions(
91126

92127
target_link_libraries(php_ext_com_dotnet PRIVATE oleaut32)
93128

94-
check_include_files(mscoree.h HAVE_MSCOREE_H)
129+
if(PHP_EXT_COM_DOTNET_ENABLE_DOTNET)
130+
check_include_files(mscoree.h PHP_EXT_COM_DOTNET_HAS_MSCOREE_H)
131+
132+
if(NOT PHP_EXT_COM_DOTNET_HAS_MSCOREE_H)
133+
message(
134+
FATAL_ERROR
135+
"<mscoree.h> not found. Please install the .NET Framework or disable the "
136+
".NET support with by setting 'PHP_EXT_COM_DOTNET_ENABLE_DOTNET' to "
137+
"'OFF'."
138+
)
139+
endif()
140+
141+
set(HAVE_MSCOREE_H TRUE)
142+
endif()
95143

96144
set(HAVE_COM_DOTNET TRUE)
97145

docs/cmake/configuration.md

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@ installation of a library, there are two main options to consider:
5858

5959
## 1. CMake presets
6060

61-
Instead of manually passing variables on the command line with
62-
`cmake -DFOO=BAR ...`, configuration options can be simply stored and shared in
63-
a JSON file `CMakePresets.json` at the project root directory.
61+
CMake presets are a convenient way to save and share common build configurations
62+
in the project. Instead of typing long `cmake -DVAR=value` commands every time,
63+
presets can define reusable named setups in JSON files like
64+
[`CMakePresets.json`](/cmake/CMakePresets.json). This makes builds more
65+
consistent across machines and CI systems, and simplifies local development too.
6466

65-
The [CMakePresets.json](/cmake/CMakePresets.json) file incorporates some common
66-
build configuration for development, continuous integration, bug reporting, etc.
67-
Additional configure presets are included from the `cmake/presets` directory.
67+
In this repository, additional configure presets are included from the
68+
[`cmake/presets`](/cmake/presets) directory.
6869

6970
To use the CMake presets:
7071

@@ -79,14 +80,34 @@ cmake --preset default
7980
cmake --build --preset default -j
8081
```
8182

82-
Custom local build configuration can be also stored in a Git-ignored file
83-
`CMakeUserPresets.json` intended to override the defaults in
84-
`CMakePresets.json`.
85-
8683
CMake presets have been available since CMake 3.19, and depending on the
8784
`version` JSON field, the minimum required CMake version may vary based on the
8885
used JSON scheme.
8986

87+
Custom local build configuration can be also stored in a Git-ignored file
88+
`CMakeUserPresets.json` intended to override the defaults in
89+
`CMakePresets.json`. For example, creating the following `CMakeUserPresets.json`
90+
file at the root of the repository, provides customizing the defaults:
91+
92+
```json
93+
{
94+
"version": 4,
95+
"configurePresets": [
96+
{
97+
"name": "my-windows",
98+
"inherits": "windows",
99+
"displayName": "My Windows configuration",
100+
"binaryDir": "${sourceDir}/php-build/default",
101+
"installDir": "c:/tmp",
102+
"cacheVariables": {
103+
"PHP_EXT_FOO": true,
104+
"PHP_...": true,
105+
}
106+
}
107+
]
108+
}
109+
```
110+
90111
## 2. CMake configuration
91112

92113
Some useful overridable configuration options built into CMake itself. All these
@@ -1100,6 +1121,18 @@ A list of Autoconf `configure` command-line configuration options, Windows
11001121
<td>PHP_EXT_COM_DOTNET=OFF</td>
11011122
<td>Windows only</td>
11021123
</tr>
1124+
<tr>
1125+
<td>&emsp;N/A</td>
1126+
<td>N/A</td>
1127+
<td>PHP_EXT_COM_DOTNET_ENABLE_DOTNET=ON</td>
1128+
<td>default; Windows only; enables the .NET Framework support</td>
1129+
</tr>
1130+
<tr>
1131+
<td>&emsp;N/A</td>
1132+
<td>N/A</td>
1133+
<td>PHP_EXT_COM_DOTNET_ENABLE_DOTNET=OFF</td>
1134+
<td>Windows only; disables the .NET Framework support</td>
1135+
</tr>
11031136
<tr>
11041137
<td>--enable-ctype</td>
11051138
<td>--enable-ctype</td>

docs/cmake/ext/com_dotnet.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,43 @@ This extension provides the Component Object Model (COM) and .NET support.
1010
> [!NOTE]
1111
> This extension is available only when the target system is Windows.
1212
13-
## PHP_EXT_COM_DOTNET
13+
## Requirements
14+
15+
To build this extension, Windows SDK needs to be installed, which includes
16+
the COM support.
17+
18+
To enable also the .NET support in this extension (e.g., the `dotnet` PHP
19+
class), the .NET framework needs to be installed, which provides the
20+
`<mscoree.h>` header. This can be done in several ways:
21+
22+
* in Visual Studio by installing the .NET desktop development workload
23+
* in Visual Studio by installing the .NET framework 4.x component only
24+
* Download and install
25+
[.NET framework](https://dotnet.microsoft.com/en-us/download/dotnet-framework)
26+
manually.
27+
28+
The .NET version 5 and later are not supported as they have removed the
29+
`<mscoree.h>` API.
30+
31+
## Configuration options
32+
33+
### PHP_EXT_COM_DOTNET
1434

1535
* Default: `ON`
1636
* Values: `ON|OFF`
1737

18-
Enable the extension.
38+
Enables the extension.
1939

20-
## PHP_EXT_COM_DOTNET_SHARED
40+
### PHP_EXT_COM_DOTNET_SHARED
2141

2242
* Default: `OFF`
2343
* Values: `ON|OFF`
2444

25-
Build extension as shared.
45+
Builds extension as shared.
46+
47+
### PHP_EXT_COM_DOTNET_ENABLE_DOTNET
48+
49+
* Default: `ON`
50+
* Values: `ON|OFF`
51+
52+
Enables the .NET Framework support.

0 commit comments

Comments
 (0)