From: Fred Morcos Date: Tue, 8 Aug 2023 10:54:47 +0000 (+0200) Subject: Meson: Separate dependency args from global option args X-Git-Tag: rec-5.1.0-alpha1~80^2~295 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc1e9f79e235cf152ef4d76ebcd314a6207ac871;p=thirdparty%2Fpdns.git Meson: Separate dependency args from global option args --- diff --git a/meson.build b/meson.build index 7e6f7ffe0a..6db64c85f5 100644 --- a/meson.build +++ b/meson.build @@ -20,7 +20,7 @@ summary('Build Dir', product_build_dir, section: 'Build') fs = import('fs') # Create the configuration object and dependencies list. -add_global_arguments('-DHAVE_CONFIG_H') +add_global_arguments('-DHAVE_CONFIG_H', language: ['cpp']) conf = configuration_data() deps = [] diff --git a/meson/auto-var-init/meson.build b/meson/auto-var-init/meson.build index 5fc4d31bbf..a3c5552e31 100644 --- a/meson/auto-var-init/meson.build +++ b/meson/auto-var-init/meson.build @@ -9,7 +9,7 @@ if auto_var_init != 'disabled' subdir_done() endif - add_global_arguments(arg) + add_global_arguments(arg, language: ['cpp']) endif summary('Auto Var Init', auto_var_init, section: 'Configuration') diff --git a/meson/code-coverage/meson.build b/meson/code-coverage/meson.build index 7baf3a87cc..bdfbe842fb 100644 --- a/meson/code-coverage/meson.build +++ b/meson/code-coverage/meson.build @@ -1,7 +1,5 @@ # Code coverage -# Inputs: deps -code_coverage_deps = [] code_coverage = get_option('code-coverage') if code_coverage @@ -12,9 +10,9 @@ if code_coverage error('Compiler does not support ' + arg + ', which is needed for code coverage') break endif - - code_coverage_deps += declare_dependency(compile_args: [arg]) endforeach + + add_global_arguments(args, language: ['cpp']) endif summary('Code Coverage', code_coverage, bool_yn: true, section: 'Configuration') diff --git a/meson/compiler-setup/meson.build b/meson/compiler-setup/meson.build index 3f12ef9b6d..994c611e31 100644 --- a/meson/compiler-setup/meson.build +++ b/meson/compiler-setup/meson.build @@ -4,10 +4,10 @@ # Don't limit the number of errors when using clang. This is useful to not cut out the # error output when using an LSP server like clangd. if meson.get_compiler('cpp').get_id() == 'clang' - add_global_arguments(['-ferror-limit=0'], language: 'cpp') + add_global_arguments('-ferror-limit=0', language: ['cpp']) endif -add_global_arguments(['-Wshadow', '-Wmissing-declarations', '-Wredundant-decls'], language: 'cpp') +add_global_arguments('-Wshadow', '-Wmissing-declarations', '-Wredundant-decls', language: ['cpp']) cxx = meson.get_compiler('cpp') system = target_machine.system() diff --git a/meson/hardening/fortify-source/meson.build b/meson/hardening/fortify-source/meson.build index 1d9b61f6dc..a13cad11ea 100644 --- a/meson/hardening/fortify-source/meson.build +++ b/meson/hardening/fortify-source/meson.build @@ -1,5 +1,5 @@ # Fortify Source -# Inputs: hardening_features deps +# Inputs: hardening_features fortify_source_opt = get_option('fortify-source') @@ -16,8 +16,7 @@ if fortify_source_opt != 'disabled' variant_str = variant.to_string() if fortify_source_level == variant if cxx.has_argument('-D_FORTIFY_SOURCE=' + variant_str) - dep_fortify = declare_dependency(compile_args: ['-U_FORTIFY_SOURCE', '-D_FORTIFY_SOURCE=' + variant_str]) - deps += dep_fortify + add_global_arguments('-U_FORTIFY_SOURCE', '-D_FORTIFY_SOURCE=' + variant_str, language: ['cpp']) break else fortify_source_level = fortify_source_level - 1 diff --git a/meson/hardening/global-offset-table/meson.build b/meson/hardening/global-offset-table/meson.build index bef947ae80..24c35e3d51 100644 --- a/meson/hardening/global-offset-table/meson.build +++ b/meson/hardening/global-offset-table/meson.build @@ -1,5 +1,5 @@ # Read-only Global Offset Table -# Inputs: hardening_features deps +# Inputs: hardening_features ld_help = run_command(cxx, '-Wl,-help', '2>&1', check: true).stdout().strip() variants = ['relro', 'now'] @@ -7,8 +7,7 @@ found_variant = false foreach variant: variants if ld_help.contains('-z ' + variant) found_variant = true - dep_relro = declare_dependency(link_args: ['-Wl,-z', '-Wl,' + variant]) - deps += dep_relro + add_global_link_arguments('-Wl,-z', '-Wl,' + variant, language: ['cpp']) endif endforeach diff --git a/meson/hardening/pie/meson.build b/meson/hardening/pie/meson.build index 1f0ffd2ea7..ceab528da1 100644 --- a/meson/hardening/pie/meson.build +++ b/meson/hardening/pie/meson.build @@ -23,11 +23,10 @@ else foreach variant: pie_variants cflags = variant[0] ldflags = variant[1] - dep_pie = declare_dependency(compile_args: cflags, link_args: ldflags) - # if cxx.links(prog, dependencies: dep_pie, name: 'compiler can build Position Independent Executables') # TODO Meson 0.57 if cxx.links(prog, args: cflags + ldflags, name: 'compiler can build Position Independent Executables') - deps += dep_pie + add_global_arguments(cflags, language: ['cpp']) + add_global_link_arguments(ldflags, language: ['cpp']) found_variant = true break endif diff --git a/meson/hardening/stack-prot/meson.build b/meson/hardening/stack-prot/meson.build index a6dd8780c6..90282b7d08 100644 --- a/meson/hardening/stack-prot/meson.build +++ b/meson/hardening/stack-prot/meson.build @@ -1,11 +1,10 @@ # Stack Protector -# Inputs: hardening_features deps +# Inputs: hardening_features support_stack_protector = cxx.has_argument('-fstack-protector') if support_stack_protector - dep_sp = declare_dependency(compile_args: ['-fstack-protector']) - deps += dep_sp + add_global_arguments('-fstack-protector', language: ['cpp']) endif hardening_features += [[support_stack_protector, 'Stack Protector']] diff --git a/meson/hardening/stack-smashing-prot/meson.build b/meson/hardening/stack-smashing-prot/meson.build index cac77210b5..e0440bc958 100644 --- a/meson/hardening/stack-smashing-prot/meson.build +++ b/meson/hardening/stack-smashing-prot/meson.build @@ -3,7 +3,7 @@ support_stack_smashing_protector = cxx.has_argument('--param=ssp-buffer-size=4') if support_stack_smashing_protector - add_global_arguments(['--param=ssp-buffer-size=4'], language: ['c', 'cpp']) + add_global_arguments('--param=ssp-buffer-size=4', language: ['cpp']) endif hardening_features += [[support_stack_smashing_protector, 'Stack Smashing Protection']] diff --git a/meson/libcrypto/meson.build b/meson/libcrypto/meson.build index 618a132a0b..91d97aaed3 100644 --- a/meson/libcrypto/meson.build +++ b/meson/libcrypto/meson.build @@ -123,11 +123,11 @@ has = cxx.has_header_symbol('openssl/kdf.h', 'EVP_PKEY_CTX_set1_scrypt_salt', ar conf.set10('HAVE_EVP_PKEY_CTX_SET1_SCRYPT_SALT', has, description: 'Whether we have EVP_PKEY_CTX_set1_scrypt_salt') if libdir != '' - add_global_arguments(libcrypto_args + ['-I' + libdir / 'include']) -else - deps += dep_libcrypto + dep_libcrypto = declare_dependency(compile_args: libcrypto_args + ['-I' + libdir / 'include']) endif +deps += dep_libcrypto + conf.set10('HAVE_LIBCRYPTO', have_libcrypto, description: 'Whether we build OpenSSL libcrypto-based signers') summary('OpenSSL libcrypto', have_libcrypto, bool_yn: true, section: 'Configuration') diff --git a/meson/libdecaf/meson.build b/meson/libdecaf/meson.build index a52054f6d2..2e6c02e441 100644 --- a/meson/libdecaf/meson.build +++ b/meson/libdecaf/meson.build @@ -24,7 +24,7 @@ if not opt_libdecaf.disabled() message('Libdecaf: Checking for ' + header_path) found_header = cxx.has_header(header, dependencies: dep_libdecaf, required: false, include_directories: dir) if found_header - add_global_arguments('-I' + dirname, language: 'cpp') + deps += declare_dependency(compile_args: ['-I' + dirname]) do_break = true break endif diff --git a/meson/platform/meson.build b/meson/platform/meson.build index ee64b60583..cff51b7a40 100644 --- a/meson/platform/meson.build +++ b/meson/platform/meson.build @@ -28,8 +28,7 @@ foreach platform: platforms endforeach foreach arg: args - dep = declare_dependency(compile_args: ['-D' + arg]) - deps += dep + add_global_arguments('-D' + arg, language: ['cpp']) endforeach foreach lib: libs diff --git a/meson/sanitizers/address-sanitizer/meson.build b/meson/sanitizers/address-sanitizer/meson.build index 2cb3ec56a2..bf3d30a7d6 100644 --- a/meson/sanitizers/address-sanitizer/meson.build +++ b/meson/sanitizers/address-sanitizer/meson.build @@ -55,6 +55,6 @@ conf.set10('HAVE_FIBER_SANITIZER', single_pointer or three_pointers, description conf.set10('HAVE_SANITIZER_FINISH_SWITCH_FIBER_SINGLE_PTR', single_pointer, description: 'Address Sanitizer: __sanitizer_finish_switch_fiber takes only a pointer') conf.set10('HAVE_SANITIZER_FINISH_SWITCH_FIBER_THREE_PTRS', three_pointers, description: 'Address Sanitizer: __sanitizer_finish_switch_fiber takes three pointers') -add_global_arguments('-fsanitize=address') +add_global_arguments('-fsanitize=address', language: ['cpp']) summary('address', opt_address_sanitizer, bool_yn: true, section: 'Sanitizers') diff --git a/meson/sanitizers/meson.build b/meson/sanitizers/meson.build index 0d6f7d2998..3850783e42 100644 --- a/meson/sanitizers/meson.build +++ b/meson/sanitizers/meson.build @@ -21,7 +21,7 @@ foreach sanitizer, name: sanitizers if not cxx.has_argument(compiler_opt) error(name + ' Sanitizer requested but compiler does not support `' + compiler_opt + '`') endif - add_global_arguments(compiler_opt) + add_global_arguments(compiler_opt, language: ['cpp']) summary(name, get_variable(opt_name), bool_yn: true, section: 'Sanitizers') endforeach @@ -42,5 +42,5 @@ if opt_memory_sanitizer and opt_thread_sanitizer endif if opt_address_sanitizer or opt_thread_sanitizer or opt_leak_sanitizer or opt_undefined_behavior_sanitizer or opt_memory_sanitizer - add_global_arguments('-fno-omit-frame-pointer') + add_global_arguments('-fno-omit-frame-pointer', language: ['cpp']) endif