build: Add variable to check if a GNU C compiler is used

This applies to both gcc and clang, without having to repeat the same
check multiple times and involving strings
This commit is contained in:
Marco Trevisan (Treviño) 2024-05-09 19:00:41 +02:00
parent 589c8295ea
commit 3bba0adcc1

View File

@ -567,8 +567,10 @@ foreach m : struct_members
endif
endforeach
glib_gnu_cc_compiler = cc.get_id() == 'gcc' or cc.get_id() == 'clang'
# Compiler flags
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
if glib_gnu_cc_compiler
warning_common_args = [
'-Wduplicated-branches',
'-Wfloat-conversion',
@ -1784,7 +1786,7 @@ g_sizet_compatibility = {
# Do separate checks for gcc/clang (and ignore other compilers for now), since
# we need to explicitly pass -Werror to the compilers.
# FIXME: https://github.com/mesonbuild/meson/issues/5399
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
if glib_gnu_cc_compiler
foreach type_name, size_compatibility : g_sizet_compatibility
g_sizet_compatibility += { type_name: size_compatibility and
cc.compiles(
@ -2082,7 +2084,7 @@ if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl' or cc.links(atomictest, na
glib_conf.set('__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4', true)
endif
if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
if glib_gnu_cc_compiler
sync_swap_test = '''
int main() {
int atomic = 2;