How to defer to to package's config file when it exists

I have a dependency that now installs a FooConfig.cmake package configuration, but previously I had to provide my own FindFoo.cmake file to find the dependency. I’d like to support older versions of the dependency, too. How can I use my FindFoo.cmake for older versions of the dependency, but use the installed FooConfig.cmake for newer versions?

This is a common pattern in CMake’s own find-modules. See FindCURL.cmake for an example of how we do it.