From 0b2d5c912c01abc4672f148f622c6e5c482ed755 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Tue, 19 Sep 2023 00:06:39 +0300 Subject: [PATCH] build: improve option checking / flags --- meson.build | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build index b29d3d44..30b3a166 100644 --- a/meson.build +++ b/meson.build @@ -46,6 +46,11 @@ endif ################################################################################ # compilers / flags # + +# compilers +cc = meson.get_compiler('c') +cxx= meson.get_compiler('cpp') + extra_flags = [ '-Wno-unused-parameter', '-Wno-cast-function-type', @@ -53,33 +58,36 @@ extra_flags = [ '-Wformat=2', '-Wstack-protector', '-Wno-switch-enum', - '-Wno-volatile', # assuming these are false alarm... (in fmt, with gcc13): '-Wno-array-bounds', - '-Wno-stringop-overflow', -# clang - '-Wc11-extensions', # for clang - '-Wno-keyword-macro', - '-Wno-deprecated-volatile', - '-Wno-#warnings', + '-Wno-stringop-overflow'] + +if (cxx.get_id() == 'clang') + extra_flags += [ + '-Wc11-extensions', + '-Wno-keyword-macro', + '-Wno-deprecated-volatile', + '-Wno-#warnings'] +endif + +extra_cpp_flags= [ + '-Wno-volatile' ] if get_option('buildtype') == 'debug' extra_flags += [ '-ggdb', - '-fvar-tracking', - '-fvar-tracking-assignments'] + '-g3'] endif -# compilers -cc = meson.get_compiler('c') -cxx= meson.get_compiler('cpp') - # extra arguments, if available foreach extra_arg : extra_flags if cc.has_argument (extra_arg) add_project_arguments([extra_arg], language: 'c') endif +endforeach + +foreach extra_arg : extra_flags + extra_cpp_flags if cxx.has_argument (extra_arg) add_project_arguments([extra_arg], language: 'cpp') endif @@ -168,8 +176,6 @@ else message('CLD2 not found; no support for language detection') endif -dependency('cld2', required : false) - # note: these are for the unit-tests cp=find_program('cp')