build: improve option checking / flags

This commit is contained in:
Dirk-Jan C. Binnema 2023-09-19 00:06:39 +03:00
parent b5b90a0673
commit 0b2d5c912c
1 changed files with 21 additions and 15 deletions

View File

@ -46,6 +46,11 @@ endif
################################################################################ ################################################################################
# compilers / flags # compilers / flags
# #
# compilers
cc = meson.get_compiler('c')
cxx= meson.get_compiler('cpp')
extra_flags = [ extra_flags = [
'-Wno-unused-parameter', '-Wno-unused-parameter',
'-Wno-cast-function-type', '-Wno-cast-function-type',
@ -53,33 +58,36 @@ extra_flags = [
'-Wformat=2', '-Wformat=2',
'-Wstack-protector', '-Wstack-protector',
'-Wno-switch-enum', '-Wno-switch-enum',
'-Wno-volatile',
# assuming these are false alarm... (in fmt, with gcc13): # assuming these are false alarm... (in fmt, with gcc13):
'-Wno-array-bounds', '-Wno-array-bounds',
'-Wno-stringop-overflow', '-Wno-stringop-overflow']
# clang
'-Wc11-extensions', # for clang if (cxx.get_id() == 'clang')
extra_flags += [
'-Wc11-extensions',
'-Wno-keyword-macro', '-Wno-keyword-macro',
'-Wno-deprecated-volatile', '-Wno-deprecated-volatile',
'-Wno-#warnings', '-Wno-#warnings']
endif
extra_cpp_flags= [
'-Wno-volatile'
] ]
if get_option('buildtype') == 'debug' if get_option('buildtype') == 'debug'
extra_flags += [ extra_flags += [
'-ggdb', '-ggdb',
'-fvar-tracking', '-g3']
'-fvar-tracking-assignments']
endif endif
# compilers
cc = meson.get_compiler('c')
cxx= meson.get_compiler('cpp')
# extra arguments, if available # extra arguments, if available
foreach extra_arg : extra_flags foreach extra_arg : extra_flags
if cc.has_argument (extra_arg) if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c') add_project_arguments([extra_arg], language: 'c')
endif endif
endforeach
foreach extra_arg : extra_flags + extra_cpp_flags
if cxx.has_argument (extra_arg) if cxx.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'cpp') add_project_arguments([extra_arg], language: 'cpp')
endif endif
@ -168,8 +176,6 @@ else
message('CLD2 not found; no support for language detection') message('CLD2 not found; no support for language detection')
endif endif
dependency('cld2', required : false)
# note: these are for the unit-tests # note: these are for the unit-tests
cp=find_program('cp') cp=find_program('cp')