aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/snippets/find-override.md
blob: ef3a4a2fdd8f3c88403c613039f53e63a7b1a75f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Can override find_program

It is now possible to override the result of `find_program` to point
to a custom program you want. The overriding is global and applies to
every subproject from there on. Here is how you would use it.

In master project

```meson
subproject('mydep')
```

In the called subproject:

```meson
prog = find_program('my_custom_script')
meson.override_find_program('mycodegen', prog)
```

In master project (or, in fact, any subproject):

```meson
genprog = find_program('mycodegen')
```

Now `genprog` points to the custom script. If the dependency had come
from the system, then it would point to the system version.

You can also use the return value of `configure_file()` to override
a program in the same way as above:

```meson
prog_script = configure_file(input : 'script.sh.in',
                             output : 'script.sh',
                             configuration : cdata)
meson.override_find_program('mycodegen', prog_script)
```