With 3.17, you should be able to pass --debug-find
to have CMake output why it is finding the package in question.
CMAKE_PREFIX_PATH
is not searched recursively, but specific paths are used relative to each entry to find other paths. For example, lib
is looked in for find_library
calls. If it is finding a foo-config.cmake
package under it, it is in a path that is search specifically by CMake under the prefixes it is given.