There is more

To summarize, when discovering packages there are four available routes:

  1. Use the CMake files <package>Config.cmake, <package>ConfigVersion.cmake, and <package>Targets.cmake provided by the package vendor and installed alongside the package itself in standard locations.
  2. Use a find-module for the desired package, whether shipped by CMake or a third party.
  3. Resort to pkg-config, as shown in this recipe.
  4. If none of these are viable, write your own find-module.

The four alternative routes have been ranked by relevance, but each approach has its challenges.

Not all package vendors provide CMake discovery files, but it is becoming more common. This is due to the fact that exporting CMake targets makes it very easy for third-party ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.