Discovering legacy packages with FindPkgConfig
The problem of managing dependencies and discovering all the compile flags that they require is as old as C++ libraries themselves. There are many tools to deal with it, ranging from very small and minimal mechanisms to very versatile solutions offered as parts of buildsystems and IDEs. One of the (once very popular) tools is called PkgConfig (freedesktop.org/wiki/Software/pkg-config/). It is often available on Unix-like systems (although it works on macOS and Windows too).
pkg-config
is slowly being phased out by other more modern solutions. A question arises here – should you invest your time in supporting it? The answer is as usual – it depends:
- If a library is really popular, it might already have its find-module in CMake; in that case, you probably won't need it.
- If there's no find-module (or it doesn't work for your library) and a PkgConfig
.pc
file is all that library provides, just use...