mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.62k stars 1.63k forks source link

How to add boost dependency to the pkg-config file? #620

Open 0x1997 opened 8 years ago

0x1997 commented 8 years ago

For example

boost_date_time = dependency('boost', modules: ['date_time'])
jemalloc = dependency('jemalloc')

a_sp = subproject('a')
a_lib = a_sp.get_variable('lib')

libmylib = shared_library('mylib', 'mylib.cpp',
    include_directories: inc,
    dependencies: [
        boost_date_time,
        jemalloc,
        a_sp
    ],
    install: true
)

pkg_mod = import('pkgconfig')
pkg_mod.generate(
    name : 'mylib',
    filebase : 'mylib',
    version : meson.project_version(),
    description : 'My Lib',
    requires: ['jemalloc'],
    libraries : [
        libmylib,
        a_lib,
        boost_date_time     #  this doesn't work
    ],
)

The error message is Library argument not a library object.

nirbheek commented 8 years ago

Why did you close this bug? I think it's probably a good idea to add cross-dependency support to pkg-config libraries since it only requires -L and -l flags.

0x1997 commented 8 years ago

@nirbheek As said on the wiki, the built-in generator is meant for basic use cases. And aside from boost, I also have a dependency on pthread. To add -pthread to the CFlags section, I'd better generate the pkg-config file manually with configure_files.

nirbheek commented 8 years ago

The wiki says that, but it's not very friendly to users that they try the pkg-config module and then it doesn't work for many use-cases outside the trivial. It also requires them to know the exact format of the pkg-config file, which is an anti-pattern that Autotools encouraged and we shouldn't.

I think the pkg-config module should be fixed to work for 99% of cases, and we really should make it work better. But it's up to Jussi.

0x1997 commented 8 years ago

@nirbheek I agree. I'm totally open to a more powerful pkg-config generator.

KrullBorg commented 8 years ago

+1; i need also libraries found with compiler.find_library (in my case math library)

tschoonj commented 4 years ago

Hi, having run into the problem of getting boost into a pig-config file recently myself, I was wondering if there has been any development on this?

Is there currently a way to extract the cflags and libs from the boost dependency object so I can add them to the extra_cflags and libraries options of generate().

Thanks!