Is CMAKE_PREFIX_PATH recursively searched?

Hi!

I have a build where a system package config file is picked up even though it should not be. Having read the docs on what the config file search logic is, it could only possible find it if the search of <prefix> is recurisve, however this word does not appear in the docs anywhere.

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.

1 Like

Thanks @ben.boeckel, that was a lifesaver. I installed the 3.17-rc3 for this sole purpose and debugged the issue. It’s picking up the package config file, because of a bin path, which is then shaved off and made a system-wide base of config file lookup. This rule 5. of Search Procedure is intricate, to say the least.