Skip to content

Commit c8c4773

Browse files
committed
Add PHP_CORE target property
1 parent c997f97 commit c8c4773

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
@@ -893,6 +893,7 @@ if(PHP_DTRACE)
893893
INCLUDES
894894
$<TARGET_PROPERTY:PHP::config,INTERFACE_INCLUDE_DIRECTORIES>
895895
)
896+
set_target_properties(php_dtrace PROPERTIES PHP_CORE TRUE)
896897

897898
target_link_libraries(php_config INTERFACE DTrace::DTrace)
898899
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

cmake/win32/CMakeLists.txt

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include(FeatureSummary)
99
# Add library.
1010
################################################################################
1111

12-
add_library(php_windows OBJECT)
12+
add_library(php_windows SHARED)
1313
add_library(PHP::windows ALIAS php_windows)
1414

1515
target_sources(
@@ -69,7 +69,22 @@ target_sources(
6969
)
7070

7171
target_include_directories(php_windows PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
72-
target_link_libraries(php_windows PRIVATE PHP::config)
72+
73+
target_link_libraries(
74+
php_windows
75+
PRIVATE
76+
PHP::config
77+
PHP::core::objects
78+
)
79+
80+
set_target_properties(php_windows PROPERTIES OUTPUT_NAME php)
81+
82+
target_compile_options(
83+
php_windows
84+
PRIVATE
85+
/nodefaultlib:libcmt
86+
/d2:-AllowCompatibleILVersions
87+
)
7388

7489
################################################################################
7590
# Add usage requirements to PHP interface targets.
@@ -100,7 +115,7 @@ target_compile_definitions(
100115
_MBCS
101116
_USE_MATH_DEFINES
102117

103-
$<$<AND:$<PLATFORM_ID:Windows>,$<IN_LIST:$<TARGET_PROPERTY:TYPE>,OBJECT_LIBRARY;STATIC_LIBRARY>>:PHP_EXPORTS>
118+
$<$<BOOL:$<TARGET_PROPERTY:PHP_CORE>>:PHP_EXPORTS>
104119

105120
# The time_t defaults to 64-bit. Force 32-bit time_t on 32-bit architecture.
106121
# This was historically added to PHP as Visual Studio 2005 set 64-bit time_t
@@ -109,9 +124,9 @@ target_compile_definitions(
109124
# should be removed at some point.
110125
$<$<EQUAL:${CMAKE_SIZEOF_VOID_P},4>:_USE_32BIT_TIME_T=1>
111126

112-
$<$<AND:$<PLATFORM_ID:Windows>,$<IN_LIST:$<TARGET_PROPERTY:TYPE>,OBJECT_LIBRARY;STATIC_LIBRARY>>:WINVER=0x0602>
127+
$<$<BOOL:$<TARGET_PROPERTY:PHP_CORE>>:_USRDLL>
113128

114-
$<$<AND:$<PLATFORM_ID:Windows>,$<IN_LIST:$<TARGET_PROPERTY:TYPE>,OBJECT_LIBRARY;STATIC_LIBRARY>>:_USRDLL>
129+
$<$<BOOL:$<TARGET_PROPERTY:PHP_CORE>>:WINVER=0x0602>
115130
)
116131

117132
target_compile_options(
@@ -129,12 +144,6 @@ target_compile_options(
129144
$<$<COMPILE_LANGUAGE:C,CXX>:/FD>
130145
)
131146

132-
target_link_options(
133-
php_config
134-
INTERFACE
135-
$<$<AND:$<PLATFORM_ID:Windows>,$<IN_LIST:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY;SHARED_LIBRARY>,$<LINK_LANGUAGE:C,CXX>>:/dll>
136-
)
137-
138147
target_link_libraries(
139148
php_config
140149
INTERFACE
@@ -149,8 +158,7 @@ target_link_libraries(
149158
ws2_32
150159
)
151160

152-
target_link_libraries(php_core_objects INTERFACE PHP::windows)
153-
target_sources(php_core_objects INTERFACE $<TARGET_OBJECTS:PHP::windows>)
161+
target_link_libraries(php_core INTERFACE PHP::windows)
154162

155163
################################################################################
156164
# Generate wsyslog.h file with message compiler (mc).

0 commit comments

Comments
 (0)