cmake Search and use installed packages, libraries and programs


  • find_package(pkgname [version] [EXACT] [QUIET] [REQUIRED])
  • include(FindPkgConfig)
  • pkg_search_module(prefix [REQUIRED] [QUIET] pkgname [otherpkg...])
  • pkg_check_modules(prefix [REQUIRED] [QUIET] pkgname [otherpkg...])


version (optional)Minimum version of the package defined by a major number and optionally a minor, patch and tweak number, in the format major.minor.patch.tweak
EXACT (optional)Specify that the version specified in version is the exact version to be found
REQUIRED (optional)Automatically throws an error and stop the process if the package is not found
QUIET (optional)The function won't send any message to the standard output


  • The find_package way is compatible on all platform, whereas the pkg-config way is available only on Unix-like platforms, like Linux and OSX.

  • A full description of the find_package numerous parameters and options can be found in the manual.

  • Even though it is possible to specify many optional parameters such as the version of the package, not all Find modules properly uses all those parameters. If any undefined behaviour occur, it could be necessary to find the module in CMake's install path and fix or understand its behaviour.