Include fpm pkg-config libraries

I have noticed that one can insert pkg-config calls in the flags in the fpm.toml like:

imas.ifort.flags = “-vms -g $(pkg-config --cflags al-fortran xmllib)”
imas.ifort.link-time-flags = " $(pkg-config --libs al-fortran xmllib)"

And it does work.

Is there any other better way?

Does fpm extract pkg-config commands specifically? Otherwise this would be a big command injection vulnerability.

I’m guessing the right approach is to list those libraries in the link section:

[build]
link = ["al-fortran", "xmllib"]

You can pass the additional linker flags using export FPM_LDFLAGS=$(pkg-config --cflags al-fortran xmllib).

Yes of course, that was my first try.

But then you need a Makefile destroying the very idea that fpm is enough.

Look, with a Makefile you can even rebuild fpm.toml with all the linking flags with the correct values without resorting to inject shell scripts like I did before.

So, I’m looking for a solution that doesn’t involve setting fpm related shell variables specific to a single project.

I know that for netcdf and other particular libraries fpm can use pkg-config. Can that work for other libraries? And if yes, how?

Cheers,

Not to say that I like fpm, of course!