find_package(... CONFIG) should fallback to Module mode if no Config file found
When The find_package
command invoked in Module mode, it'll fallback to Config if no Find<package>.cmake
file found.
On the other hand, if it is invoked in Config mode, and no <package>Config.cmake
file found, it'll fail.
This is pretty bad because the recommended way for library vendors is to ship Config files. We only want to write Find modules for libraries that do not provide Config file.
Now, there are some libraries that provide Config files in certain platforms, but not on others.
Such example is the CppUTest library that has a Config file on Mac OS through homebrew
, but not on Debian through apt-get
.
Yes, I know it should be reported as a bug to the maintainers, and I did.
But still - as more and more packages will have Config files, it makes more sense to first try and locate the Config file and then fallback to Find module.