...

/

Discovering Legacy Packages With FindPkgConfig

Discovering Legacy Packages With FindPkgConfig

Let's learn how to find and use 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. It is often available on Unix-like systems (although it works on macOS and Windows too).

Discovering legacy package

pkg-config is slowly being phased out by other, more modern solutions. A question arises here: should we invest our 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, we probably won't need it.

  • If there's no find-module (or it doesn't work for our library) and a PkgConfig .pc file is all that library provides, just use what's readily available.

Many (if not most) libraries have embraced CMake and provide a package config-file in current versions. If we're not publishing our solution and we control the environment, use find_package() and don't worry about legacy versions. ...