mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-11 08:40:19 +01:00
build/meson: fix build to always set "-W" compiler flags
We must set these compiler flags independent as to whether this is a release build or a debug build. In most cases, we don't differentiate between release and debug build anyway. Granted, we have "-D more_asserts=100" and set "-O" CFLAGS, but that is more granular and not a simple "buildtype". In particular, these compiler flags apply to all kinds of builds. This is important, because otherwise we get build failures, because also in release build we want to build with `-Werror` and `-Wall`. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/692 (cherry picked from commitc0c6470e4d) (cherry picked from commit6b316a1991)
This commit is contained in:
parent
fb0571e8d8
commit
805c9fa8d4
1 changed files with 56 additions and 61 deletions
117
meson.build
117
meson.build
|
|
@ -65,8 +65,6 @@ libnm_version = '@0@.@1@.@2@'.format(current - age, age, revision)
|
|||
|
||||
libnm_pkgincludedir = join_paths(nm_includedir, libnm_name)
|
||||
|
||||
nm_debug = get_option('buildtype').contains('debug')
|
||||
|
||||
gnome = import('gnome')
|
||||
i18n = import('i18n')
|
||||
pkg = import('pkgconfig')
|
||||
|
|
@ -173,67 +171,64 @@ if enable_lto
|
|||
common_ldflags += lto_flag
|
||||
endif
|
||||
|
||||
if nm_debug
|
||||
common_flags += cc.get_supported_arguments([
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wdeclaration-after-statement',
|
||||
'-Wfloat-equal',
|
||||
'-Wformat-nonliteral',
|
||||
'-Wformat-security',
|
||||
'-Wimplicit-function-declaration',
|
||||
'-Winit-self',
|
||||
'-Wlogical-op',
|
||||
'-Wmissing-declarations',
|
||||
'-Wmissing-include-dirs',
|
||||
'-Wmissing-prototypes',
|
||||
'-Wpointer-arith',
|
||||
'-Wshadow',
|
||||
'-Wshift-negative-value',
|
||||
'-Wstrict-prototypes',
|
||||
'-Wundef',
|
||||
'-Wvla',
|
||||
'-Wno-duplicate-decl-specifier',
|
||||
'-Wno-format-truncation',
|
||||
'-Wno-format-y2k',
|
||||
'-Wno-gnu-variable-sized-type-not-at-end',
|
||||
'-Wno-missing-field-initializers',
|
||||
'-Wno-pragmas',
|
||||
'-Wno-sign-compare',
|
||||
'-Wno-tautological-constant-out-of-range-compare',
|
||||
'-Wno-unknown-pragmas',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wparentheses-equality',
|
||||
'-Wpointer-arith',
|
||||
'-Wshadow',
|
||||
'-Wstrict-prototypes',
|
||||
'-Wtypedef-redefinition',
|
||||
'-Wundef',
|
||||
'-Wunknown-attributes',
|
||||
'-fno-strict-aliasing',
|
||||
])
|
||||
common_flags += cc.get_supported_arguments([
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wdeclaration-after-statement',
|
||||
'-Wfloat-equal',
|
||||
'-Wformat-nonliteral',
|
||||
'-Wformat-security',
|
||||
'-Wimplicit-function-declaration',
|
||||
'-Winit-self',
|
||||
'-Wlogical-op',
|
||||
'-Wmissing-declarations',
|
||||
'-Wmissing-include-dirs',
|
||||
'-Wmissing-prototypes',
|
||||
'-Wpointer-arith',
|
||||
'-Wshadow',
|
||||
'-Wshift-negative-value',
|
||||
'-Wstrict-prototypes',
|
||||
'-Wundef',
|
||||
'-Wvla',
|
||||
'-Wno-duplicate-decl-specifier',
|
||||
'-Wno-format-truncation',
|
||||
'-Wno-format-y2k',
|
||||
'-Wno-gnu-variable-sized-type-not-at-end',
|
||||
'-Wno-missing-field-initializers',
|
||||
'-Wno-pragmas',
|
||||
'-Wno-sign-compare',
|
||||
'-Wno-tautological-constant-out-of-range-compare',
|
||||
'-Wno-unknown-pragmas',
|
||||
'-Wno-unused-parameter',
|
||||
'-Wparentheses-equality',
|
||||
'-Wpointer-arith',
|
||||
'-Wshadow',
|
||||
'-Wstrict-prototypes',
|
||||
'-Wtypedef-redefinition',
|
||||
'-Wundef',
|
||||
'-Wunknown-attributes',
|
||||
'-fno-strict-aliasing',
|
||||
])
|
||||
|
||||
if cc.has_argument('-Wimplicit-fallthrough')
|
||||
if cc.compiles('''
|
||||
int main(int argc, char **argv) {
|
||||
int r = 0;
|
||||
switch (argc) {
|
||||
case 0:
|
||||
r++;
|
||||
/* fall-through */
|
||||
case 1:
|
||||
r++;
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
''',
|
||||
args: '-Werror=implicit-fallthrough',
|
||||
name: '-Werror=implicit-fallthrough')
|
||||
common_flags += '-Wimplicit-fallthrough'
|
||||
endif
|
||||
if cc.has_argument('-Wimplicit-fallthrough')
|
||||
if cc.compiles('''
|
||||
int main(int argc, char **argv) {
|
||||
int r = 0;
|
||||
switch (argc) {
|
||||
case 0:
|
||||
r++;
|
||||
/* fall-through */
|
||||
case 1:
|
||||
r++;
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
''',
|
||||
args: '-Werror=implicit-fallthrough',
|
||||
name: '-Werror=implicit-fallthrough')
|
||||
common_flags += '-Wimplicit-fallthrough'
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
add_project_arguments(common_flags, language: 'c')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue