Skip to content

Commit 48d77fe

Browse files
committed
Fix TSRM linking
This now properly links the TSRM into Zend Engine. Instead of adding TSRM subdirectory in the project root, it adds it as part of the Zend Engine configuration. TSRM objects and compile options are then transitively passed to further targets as needed.
1 parent 17614bf commit 48d77fe

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

cmake/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ message(STATUS "Configuring PHP")
3636
message(STATUS "---------------\n")
3737

3838
add_subdirectory(pear)
39-
add_subdirectory(TSRM)
4039
add_subdirectory(win32)
4140
add_subdirectory(main)
4241
add_subdirectory(scripts)

cmake/TSRM/CMakeLists.txt

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
add_library(php_tsrm OBJECT)
2-
add_library(PHP::TSRM ALIAS php_tsrm)
1+
#[=============================================================================[
2+
TSRM (Thread Safe Resource Manager) is a separate directory in php-src as it was
3+
once a standalone project. Ideally, it should be integrated into Zend Engine.
4+
5+
The TSRM::TSRM target is used to transitively pass the TSRM object(s) and
6+
compile options to Zend Engine, which propagates it further as needed.
7+
#]=============================================================================]
8+
9+
add_library(tsrm_object OBJECT)
10+
add_library(tsrm INTERFACE)
11+
add_library(TSRM::TSRM ALIAS tsrm)
12+
13+
target_link_libraries(
14+
tsrm
15+
INTERFACE
16+
tsrm_object
17+
$<TARGET_OBJECTS:tsrm_object>
18+
)
319

420
target_sources(
5-
php_tsrm
21+
tsrm_object
622
PRIVATE
723
$<$<PLATFORM_ID:Windows>:tsrm_win32.c>
824
TSRM.c
@@ -13,23 +29,25 @@ target_sources(
1329
TSRM.h
1430
)
1531

16-
target_link_libraries(php_tsrm PRIVATE PHP::configuration)
32+
target_link_libraries(tsrm_object PRIVATE PHP::configuration)
1733

18-
target_include_directories(php_tsrm INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
34+
target_include_directories(
35+
tsrm_object
36+
INTERFACE
37+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
38+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PHP_INCLUDE_PREFIX}/TSRM>
39+
)
1940

2041
target_compile_definitions(
21-
php_tsrm
42+
tsrm_object
2243
PRIVATE
2344
ZEND_ENABLE_STATIC_TSRMLS_CACHE=1
45+
PUBLIC
2446
$<$<PLATFORM_ID:Windows>:TSRM_EXPORTS>
25-
INTERFACE
26-
# Pass transitively only to Zend::Zend library on Windows.
27-
$<$<AND:$<STREQUAL:$<TARGET_PROPERTY:NAME>,zend>,$<PLATFORM_ID:Windows>>:TSRM_EXPORTS>
2847
)
2948

3049
install(
31-
TARGETS php_tsrm
32-
ARCHIVE EXCLUDE_FROM_ALL
50+
TARGETS tsrm_object
3351
FILE_SET HEADERS
3452
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PHP_INCLUDE_PREFIX}/TSRM
3553
)

cmake/Zend/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,15 @@ target_sources(
304304
$<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_CURRENT_BINARY_DIR}/zend_config.h>
305305
)
306306

307+
# Add TSRM.
308+
add_subdirectory(../TSRM ../TSRM)
309+
307310
target_link_libraries(
308311
zend
309312
PRIVATE
310313
PHP::configuration
311314
PUBLIC
312-
PHP::TSRM
313-
$<TARGET_OBJECTS:PHP::TSRM>
315+
TSRM::TSRM
314316
)
315317

316318
target_include_directories(
@@ -324,6 +326,7 @@ target_compile_definitions(
324326
zend
325327
PRIVATE
326328
ZEND_ENABLE_STATIC_TSRMLS_CACHE=1
329+
PUBLIC
327330
$<$<PLATFORM_ID:Windows>:LIBZEND_EXPORTS>
328331
)
329332

0 commit comments

Comments
 (0)