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 the `PATH` 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. Signed-off-by: Patrick Steinhardt <ps@pks.im>pull/14119/head
parent
a86476c57c
commit
f33120eaca
7 changed files with 54 additions and 7 deletions
@ -0,0 +1,6 @@ |
||||
## `find_program()` can optionally skip searching the source directory |
||||
|
||||
When given an executable name without any overrides, the `find_program()` |
||||
function searches the source directory for the executable before scanning |
||||
through `PATH`. This can now be skipped by passing `skip_source_dir: true` to |
||||
`find_program()` so that only `PATH` will be searched. |
@ -0,0 +1,3 @@ |
||||
#!/usr/bin/env python3 |
||||
|
||||
print('from source directory') |
@ -0,0 +1,9 @@ |
||||
project('skip_source_dir', |
||||
meson_version: '>=1.7.0', |
||||
) |
||||
|
||||
summary({ |
||||
'no args': run_command(find_program('executable.py'), capture: true, check: true).stdout(), |
||||
'skip_source_dir: true': run_command(find_program('executable.py', skip_source_dir: false), capture: true, check: true).stdout(), |
||||
'skip_source_dir: false': run_command(find_program('executable.py', skip_source_dir: true), capture: true, check: true).stdout(), |
||||
}, section: 'output') |
@ -0,0 +1,3 @@ |
||||
#!/usr/bin/env python3 |
||||
|
||||
print('from path') |
Loading…
Reference in new issue