add_languages()

Add programming languages used by the project.

This is equivalent to having them in the project declaration. This function is usually used to add languages that are only used under some conditions.

Returns true if all languages specified were found and false otherwise.

If native is omitted, the languages may be used for either build or host machine, but are never required for the build machine. (i.e. it is equivalent to add_languages(*langs*, native: false, required: *required*) and add_languages(*langs*, native: true, required: false). This default behaviour may change to native: false in a future Meson version.

Signature

# Add programming languages used by the project
bool add_languages(
  str Language...,  # The languages to add

  # Keyword arguments:
  native   : bool            # If set to `true`, the language will be used to compile for the build
  required : bool | feature  # If set to `true`, Meson will halt if any of the languages
)

Example

project('foobar', 'c')

if compiling_for_osx
  add_languages('objc')
endif
if add_languages('cpp', required : false)
  executable('cpp-app', 'main.cpp')
endif

# More code...

Arguments

The function accepts between 0 and infinity variadic arguments (Language...) of type str.

The languages to add

The function add_languages() accepts the following keyword arguments:

Name Type Description Tags
native bool

If set to true, the language will be used to compile for the build machine, if false, for the host machine.

(since 0.54.0)

required bool | feature

If set to true, Meson will halt if any of the languages specified are not found. (since 0.47.0) The value of a feature option can also be passed.

default = true

The results of the search are