berndporr / iir1

DSP IIR realtime filter library written in C++
http://berndporr.github.io/iir1/
MIT License
627 stars 137 forks source link

make the pkg-config file work again #37

Closed eli-schwartz closed 2 years ago

eli-schwartz commented 2 years ago

In commit 45b0cbfe4c29c69bc06a967947e3b77c7e988038 the project was ported from autotools to cmake. In commit 512b6cba5ec7537953d24dbe546c488d657c68a1 autotools support was dropped.

During the port, the iir.pc file was hooked up to cmake, but unlike autotools, cmake doesn't have many variables hooked up for this (and needs quite a bit of help to correctly define install paths, especially). None of that was handled, however... and also the cmake setup only configured the file, but did not install it.

Add this support back.

Due to https://github.com/jtojnar/cmake-snips/#concatenating-paths-when-building-pkg-config-filesa third-party function needs to be included in order to correctly define prefix/libdir/includedir in the pkg-config file.

eli-schwartz commented 2 years ago

Found while reviewing a Meson port in https://github.com/mesonbuild/wrapdb/pull/445 and comparing Meson's builtin pkg-config generator output to the manually coded one here.

berndporr commented 2 years ago

pkgconfig is really for nerds directly creating makefiles. Do you think there is anybody doing that anymore? The other option would be to get rid of it for good? I don't mind but I haven't used pkgconfig for a decade I'd say.

eli-schwartz commented 2 years ago

pkgconfig is really for nerds directly creating makefiles.

That's utterly untrue.

It's a build-system agnostic tool that's equally usable in Makefiles, autotools, cmake, Meson, and a variety of other build systems.

This is because pkg-config actually tries to be generally useful. It came first. It's published by a standards and interoperability group and consequently saw wide adoption on Unix-based systems, where pkg-config is preferred regardless of build system. It is even ported to and usable on Windows. :)

-config.cmake is usable only in cmake, so perhaps you meant "only nerds don't use cmake"?

I'm afraid I disagree about that too, though. :) Like I said above, I discovered this while reviewing a Meson port of iir. Meson is (obviously) not cmake, and since it is not cmake, it doesn't contain a bit-for-bit identical reimplementation of cmake's turing-complete and partially undocumented embedded programming language, so it cannot natively use a -config.cmake file either. Meson instead relies on interoperability standards, which means pkg-config.

Without this pkg-config file, it is complicated and burdensome to detect iir as a dependency in another project that uses Meson (such as dosbox-staging). It can still be done by failing to find a cmake-built copy and falling back to downloading and building a private copy, of course (that's what the Meson port is for) but it's not especially ideal to do that.

(Yes, Meson is a modern build system, it is not "nerds with Makefiles".)

Disclaimer: I'm a core committer for Meson.

berndporr commented 2 years ago

I see. So the pkgconfig is used as input to meson. I've committed the changes. Just removed the subdir as it's just the only file. I have just a bad feel that subdirs call for trouble!

eli-schwartz commented 2 years ago

Thanks!

I have no opinion on the subdir issue, I merely know that most people use one for stuff like this so I used one by default. :)