Skip to content

Commit a6aca68

Browse files
committed
Add PHP_CORE target property
1 parent 3bac67b commit a6aca68

File tree

11 files changed

+62
-58
lines changed

11 files changed

+62
-58
lines changed

cmake/CMakeLists.txt

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,23 @@ target_include_directories(
5757
)
5858

5959
# Create PHP core library that ties objects and configuration together for PHP
60-
# SAPIs and shared extensions. On Windows there is also a standalone shared DLL
61-
# created for shared extensions which need it linked to have symbols available.
60+
# SAPIs and shared extensions. On Windows (win32 directory) there is also a
61+
# shared DLL created for shared extensions to have symbols available.
6262
add_library(php_core INTERFACE)
6363
add_library(PHP::core ALIAS php_core)
6464

6565
add_library(php_core_objects INTERFACE)
6666
add_library(PHP::core::objects ALIAS php_core_objects)
67+
target_link_libraries(
68+
php_core
69+
INTERFACE
70+
PHP::config
71+
$<$<NOT:$<PLATFORM_ID:Windows>>:PHP::core::objects>
72+
)
6773

68-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
69-
add_library(php_core_library SHARED)
70-
add_library(PHP::core::library ALIAS php_core_library)
71-
target_link_libraries(
72-
php_core_library
73-
PRIVATE
74-
PHP::config
75-
PHP::core::objects
76-
)
77-
target_compile_options(
78-
php_core_library
79-
PRIVATE
80-
/nodefaultlib:libcmt
81-
/d2:-AllowCompatibleILVersions
82-
)
83-
84-
target_link_libraries(php_core INTERFACE PHP::config PHP::core::library)
85-
else()
86-
target_link_libraries(php_core INTERFACE PHP::config PHP::core::objects)
87-
endif()
74+
target_compile_definitions(
75+
php_config INTERFACE
76+
)
8877

8978
################################################################################
9079
# Configure project.
@@ -102,6 +91,14 @@ define_property(
10291
BRIEF_DOCS "Whether the PHP SAPI is FastCGI-based"
10392
)
10493

94+
define_property(
95+
TARGET
96+
PROPERTY PHP_CORE
97+
BRIEF_DOCS
98+
"Whether the target should get compile properties dedicated to PHP core "
99+
"objects (e.g, *_EXPORTS compile definitions, etc.)."
100+
)
101+
105102
# Check whether IPO/LTO can be enabled.
106103
include(PHP/Optimization)
107104

@@ -126,6 +123,7 @@ include(cmake/ConfigureChecks.cmake)
126123
# Check compilation options.
127124
include(cmake/Flags.cmake)
128125

126+
add_subdirectory(win32)
129127
add_subdirectory(sapi)
130128
add_subdirectory(ext)
131129
add_subdirectory(Zend)
@@ -137,7 +135,6 @@ message(STATUS "===============")
137135
message(STATUS "")
138136

139137
add_subdirectory(pear)
140-
add_subdirectory(win32)
141138
add_subdirectory(main)
142139
add_subdirectory(scripts)
143140

cmake/Zend/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ set_target_properties(
327327
VERSION ${Zend_VERSION}
328328
ZEND_EXTENSION_API_NO ${Zend_VERSION_EXTENSION_API_NO}
329329
ZEND_MODULE_API_NO ${Zend_VERSION_MODULE_API_NO}
330+
PHP_CORE TRUE
330331
)
331332

332333
################################################################################

cmake/cmake/ConfigureChecks.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ if(PHP_DTRACE)
852852
INCLUDES
853853
$<TARGET_PROPERTY:PHP::config,INTERFACE_INCLUDE_DIRECTORIES>
854854
)
855+
set_target_properties(php_dtrace PROPERTIES PHP_CORE TRUE)
855856

856857
target_link_libraries(php_config INTERFACE DTrace::DTrace)
857858
target_link_libraries(php_core_objects INTERFACE php_dtrace)

