pkgconfig: Add missing cflags in uninstalled files

Fixes: #7365
pull/7381/head
Xavier Claessens 4 years ago committed by Jussi Pakkanen
parent 35f2a2444f
commit d0f468fef1
  1. 27
      mesonbuild/modules/pkgconfig.py
  2. 5
      run_unittests.py
  3. 4
      test cases/common/47 pkgconfig-gen/dependencies/main.c
  4. 3
      test cases/common/47 pkgconfig-gen/meson.build

@ -372,18 +372,18 @@ class PkgConfigModule(ExtensionModule):
if len(deps.priv_libs) > 0:
ofile.write('Libs.private: {}\n'.format(' '.join(generate_libs_flags(deps.priv_libs))))
def generate_compiler_flags():
cflags_buf = []
for f in deps.cflags:
cflags_buf.append(self._escape(f))
return cflags_buf
cflags = generate_compiler_flags()
ofile.write('Cflags: ')
cflags = []
if uninstalled:
ofile.write(' '.join(generate_uninstalled_cflags(deps.pub_libs + deps.priv_libs)))
elif not dataonly and cflags:
ofile.write('{}\n'.format(' '.join(cflags)))
cflags += generate_uninstalled_cflags(deps.pub_libs + deps.priv_libs)
else:
for d in subdirs:
if d == '.':
cflags.append('-I${includedir}')
else:
cflags.append(self._escape(PurePath('-I${includedir}') / d))
cflags += [self._escape(f) for f in deps.cflags]
if cflags and not dataonly:
ofile.write('Cflags: {}\n'.format(' '.join(cflags)))
@FeatureNewKwargs('pkgconfig.generate', '0.54.0', ['uninstalled_variables'])
@FeatureNewKwargs('pkgconfig.generate', '0.42.0', ['extra_cflags'])
@ -448,11 +448,6 @@ class PkgConfigModule(ExtensionModule):
libraries = [mainlib] + libraries
deps = DependenciesHelper(state, filebase)
for d in subdirs:
if d == '.':
deps.add_cflags(['-I${includedir}'])
else:
deps.add_cflags(self._escape(PurePath('-I${includedir}') / d))
deps.add_pub_libs(libraries)
deps.add_priv_libs(kwargs.get('libraries_private', []))
deps.add_pub_reqs(kwargs.get('requires', []))

@ -3177,8 +3177,9 @@ int main(int argc, char **argv) {
self.assertEqual(foo_dep.get_link_args(), link_args)
# Ensure include args are properly quoted
incdir = PurePath(prefix) / PurePath('include')
cargs = ['-I' + incdir.as_posix()]
self.assertEqual(foo_dep.get_compile_args(), cargs)
cargs = ['-I' + incdir.as_posix(), '-DLIBFOO']
# pkg-config and pkgconf does not respect the same order
self.assertEqual(sorted(foo_dep.get_compile_args()), sorted(cargs))
def test_array_option_change(self):
def get_opt():

@ -1,5 +1,9 @@
#include <simple.h>
#ifndef LIBFOO
#error LIBFOO should be defined in pkgconfig cflags
#endif
int main(int argc, char *argv[])
{
return simple_function() == 42 ? 0 : 1;

@ -43,7 +43,8 @@ pkgg.generate(
name : 'libfoo',
version : libver,
description : 'A foo library.',
variables : ['foo=bar', 'datadir=${prefix}/data']
variables : ['foo=bar', 'datadir=${prefix}/data'],
extra_cflags : ['-DLIBFOO'],
)
pkgg.generate(

Loading…
Cancel
Save