Port WARNCFLAGS of CMakeLists.txt to meson.build

And let CMake determine which compiler warning flags are available as
suggested in [1].

[1] https://gitlab.com/federicomenaquintero/bzip2/merge_requests/19#note_206149857
This commit is contained in:
Chih-Hsuan Yen 2019-08-19 22:51:25 +08:00
parent 3eff339237
commit 4a8a9fd228
No known key found for this signature in database
GPG Key ID: 0453A6CA23C56315
2 changed files with 48 additions and 6 deletions

View File

@ -129,6 +129,7 @@ else()
endif() endif()
# For C compiler # For C compiler
# Please keep this list in sync with meson.build
extract_valid_c_flags(WARNCFLAGS extract_valid_c_flags(WARNCFLAGS
-Wall -Wall
-Wextra -Wextra
@ -154,22 +155,22 @@ else()
-Waddress -Waddress
-Wattributes -Wattributes
-Wdiv-by-zero -Wdiv-by-zero
# -Wshorten-64-to-32 # May be missing from GCC -Wshorten-64-to-32
-Wconversion -Wconversion
# -Wextended-offsetof # May be missing from GCC -Wextended-offsetof
-Wformat-nonliteral -Wformat-nonliteral
# -Wlanguage-extension-token # May be missing from GCC -Wlanguage-extension-token
-Wmissing-field-initializers -Wmissing-field-initializers
-Wmissing-noreturn -Wmissing-noreturn
# -Wmissing-variable-declarations # May be missing from GCC -Wmissing-variable-declarations
# -Wpadded # Not used because we cannot change public structs # -Wpadded # Not used because we cannot change public structs
-Wsign-conversion -Wsign-conversion
# -Wswitch-enum # Not used because this basically disallows default case # -Wswitch-enum # Not used because this basically disallows default case
# -Wunreachable-code-break # May be missing from GCC -Wunreachable-code-break
-Wunused-macros -Wunused-macros
-Wunused-parameter -Wunused-parameter
-Wredundant-decls -Wredundant-decls
# -Wheader-guard # Only work with Clang for the moment -Wheader-guard
-Wno-format-nonliteral # This is required because we pass format string as "const char*. -Wno-format-nonliteral # This is required because we pass format string as "const char*.
) )
endif() endif()

View File

@ -16,7 +16,48 @@ configure_file(
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
add_project_arguments(cc.get_supported_arguments([ add_project_arguments(cc.get_supported_arguments([
# Please keep this list in sync with CMakeLists.txt
'-Wall',
'-Wextra',
'-Wmissing-prototypes',
'-Wstrict-prototypes',
'-Wmissing-declarations',
'-Wpointer-arith',
'-Wdeclaration-after-statement',
'-Wformat-security',
'-Wwrite-strings',
'-Wshadow',
'-Winline', '-Winline',
'-Wnested-externs',
'-Wfloat-equal',
'-Wundef',
'-Wendif-labels',
'-Wempty-body',
'-Wcast-align',
'-Wclobbered',
'-Wvla',
'-Wpragmas',
'-Wunreachable-code',
'-Waddress',
'-Wattributes',
'-Wdiv-by-zero',
'-Wshorten-64-to-32',
'-Wconversion',
'-Wextended-offsetof',
'-Wformat-nonliteral',
'-Wlanguage-extension-token',
'-Wmissing-field-initializers',
'-Wmissing-noreturn',
'-Wmissing-variable-declarations',
# '-Wpadded', # Not used because we cannot change public structs
'-Wsign-conversion',
# '-Wswitch-enum', # Not used because this basically disallows default case
'-Wunreachable-code-break',
'-Wunused-macros',
'-Wunused-parameter',
'-Wredundant-decls',
'-Wheader-guard',
'-Wno-format-nonliteral', # This is required because we pass format string as "const char*.
]), ]),
language : 'c', language : 'c',
) )