@@ -187,8 +187,7 @@ function(_php_extensions_parse_dependencies extension result)
187187
188188 file (READ ${CMAKE_CURRENT_SOURCE_DIR} /${extension} /CMakeLists.txt content )
189189
190- # Remove line comments from CMake code content.
191- string (REGEX REPLACE "#[^\r\n ]*[\r\n ]" "" content "${content} " )
190+ _php_extensions_remove_comments(content )
192191
193192 string (CONCAT regex
194193 # Command invocation:
@@ -244,27 +243,19 @@ function(_php_extensions_option_regex option result)
244243 string (CONCAT _
245244 # Start of the option command invocation:
246245 "[ \t\r\n ]?option[ \t ]*\\ ([ \t\r\n ]*"
247- # Optional line comments:
248- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
249246 # Variable name:
250247 "[ \t\r\n ]*${option} [ \t\r\n ]+"
251- # Optional line comments:
252- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
253248 # Documentation string without escaped double quotes (\"):
254249 # TODO: should escaped quotes be also matched?
255250 #"[ \t\r\n]*\"([^\"]|\\\")*\"[ \t\r\n]*"
256251 "[ \t\r\n ]*\" [^\" ]*\" [ \t\r\n ]*"
257- # Optional line comments:
258- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
259252 # Optional boolean or variable value:
260253 "([ \t\r\n ]+("
261254 "ON|on|TRUE|true|YES|yes|Y|y|"
262255 "OFF|off|FALSE|false|NO|no|N|n|"
263256 "[0-9.]+|"
264257 "\\\$\\ {[^\\ }]+\\ }"
265258 "))?"
266- # Optional line comments:
267- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
268259 # End of option invocation:
269260 "[ \t\r\n ]*\\ )"
270261 )
@@ -277,40 +268,28 @@ function(_php_extensions_cmake_dependent_option_regex option result)
277268 string (CONCAT _
278269 # Start of the option command invocation:
279270 "[ \t\r\n ]?cmake_dependent_option[ \t ]*\\ ([ \t\r\n ]*"
280- # Possible inline comments:
281- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
282271 # Variable name:
283272 "[ \t\r\n ]*${option} [ \t\r\n ]+"
284- # Optional line comments:
285- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
286273 # Documentation string without escaped double quotes (\"):
287274 # TODO: should escaped quotes be also matched?
288275 #"[ \t\r\n]*\"([^\"]|\\\")*\"[ \t\r\n]*"
289276 "[ \t\r\n ]*\" [^\" ]*\" [ \t\r\n ]*"
290- # Optional line comments:
291- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
292277 # Boolean or variable value:
293278 "[ \t\r\n ]+("
294279 "ON|on|TRUE|true|YES|yes|Y|y|"
295280 "OFF|off|FALSE|false|NO|no|N|n|"
296281 "[0-9.]+|"
297282 "\\\$\\ {[^\\ }]+\\ }"
298283 ")"
299- # Optional line comments:
300- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
301284 # Semicolon separated list of conditions:
302285 "[ \t\r\n ]*\" [^\" ]*\" [ \t\r\n ]*"
303- # Optional line comments:
304- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
305286 # Boolean or variable force value:
306287 "[ \t\r\n ]+("
307288 "ON|on|TRUE|true|YES|yes|Y|y|"
308289 "OFF|off|FALSE|false|NO|no|N|n|"
309290 "[0-9.]+|"
310291 "\\\$\\ {[^\\ }]+\\ }"
311292 ")"
312- # Optional line comments:
313- "([ \t\r\n ]*#[^\r\n ]*[\r\n ])*"
314293 # End of option invocation:
315294 "[ \t\r\n ]*\\ )"
316295 )
@@ -337,6 +316,7 @@ function(_php_extensions_eval_options directories)
337316 string (TOUPPER "${extension} " extensionUpper)
338317
339318 # Check if extension has option(EXT_<extension> ...).
319+ _php_extensions_remove_comments(content )
340320 _php_extensions_option_regex("EXT_${extensionUpper} " regex )
341321 string (REGEX MATCH "${regex} " code "${content} " )
342322
@@ -374,6 +354,12 @@ function(_php_extensions_eval_options directories)
374354 endforeach ()
375355endfunction ()
376356
357+ # Remove line comments from CMake code content.
358+ function (_php_extensions_remove_comments)
359+ string (REGEX REPLACE "[ \t ]*#[^\r\n ]*" "" ${ARGV0} "${${ARGV0} }" )
360+ set (${ARGV0} "${${ARGV0} }" PARENT_SCOPE)
361+ endfunction ()
362+
377363# Postconfigure extension right after it has been configured.
378364function (php_extensions_postconfigure extension)
379365 if (NOT TARGET php_${extension} )
0 commit comments