From 5b398308b63141554430e1a90a2eccdfb1189ab9 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Thu, 12 Jan 2023 15:09:17 +0100 Subject: [PATCH] meson: add common compiler options similar to configure.ac Co-authored-by: Marvin Scholz --- meson.build | 41 +++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 6 +++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 0cf1f30c0a..c424d7e5a9 100644 --- a/meson.build +++ b/meson.build @@ -403,6 +403,47 @@ windows_version_test = ''' endif +add_project_arguments(cc.get_supported_arguments([ + '-Wno-deprecated-copy', # Some Qt version are generating tons of warning that cannot be + # avoided so mute them +]), language: ['c', 'cpp', 'objc']) + +add_project_arguments(cc.get_supported_arguments([ + '-Wextra', + '-Wsign-compare', + '-Wundef', + '-Wpointer-arith', + '-Wvolatile-register-var', + '-Wformat', + '-Wformat-security', + '-Wduplicated-branches', + '-Wduplicated-cond', +]), language: ['c', 'cpp']) + +add_project_arguments(cc.get_supported_arguments([ + '-Wbad-function-cast', + '-Wwrite-strings', + '-Wmissing-prototypes', + '-Werror-implicit-function-declaration', + '-Winit-self', + '-Wlogical-op', + '-Wshadow=local', + '-Wmultistatement-macros', + '-pipe' +]), language: ['c']) + +if get_option('branch_protection') \ + .require(host_machine.cpu_family() == 'aarch64', error_message: 'Branch protection is only available for AArch64') \ + .require(cc.has_argument('-mbranch-protection=standard'), error_message: 'Compiler does not support `-mbranch-protection`') \ + .allowed() + add_project_arguments('-mbranch-protection=standard', language: ['c', 'cpp']) +endif + +if cc.get_id() not in ['clang-cl'] + add_project_arguments(cc.get_supported_arguments([ + '-Wall', # too verbose with clang-cl + ]), language: ['c', 'cpp']) +endif add_project_arguments(cc.first_supported_argument(['-Werror-implicit-function-declaration', '-we4013']), language: ['c']) diff --git a/meson_options.txt b/meson_options.txt index 88b74b1f98..572912bc1f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -40,6 +40,11 @@ option('run_as_root', value : false, description : 'Allow running VLC as root') +option('branch_protection', + type : 'feature', + value : 'auto', + description : 'AArch64 branch protection') + option('winstore_app', type : 'boolean', value : 'false', @@ -52,7 +57,6 @@ option('winstore_app', # TODO: Missing avx option # TODO: Missing neon option # TODO: Missing sve option -# TODO: Missing branch_protection option # TODO: Missing altivec option # TODO: Missing update-check option