@@ -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
2653cmake_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+
5792if (NOT PHP_EXT_COM_DOTNET)
5893 return ()
5994endif ()
@@ -91,7 +126,20 @@ target_compile_definitions(
91126
92127target_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
96144set (HAVE_COM_DOTNET TRUE )
97145
0 commit comments