Debian Codegraph @

subprojects/meson-docs/docs/yaml/functions/add_languages.yaml

raw
1 name: add_languages
2 returns: bool
3 description: |
4 Add programming languages used by the project.
5
6 This is equivalent to having
7 them in the `project` declaration. This function is usually used to
8 add languages that are only used under some conditions.
9
10 Returns `true` if all languages specified were found and `false` otherwise.
11
12 If `native` is omitted, the languages may be used for either build or host
13 machine, but are never required for the build machine. (i.e. it is equivalent
14 to `add_languages(*langs*, native: false, required: *required*) and
15 add_languages(*langs*, native: true, required: false)`. This default behaviour
16 may change to `native: false` in a future Meson version.
17
18 example: |
19 ```meson
20 project('foobar', 'c')
21
22 if compiling_for_osx
23 add_languages('objc')
24 endif
25 if add_languages('cpp', required : false)
26 executable('cpp-app', 'main.cpp')
27 endif
28
29 # More code...
30 ```
31
32 varargs:
33 type: str
34 name: Language
35 description: The languages to add
36
37 kwargs:
38 required:
39 type: bool | feature
40 default: true
41 description: |
42 If set to `true`, Meson will halt if any of the languages
43 specified are not found. *(since 0.47.0)* The value of a
44 [`feature`](Build-options.md#features) option can also be passed.
45 native:
46 type: bool
47 since: 0.54.0
48 description: |
49 If set to `true`, the language will be used to compile for the build
50 machine, if `false`, for the host machine.
51