How it works

Find-modules typically follow a specific pattern:

  1. Check whether the user provided a custom location for the desired package.
  2. Use commands from the find_ family to search for known required components of the required package, that is, header files, libraries, executables, and so forth. We have used find_path to find the full path to a header file and find_library to find a library. CMake also offers find_file, find_program, and find_package. These commands have the following general signature:
find_path(<VAR> NAMES name PATHS paths)
  1. Here, <VAR> will hold the result of the search, if successful, or <VAR>-NOTFOUND if unsuccessful. NAMES and PATHS are names for the file CMake should look for and paths where the search should be ...

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.