Prefer HINTS to PATHS in cmake find modules #6218
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For all the cmake
find_XYZ
utilities, there is a well defined ordered list in which CMake scans paths while searching. In this list, the paths passed via the argumentHINTS
appear early on. On the other hand, the paths passed via the argumentPATHS
appear quite late. After tryingHINTS
and before tryingPATHS
, CMake consider other options, among which we have/usr
directory on linux)find_package
, but can be quite annoying and hard to find, as we experienced with EKAT)CMake states that HINTS and PATHS should be used for different reasons. In particular, regarding
HINTS
it states thatHowever, the fact that
PATHS
is scanned after system folders makes its usage more complicated. SinceHINTS
andPATHS
are treated in the same way (meaning, CMake grabs the paths contained in them, and just scan them), from the practical point of view, the difference between the two is just the fact that one is considered much earlier than the other.The alternative would have been to add
NO_SYSTEM_PATH
to thefind_XYZ
calls, but it comes with a drawback: if on some testing machine (a shared workstation, perhaps) we do have a valid installation of a tpl in the system paths, we would not pick it up. UsingHINTS
, we can still pick up the system install (leaving HINTS empty).Fixes #6217 .