ecbuild_find_package¶
Find a package and import its configuration.
ecbuild_find_package( NAME <name>
[ VERSION <version> [ EXACT ] ]
[ COMPONENTS <component1> [ <component2> ... ] ]
[ URL <url> ]
[ DESCRIPTION <description> ]
[ TYPE <type> ]
[ PURPOSE <purpose> ]
[ FAILURE_MSG <message> ]
[ REQUIRED ]
[ QUIET ] )
Options¶
- NAME : required
- package name (used as
Find<name>.cmakeand<name>-config.cmake) - VERSION : optional
- minimum required package version
- COMPONENTS : optional
- list of package components to find (behaviour depends on the package)
- EXACT : optional, requires VERSION
- require the exact version rather than a minimum version
- URL : optional
- homepage of the package (shown in summary and stored in the cache)
- DESCRIPTION : optional
- literal string or name of CMake variable describing the package
- TYPE : optional, one of RUNTIME|OPTIONAL|RECOMMENDED|REQUIRED
- type of dependency of the project on this package (defaults to OPTIONAL)
- PURPOSE : optional
- literal string or name of CMake variable describing which functionality this package enables in the project
- FAILURE_MSG : optional
- literal string or name of CMake variable containing a message to be appended to the failure message if the package is not found
- REQUIRED : optional
- fail if package cannot be found
- QUIET : optional
- do not output package information if found
Input variables¶
The following CMake variables influence the behaviour if set (<name> is
the package name as given, <NAME> is the capitalised version):
| DEVELOPER_MODE: | if enabled, discover projects parallel in the build tree |
|---|---|
| <name>_PATH: | install prefix path of the package |
| <NAME>_PATH: | install prefix path of the package |
| <name>_DIR: | directory containing the <name>-config.cmake file
(usually <install-prefix>/lib/cmake/<name>) |
The environment variables <name>_PATH, <NAME>_PATH, <name>_DIR
are taken into account only if the corresponding CMake variables are unset.
Usage¶
The search proceeds as follows:
- If any paths have been specified by the user via CMake or environment
variables as given above or a parallel build tree has been discovered in
DEVELOPER_MODE:
- search for
<name>-config.cmakein those paths only - search using
Find<name>.cmake(which should respect those paths) - fail if the package was not found in any of those paths
- search for
- Search for
<name>-config.cmakein theCMAKE_PREFIX_PATHand if DEVELOPER_MODE is enabled also in the user package registry. - Search system paths for
<name>-config.cmake. - Search system paths using
Find<name>.cmake. - If the package was found, and a minimum version was requested, check if
the version is acceptable and if not, unset
<NAME>_FOUND. - Fail if the package was not found and is REQUIRED.