From a3892be70108adb0cbafcff9bf4c2ebc0f65acb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 14 Mar 2020 01:08:15 +0000 Subject: [PATCH] [meson] fix spurious warning when building test/api C sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes compiler warning test-unicode.c:589:1: warning: ‘test_unicode_properties_lenient’ defined but not used which didn't happen with autotools. Reason it does with meson is that the setup for C was slightly wrong. We would only add -DHAVE_CONFIG_H to cpp_args which is only valid when compiling C++ code, but not plain C code, and many of these tests were plain C. Instead pass -DHAVE_CONFIG_H via add_project_arguments() and make sure to set both c_args and cpp_args when building test executables. Fixes https://github.com/harfbuzz/harfbuzz/issues/2257 --- meson.build | 5 +++-- test/api/meson.build | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index c22e92626..52e829ac0 100644 --- a/meson.build +++ b/meson.build @@ -144,13 +144,14 @@ deps = [] conf = configuration_data() incconfig = include_directories('.') -cpp_args = ['-DHAVE_CONFIG_H'] + +add_project_arguments('-DHAVE_CONFIG_H', language: ['c', 'cpp']) warn_cflags = [ '-Wno-non-virtual-dtor', ] -cpp_args += cpp.get_supported_arguments(warn_cflags) +cpp_args = cpp.get_supported_arguments(warn_cflags) if m_dep.found() deps += [m_dep] diff --git a/test/api/meson.build b/test/api/meson.build index 0a9ade6ea..6258915bb 100644 --- a/test/api/meson.build +++ b/test/api/meson.build @@ -45,10 +45,9 @@ if conf.get('HAVE_GLIB', 0) == 1 opts = test_data.length() > 1 ? test_data[1] : {} extra_c_args = opts.get('c_args', []) - - test_name = fname.split('.')[0].underscorify() exe = executable(test_name, fname, + c_args: extra_c_args, cpp_args: cpp_args + extra_c_args, include_directories: [incconfig, incsrc], dependencies: deps,