[cmake-developers] [CMake] Debugging find_package() search behavior?

Brad King brad.king at kitware.com
Wed Aug 30 09:15:04 EDT 2017


On 08/29/2017 05:28 PM, Robert Dailey wrote:
> One other thing: Is there a way to make find_package() default to
> CONFIG mode? Right now it seems to search MODULE first, then CONFIG.
> But right now the only way to enable config is to explicitly use the
> CONFIG option or make sure CMake can't find a find module by
> manipulating CMAKE_MODULE_PATH.

It only searches in one mode.  The presence or non-presence of a
find module in CMAKE_MODULE_PATH is the way the mode is selected
if an explicit CONFIG option is not given.  There is an issue
about this here:

 https://gitlab.kitware.com/cmake/cmake/issues/16805

with an unfinished/expired MR:

 https://gitlab.kitware.com/cmake/cmake/merge_requests/768

Some find modules call `find_package(MyPackage CONFIG ...)` as
their first step if the external package may be found by either
method.

-Brad


More information about the cmake-developers mailing list