cmake/ext/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ foreach(extension IN LISTS extensions)
8181
PRIVATE $<$<PLATFORM_ID:Windows>:$<TARGET_NAME_IF_EXISTS:PHP::core>>
8282
)
8383
else()
84+
set_target_properties(php_ext_${extension} PROPERTIES PHP_CORE)
85+
8486
target_compile_definitions(
8587
php_config
8688
INTERFACE

cmake/ext/iconv/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,8 @@ target_sources(
7272
)
7373

7474
get_target_property(type php_ext_iconv TYPE)
75-
if(
76-
CMAKE_SYSTEM_NAME STREQUAL "Windows"
77-
AND TARGET php_core_library
78-
AND NOT type MATCHES "^(MODULE|SHARED)_LIBRARY$"
79-
)
80-
target_sources(php_core_library PRIVATE php_iconv.def)
75+
if(TARGET php_windows AND type MATCHES "^(OBJECT|STATIC)_LIBRARY$")
76+
target_sources(php_windows PRIVATE php_iconv.def)
8177
endif()
8278

8379
target_compile_definitions(

cmake/ext/libxml/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ target_sources(
5353
php_libxml.h
5454
)
5555

56-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND TARGET php_core_library)
57-
target_sources(php_core_library PRIVATE php_libxml2.def)
56+
if(TARGET php_windows)
57+
target_sources(php_windows PRIVATE php_libxml2.def)
5858
endif()
5959

6060
target_compile_definitions(

cmake/ext/pcre/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ else()
203203
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
204204
set(PCRE2_STATIC TRUE)
205205

206-
if(TARGET php_core_library)
207-
target_sources(php_core_library PRIVATE php_pcre.def)
206+
if(TARGET php_windows)
207+
target_sources(php_windows PRIVATE php_pcre.def)
208208
endif()
209209
endif()
210210

cmake/ext/tidy/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,8 @@ target_sources(
6868
)
6969

7070
get_target_property(type php_ext_tidy TYPE)
71-
if(
72-
CMAKE_SYSTEM_NAME STREQUAL "Windows"
73-
AND TARGET php_core_library
74-
AND NOT type MATCHES "^(MODULE|SHARED)_LIBRARY$"
75-
)
76-
target_sources(php_core_library PRIVATE php_tidy.def)
71+
if(TARGET php_windows AND type MATCHES "^(OBJECT|STATIC)_LIBRARY$")
72+
target_sources(php_windows PRIVATE php_tidy.def)
7773
endif()
7874

7975
# Add -Wno-ignored-qualifiers as this is an issue upstream. Fixed in tidy-html5

cmake/ext/zlib/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,8 @@ target_sources(
6767
)
6868

6969
get_target_property(type php_ext_zlib TYPE)
70-
if(
71-
CMAKE_SYSTEM_NAME STREQUAL "Windows"
72-
AND TARGET php_core_library
73-
AND NOT type MATCHES "^(MODULE|SHARED)_LIBRARY$"
74-
)
75-
target_sources(php_core_library PRIVATE php_zlib.def)
70+
if(TARGET php_windows AND type MATCHES "^(OBJECT|STATIC)_LIBRARY$")
71+
target_sources(php_windows PRIVATE php_zlib.def)
7672
endif()
7773

7874
target_compile_definitions(php_ext_zlib PRIVATE ZEND_ENABLE_STATIC_TSRMLS_CACHE)

cmake/main/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ target_sources(
104104
$<$<NOT:$<PLATFORM_ID:Windows>>:${PHP_BINARY_DIR}/$<CONFIG>/main/php_config.h>
105105
)
106106

107+
set_target_properties(php_main PROPERTIES PHP_CORE TRUE)
108+
107109
################################################################################
108110
# Add usage requirements to PHP interface targets.
109111
################################################################################
@@ -144,6 +146,11 @@ target_sources(
144146

145147
add_library(php_main_internal_functions OBJECT internal_functions.c)
146148
add_library(php_main_internal_functions_cli OBJECT internal_functions_cli.c)
149+
set_target_properties(
150+
php_main_internal_functions
151+
php_main_internal_functions_cli
152+
PROPERTIES PHP_CORE TRUE
153+
)
147154

148155
target_sources(
149156
php_core_objects

0 commit comments

Comments
 (0)