@@ -8,6 +8,8 @@ include(CheckSourceRuns)
88include (CMakePushCheckState)
99include (PHP/CheckCompilerFlag)
1010
11+ get_cmake_property (enabledLanguages ENABLED_LANGUAGES )
12+ 
1113# Check for broken GCC optimize-strlen. 
1214include (PHP/CheckBrokenGccStrlenOpt)
1315if (PHP_HAVE_BROKEN_OPTIMIZE_STRLEN)
@@ -78,14 +80,16 @@ if(HAVE_WNO_CLOBBERED_C)
7880      $<$<COMPILE_LANGUAGE:ASM,C>:-Wno-clobbered>
7981  )
8082endif ()
81- php_check_compiler_flag(CXX -Wno-clobbered HAVE_WNO_CLOBBERED_CXX)
82- if (HAVE_WNO_CLOBBERED_CXX)
83-   target_compile_options (
84-     php_configuration
85-     BEFORE
86-     INTERFACE 
87-       $<$<COMPILE_LANGUAGE:CXX>:-Wno-clobbered>
88-   )
83+ if (CXX IN_LIST  enabledLanguages)
84+   php_check_compiler_flag(CXX -Wno-clobbered HAVE_WNO_CLOBBERED_CXX)
85+   if (HAVE_WNO_CLOBBERED_CXX)
86+     target_compile_options (
87+       php_configuration
88+       BEFORE
89+       INTERFACE 
90+         $<$<COMPILE_LANGUAGE:CXX>:-Wno-clobbered>
91+     )
92+   endif ()
8993endif ()
9094
9195# Check for support for implicit fallthrough level 1, also add after previous 
@@ -102,17 +106,19 @@ if(HAVE_WIMPLICIT_FALLTHROUGH_1_C)
102106      $<$<COMPILE_LANGUAGE:ASM,C>:-Wimplicit-fallthrough=1>
103107  )
104108endif ()
105- php_check_compiler_flag(
106-   CXX
107-   -Wimplicit-fallthrough=1
108-   HAVE_WIMPLICIT_FALLTHROUGH_1_CXX
109- )
110- if (HAVE_WIMPLICIT_FALLTHROUGH_1_CXX)
111-   target_compile_options (
112-     php_configuration
113-     INTERFACE 
114-       $<$<COMPILE_LANGUAGE:CXX>:-Wimplicit-fallthrough=1>
109+ if (CXX IN_LIST  enabledLanguages)
110+   php_check_compiler_flag(
111+     CXX
112+     -Wimplicit-fallthrough=1
113+     HAVE_WIMPLICIT_FALLTHROUGH_1_CXX
115114  )
115+   if (HAVE_WIMPLICIT_FALLTHROUGH_1_CXX)
116+     target_compile_options (
117+       php_configuration
118+       INTERFACE 
119+         $<$<COMPILE_LANGUAGE:CXX>:-Wimplicit-fallthrough=1>
120+     )
121+   endif ()
116122endif ()
117123
118124php_check_compiler_flag(C -Wduplicated-cond HAVE_WDUPLICATED_COND_C)
@@ -124,14 +130,16 @@ if(HAVE_WDUPLICATED_COND_C)
124130      $<$<COMPILE_LANGUAGE:ASM,C>:-Wduplicated-cond>
125131  )
126132endif ()
127- php_check_compiler_flag(CXX -Wduplicated-cond HAVE_WDUPLICATED_COND_CXX)
128- if (HAVE_WDUPLICATED_COND_CXX)
129-   target_compile_options (
130-     php_configuration
131-     BEFORE
132-     INTERFACE 
133-       $<$<COMPILE_LANGUAGE:CXX>:-Wduplicated-cond>
134-   )
133+ if (CXX IN_LIST  enabledLanguages)
134+   php_check_compiler_flag(CXX -Wduplicated-cond HAVE_WDUPLICATED_COND_CXX)
135+   if (HAVE_WDUPLICATED_COND_CXX)
136+     target_compile_options (
137+       php_configuration
138+       BEFORE
139+       INTERFACE 
140+         $<$<COMPILE_LANGUAGE:CXX>:-Wduplicated-cond>
141+     )
142+   endif ()
135143endif ()
136144
137145php_check_compiler_flag(C -Wlogical-op HAVE_WLOGICAL_OP_C)
@@ -143,14 +151,16 @@ if(HAVE_WLOGICAL_OP_C)
143151      $<$<COMPILE_LANGUAGE:ASM,C>:-Wlogical-op>
144152  )
145153endif ()
146- php_check_compiler_flag(CXX -Wlogical-op HAVE_WLOGICAL_OP_CXX)
147- if (HAVE_WLOGICAL_OP_CXX)
148-   target_compile_options (
149-     php_configuration
150-     BEFORE
151-     INTERFACE 
152-       $<$<COMPILE_LANGUAGE:CXX>:-Wlogical-op>
153-   )
154+ if (CXX IN_LIST  enabledLanguages)
155+   php_check_compiler_flag(CXX -Wlogical-op HAVE_WLOGICAL_OP_CXX)
156+   if (HAVE_WLOGICAL_OP_CXX)
157+     target_compile_options (
158+       php_configuration
159+       BEFORE
160+       INTERFACE 
161+         $<$<COMPILE_LANGUAGE:CXX>:-Wlogical-op>
162+     )
163+   endif ()
154164endif ()
155165
156166php_check_compiler_flag(C -Wformat-truncation HAVE_WFORMAT_TRUNCATION_C)
@@ -162,14 +172,16 @@ if(HAVE_WFORMAT_TRUNCATION_C)
162172      $<$<COMPILE_LANGUAGE:ASM,C>:-Wformat-truncation>
163173  )
164174endif ()
165- php_check_compiler_flag(CXX -Wformat-truncation HAVE_WFORMAT_TRUNCATION_CXX)
166- if (HAVE_WFORMAT_TRUNCATION_CXX)
167-   target_compile_options (
168-     php_configuration
169-     BEFORE
170-     INTERFACE 
171-       $<$<COMPILE_LANGUAGE:CXX>:-Wformat-truncation>
172-   )
175+ if (CXX IN_LIST  enabledLanguages)
176+   php_check_compiler_flag(CXX -Wformat-truncation HAVE_WFORMAT_TRUNCATION_CXX)
177+   if (HAVE_WFORMAT_TRUNCATION_CXX)
178+     target_compile_options (
179+       php_configuration
180+       BEFORE
181+       INTERFACE 
182+         $<$<COMPILE_LANGUAGE:CXX>:-Wformat-truncation>
183+     )
184+   endif ()
173185endif ()
174186
175187php_check_compiler_flag(C -Wstrict-prototypes HAVE_WSTRICT_PROTOTYPES_C)
@@ -191,14 +203,16 @@ if(HAVE_FNO_COMMON_C)
191203      $<$<COMPILE_LANGUAGE:ASM,C>:-fno-common>
192204  )
193205endif ()
194- php_check_compiler_flag(CXX -fno-common HAVE_FNO_COMMON_CXX)
195- if (HAVE_FNO_COMMON_C_XX)
196-   target_compile_options (
197-     php_configuration
198-     BEFORE
199-     INTERFACE 
200-       $<$<COMPILE_LANGUAGE:CXX>:-fno-common>
201-   )
206+ if (CXX IN_LIST  enabledLanguages)
207+   php_check_compiler_flag(CXX -fno-common HAVE_FNO_COMMON_CXX)
208+   if (HAVE_FNO_COMMON_C_XX)
209+     target_compile_options (
210+       php_configuration
211+       BEFORE
212+       INTERFACE 
213+         $<$<COMPILE_LANGUAGE:CXX>:-fno-common>
214+     )
215+   endif ()
202216endif ()
203217
204218# Explicitly disable floating-point expression contraction, even if already done 
@@ -240,14 +254,16 @@ if(PHP_MEMORY_SANITIZER)
240254      HAVE_MEMORY_SANITIZER_C
241255    )
242256
243-     php_check_compiler_flag(
244-       CXX
245-       "-fsanitize=memory;-fsanitize-memory-track-origins" 
246-       HAVE_MEMORY_SANITIZER_CXX
247-     )
257+     if (CXX IN_LIST  enabledLanguages)
258+       php_check_compiler_flag(
259+         CXX
260+         "-fsanitize=memory;-fsanitize-memory-track-origins" 
261+         HAVE_MEMORY_SANITIZER_CXX
262+       )
263+     endif ()
248264  cmake_pop_check_state()
249265
250-   if (HAVE_MEMORY_SANITIZER_C AND  HAVE_MEMORY_SANITIZER_CXX)
266+   if (HAVE_MEMORY_SANITIZER_C OR  HAVE_MEMORY_SANITIZER_CXX)
251267    target_compile_options (
252268      php_configuration
253269      INTERFACE 
@@ -284,10 +300,12 @@ if(PHP_ADDRESS_SANITIZER)
284300    set (CMAKE_REQUIRED_LINK_OPTIONS "-fsanitize=address" )
285301
286302    php_check_compiler_flag(C -fsanitize=address HAVE_ADDRESS_SANITIZER_C)
287-     php_check_compiler_flag(CXX -fsanitize=address HAVE_ADDRESS_SANITIZER_CXX)
303+     if (CXX IN_LIST  enabledLanguages)
304+       php_check_compiler_flag(CXX -fsanitize=address HAVE_ADDRESS_SANITIZER_CXX)
305+     endif ()
288306  cmake_pop_check_state()
289307
290-   if (HAVE_ADDRESS_SANITIZER_C AND  HAVE_ADDRESS_SANITIZER_CXX)
308+   if (HAVE_ADDRESS_SANITIZER_C OR  HAVE_ADDRESS_SANITIZER_CXX)
291309    target_compile_options (
292310      php_configuration
293311      INTERFACE 
@@ -325,14 +343,16 @@ if(PHP_UNDEFINED_SANITIZER)
325343      -fsanitize=undefined
326344      HAVE_UNDEFINED_SANITIZER_C
327345    )
328-     php_check_compiler_flag(
329-       CXX
330-       -fsanitize=undefined
331-       HAVE_UNDEFINED_SANITIZER_CXX
332-     )
346+     if (CXX IN_LIST  enabledLanguages)
347+       php_check_compiler_flag(
348+         CXX
349+         -fsanitize=undefined
350+         HAVE_UNDEFINED_SANITIZER_CXX
351+       )
352+     endif ()
333353  cmake_pop_check_state()
334354
335-   if (HAVE_UNDEFINED_SANITIZER_C AND  HAVE_UNDEFINED_SANITIZER_CXX)
355+   if (HAVE_UNDEFINED_SANITIZER_C OR  HAVE_UNDEFINED_SANITIZER_CXX)
336356    target_compile_options (
337357      php_configuration
338358      INTERFACE 
@@ -355,14 +375,16 @@ if(PHP_UNDEFINED_SANITIZER)
355375        -fno-sanitize=object-size
356376        HAVE_OBJECT_SIZE_SANITIZER_C
357377      )
358-       php_check_compiler_flag(
359-         CXX
360-         -fno-sanitize=object-size
361-         HAVE_OBJECT_SIZE_SANITIZER_CXX
362-       )
378+       if (CXX IN_LIST  enabledLanguages)
379+         php_check_compiler_flag(
380+           CXX
381+           -fno-sanitize=object-size
382+           HAVE_OBJECT_SIZE_SANITIZER_CXX
383+         )
384+       endif ()
363385    cmake_pop_check_state()
364386
365-     if (HAVE_OBJECT_SIZE_SANITIZER_C AND  HAVE_OBJECT_SIZE_SANITIZER_CXX)
387+     if (HAVE_OBJECT_SIZE_SANITIZER_C OR  HAVE_OBJECT_SIZE_SANITIZER_CXX)
366388      target_compile_options (
367389        php_configuration
368390        INTERFACE 
@@ -412,11 +434,13 @@ if(PHP_UNDEFINED_SANITIZER)
412434        -fno-sanitize=function
413435        HAVE_FNO_SANITIZE_FUNCTION_C
414436      )
415-       php_check_compiler_flag(
416-         CXX
417-         -fno-sanitize=function
418-         HAVE_FNO_SANITIZE_FUNCTION_CXX
419-       )
437+       if (CXX IN_LIST  enabledLanguages)
438+         php_check_compiler_flag(
439+           CXX
440+           -fno-sanitize=function
441+           HAVE_FNO_SANITIZE_FUNCTION_CXX
442+         )
443+       endif ()
420444
421445      if (HAVE_FNO_SANITIZE_FUNCTION_C)
422446        target_compile_options (
@@ -448,11 +472,13 @@ if(PHP_MEMORY_SANITIZER OR PHP_ADDRESS_SANITIZER OR PHP_UNDEFINED_SANITIZER)
448472    -fno-omit-frame-pointer
449473    HAVE_FNO_OMIT_FRAME_POINTER_C
450474  )
451-   php_check_compiler_flag(
452-     CXX
453-     -fno-omit-frame-pointer
454-     HAVE_FNO_OMIT_FRAME_POINTER_CXX
455-   )
475+   if (CXX IN_LIST  enabledLanguages)
476+     php_check_compiler_flag(
477+       CXX
478+       -fno-omit-frame-pointer
479+       HAVE_FNO_OMIT_FRAME_POINTER_CXX
480+     )
481+   endif ()
456482
457483  if (HAVE_FNO_OMIT_FRAME_POINTER_C)
458484    target_compile_options (
0 commit comments