@@ -61,7 +61,13 @@ else()
61
61
message (CHECK_FAIL "no" )
62
62
endif ()
63
63
64
- block (PROPAGATE zend_fibers_asm_file zend_fibers_asm_sources )
64
+ block ()
65
+ set (cpu "" )
66
+ set (asmFile "" )
67
+ set (prefix "" )
68
+ set (compileOptions "" )
69
+ set (compileDefinitions "" )
70
+
65
71
# Determine files based on the architecture and platform.
66
72
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64)$" )
67
73
set (prefix "x86_64_sysv" )
@@ -87,121 +93,108 @@ block(PROPAGATE zend_fibers_asm_file zend_fibers_asm_sources)
87
93
endif ()
88
94
89
95
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
90
- set (zend_fibers_asm_file "combined_sysv_macho_gas.S" )
96
+ set (asmFile "combined_sysv_macho_gas.S" )
91
97
elseif (CMAKE_SYSTEM_NAME STREQUAL "AIX" )
92
98
# AIX uses a different calling convention (shared with non-_CALL_ELF Linux).
93
99
# The AIX assembler isn't GNU, but the file is compatible.
94
- set (zend_fibers_asm_file "${prefix} _xcoff_gas.S" )
100
+ set (asmFile "${prefix} _xcoff_gas.S" )
95
101
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" )
96
102
if (NOT cpu STREQUAL "i386" )
97
- set (zend_fibers_asm_file "${prefix} _elf_gas.S" )
103
+ set (asmFile "${prefix} _elf_gas.S" )
98
104
endif ()
99
105
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows" )
100
106
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64)$" )
101
- set (zend_fibers_asm_file "x86_64_ms_pe_masm.asm" )
107
+ set (asmFile "x86_64_ms_pe_masm.asm" )
102
108
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86|i.?86.*|pentium)$" )
103
- set (zend_fibers_asm_file "i386_ms_pe_masm.asm" )
109
+ set (asmFile "i386_ms_pe_masm.asm" )
104
110
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64)$" )
105
- set (zend_fibers_asm_file "arm64_aapcs_pe_armasm.asm" )
111
+ set (asmFile "arm64_aapcs_pe_armasm.asm" )
106
112
107
113
set (
108
- compile_options
114
+ compileOptions
109
115
/nologo
110
116
# TODO: Recheck; "-machine" is a linker option.
111
117
-machine ARM64
112
118
)
113
119
endif ()
114
120
115
- if (
116
- zend_fibers_asm_file
117
- AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64)$"
118
- )
119
- set (
120
- compile_options
121
- /nologo
122
- )
121
+ if (asmFile AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|ARM64)$" )
122
+ set (compileOptions /nologo )
123
123
124
- set (
125
- compile_definitions
126
- "BOOST_CONTEXT_EXPORT=EXPORT"
127
- )
124
+ set (compileDefinitions "BOOST_CONTEXT_EXPORT=EXPORT" )
128
125
endif ()
129
126
elseif (prefix )
130
- set (zend_fibers_asm_file "${prefix} _elf_gas.S" )
127
+ set (asmFile "${prefix} _elf_gas.S" )
131
128
endif ()
132
129
133
- if (zend_fibers_asm_file )
130
+ if (asmFile )
134
131
set (
135
- zend_fibers_asm_sources
136
- ${CMAKE_CURRENT_SOURCE_DIR} /asm/jump_${zend_fibers_asm_file }
137
- ${CMAKE_CURRENT_SOURCE_DIR} /asm/make_${zend_fibers_asm_file }
132
+ asmSources
133
+ ${CMAKE_CURRENT_SOURCE_DIR} /asm/jump_${asmFile }
134
+ ${CMAKE_CURRENT_SOURCE_DIR} /asm/make_${asmFile }
138
135
)
139
136
140
- if (compile_options )
137
+ if (compileOptions )
141
138
set_source_files_properties (
142
- ${zend_fibers_asm_sources }
139
+ ${asmSources }
143
140
PROPERTIES
144
- COMPILE_OPTIONS ${compile_options }
141
+ COMPILE_OPTIONS ${compileOptions }
145
142
)
146
143
endif ()
147
144
148
- if (compile_definitions )
145
+ if (compileDefinitions )
149
146
set_source_files_properties (
150
- ${zend_fibers_asm_sources }
147
+ ${asmSources }
151
148
PROPERTIES
152
- COMPILE_DEFINITIONS ${compile_definitions }
149
+ COMPILE_DEFINITIONS ${compileDefinitions }
153
150
)
154
151
endif ()
155
152
endif ()
156
- endblock ()
157
153
158
- message (CHECK_START "Checking for fibers switching context support" )
154
+ message (CHECK_START "Checking for fibers switching context support" )
159
155
160
- if (ZEND_FIBER_ASM AND zend_fibers_asm_file )
161
- message (CHECK_PASS "yes, Zend/asm/*.${zend_fibers_asm_file } " )
156
+ if (ZEND_FIBER_ASM AND asmFile )
157
+ message (CHECK_PASS "yes, Zend/asm/*.${asmFile } " )
162
158
163
- target_sources (
164
- zend_fibers
165
- INTERFACE
166
- ${zend_fibers_asm_sources}
167
- )
159
+ target_sources (zend_fibers INTERFACE ${asmSources} )
168
160
169
- # Use compile definitions because ASM files can't see macro definitions from
170
- # the PHP configuration header (php_config.h/config.w32.h).
171
- target_compile_definitions (
172
- zend_fibers
173
- INTERFACE
174
- $< IF:$< BOOL:${SHADOW_STACK_SYSCALL} > ,SHADOW_STACK_SYSCALL=1,SHADOW_STACK_SYSCALL=0>
175
- )
176
- else ()
177
- cmake_push_check_state (RESET )
178
- # To use ucontext.h on macOS, the _XOPEN_SOURCE needs to be defined to any
179
- # value. POSIX marked ucontext functions as obsolete and on macOS the
180
- # ucontext.h functions are deprecated. At the time of writing no solution is
181
- # on the horizon yet. Here, the _XOPEN_SOURCE is defined to empty value to
182
- # enable proper X/Open symbols yet still to not enable some of the Single
183
- # Unix specification definitions (values 500 or greater where the PHP
184
- # thread-safe build would fail).
185
- if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
186
- set (CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE )
187
-
188
- set_property (
189
- SOURCE ${CMAKE_CURRENT_SOURCE_DIR} /zend_fibers.c
190
- APPEND
191
- PROPERTY
192
- COMPILE_DEFINITIONS _XOPEN_SOURCE
161
+ # Use compile definitions because ASM files can't see macro definitions from
162
+ # the PHP configuration header (php_config.h/config.w32.h).
163
+ target_compile_definitions (
164
+ zend_fibers
165
+ INTERFACE
166
+ $< IF:$< BOOL:${SHADOW_STACK_SYSCALL} > ,SHADOW_STACK_SYSCALL=1,SHADOW_STACK_SYSCALL=0>
167
+ )
168
+ else ()
169
+ cmake_push_check_state (RESET )
170
+ # To use ucontext.h on macOS, the _XOPEN_SOURCE needs to be defined to any
171
+ # value. POSIX marked ucontext functions as obsolete and on macOS the
172
+ # ucontext.h functions are deprecated. At the time of writing no solution is
173
+ # on the horizon yet. Here, the _XOPEN_SOURCE is defined to empty value to
174
+ # enable proper X/Open symbols yet still to not enable some of the Single
175
+ # Unix specification definitions (values 500 or greater where the PHP
176
+ # thread-safe build would fail).
177
+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
178
+ set (CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE )
179
+
180
+ set_property (
181
+ SOURCE ${CMAKE_CURRENT_SOURCE_DIR} /zend_fibers.c
182
+ APPEND
183
+ PROPERTY
184
+ COMPILE_DEFINITIONS _XOPEN_SOURCE
185
+ )
186
+ endif ()
187
+
188
+ check_include_file (ucontext.h ZEND_FIBER_UCONTEXT )
189
+ cmake_pop_check_state ()
190
+
191
+ if (NOT ZEND_FIBER_UCONTEXT )
192
+ message (CHECK_FAIL "no" )
193
+ message (
194
+ FATAL_ERROR
195
+ "Fibers are not available on this platform, ucontext.h not found"
193
196
)
194
197
endif ()
195
-
196
- check_include_file (ucontext.h ZEND_FIBER_UCONTEXT )
197
- cmake_pop_check_state ()
198
-
199
- if (NOT ZEND_FIBER_UCONTEXT )
200
- message (CHECK_FAIL "no" )
201
- message (
202
- FATAL_ERROR
203
- "Fibers are not available on this platform, ucontext.h not found"
204
- )
198
+ message (CHECK_PASS "yes, ucontext" )
205
199
endif ()
206
- message (CHECK_PASS "yes, ucontext" )
207
- endif ()
200
+ endblock ()
0 commit comments