find_program: add a kwarg to skip searching the source dir #14119
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.
Unless search directories or overrides are provided,
find_program()
will by first search for an executable name in the source directory before trying to look it up via thePATH
environment variable. This can create issues in some projects where the executable exists in the source directory, but when the actual program should be looked up via PATH.While the obvious answer is to move out the given executable from the source directory it's not always feasible. Git for example supports being built with both Makefiles and Meson. In the former case, the resulting
git
executable will be put into the root level source directory. So if one then sets up Meson, we would find that binary instead of the system-provided binary.Add a new "skip_source_dir" kwarg to
find_program()
that allows the user to skip looking up programs via the source directory.