What's the default search path for find_package(<package>) function while using cmake?

cmake

Solution

Turning my comment into an answer

If you have to melt it down the "single most important" path it would be CMake's own module path containing pre-shipped `Find...` modules.

The most important global variable variable to point CMake to custom paths would be `CMAKE_MODULE_PATH`.

If you want to see which directories CMake is search in your case just call

 cmake -D CMAKE_FIND_DEBUG_MODE=ON ..

The whole "search algorithm" is documented in `find_package()` command documentation:

Search paths specified in cmake-specific cache variables. This can be skipped if `NO_CMAKE_PATH` is passed:

CMAKE_PREFIX_PATH
CMAKE_FRAMEWORK_PATH
CMAKE_APPBUNDLE_PATH

Search paths specified in cmake-specific environment variables. This can be skipped if `NO_CMAKE_ENVIRONMENT_PATH` is passed:

<package>_DIR
CMAKE_PREFIX_PATH
CMAKE_FRAMEWORK_PATH
CMAKE_APPBUNDLE_PATH

Search paths specified by the `HINTS` option. Hard-coded guesses should be specified with the `PATHS` option.

Search the standard system environment variables. This can be skipped if `NO_SYSTEM_ENVIRONMENT_PATH` is passed:

PATH

Search paths stored in the CMake User Package Registry. This can be skipped if `NO_CMAKE_PACKAGE_REGISTRY` is passed or by setting the `CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` to `TRUE`.

Search cmake variables defined in the Platform files for the current system. This can be skipped if `NO_CMAKE_SYSTEM_PATH` is passed:

CMAKE_SYSTEM_PREFIX_PATH
CMAKE_SYSTEM_FRAMEWORK_PATH
CMAKE_SYSTEM_APPBUNDLE_PATH

Search paths stored in the CMake System Package Registry. This can be skipped if `NO_CMAKE_SYSTEM_PACKAGE_REGISTRY` is passed or by setting the `CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` to `TRUE`.

Search paths specified by the `PATHS` option. These are typically hard-coded guesses.

Problem

I would also like to know the default variables which are set when `find_package(<package>)` finds `<package>` in Linux (Ubuntu) ?

Original source