[meson] fix spurious warning when building test/api C sources

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
This commit is contained in:
Tim-Philipp Müller 2020-03-14 01:08:15 +00:00 committed by Ebrahim Byagowi
parent bb8aaa3108
commit a3892be701
2 changed files with 4 additions and 4 deletions

View File

@ -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]

View File

@ -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,