install_subdir()

Installs the entire given subdirectory and its contents from the source tree to the location specified by the keyword argument install_dir.

(since 0.45.0, deprecated since 0.60.0) If the subdirectory does not exist in the source tree, an empty directory is created in the specified location. A newly created subdirectory may only be created in the keyword argument install_dir. There are a number of flaws with this method, and it was never intentionally designed to work this way, please use install_emptydir() instead.

Signature

# Installs the entire given subdirectory and its contents from the
void install_subdir(
  str subdir_name,     # The sub-directory to install

  # Keyword arguments:
  exclude_directories : array[str]        # An array of directory names that should not be installed
  exclude_files       : array[str]        # An array of file names that should not be installed
  follow_symlinks     : bool              # If true, dereferences links and copies their target instead
  install_dir         : str               # Where to install to
  install_mode        : array[str | int]  # Specify the file mode in symbolic format
  install_tag         : str               # A string used by the `meson install --tags` command
  strip_directory     : bool              # Install directory contents
)

Example

For a given directory foo:

foo/
  bar/
    file1
  file2

install_subdir('foo', install_dir : 'share', strip_directory : false) creates

share/
  foo/
    bar/
      file1
    file2

install_subdir('foo', install_dir : 'share', strip_directory : true) creates

share/
  bar/
    file1
  file2

install_subdir('foo/bar', install_dir : 'share', strip_directory : false) creates

share/
  bar/
    file1

install_subdir('foo/bar', install_dir : 'share', strip_directory : true) creates

share/
  file1

install_subdir('new_directory', install_dir : 'share') creates

share/
  new_directory/

Arguments

The function install_subdir() accepts the following positional arguments:

Name Type Description Tags
subdir_name str

The sub-directory to install

Finally, install_subdir() accepts the following keyword arguments:

Name Type Description Tags
exclude_directories array[str]

An array of directory names that should not be installed. Names are interpreted as paths relative to the subdir_name location.

(since 0.47.0)

exclude_files array[str]

An array of file names that should not be installed. Names are interpreted as paths relative to the subdir_name location.

install_dir str

Where to install to.

install_mode array[str | int]

Specify the file mode in symbolic format and optionally the owner/uid and group/gid for the installed files.

See the install_mode kwarg of install_data() for more information.

(since 0.47.0)

install_tag str

A string used by the meson install --tags command to install only a subset of the files. By default these files have no install tag which means they are not being installed when --tags argument is specified.

(since 0.60.0)

strip_directory bool

Install directory contents. If strip_directory=true only the last component of the source path is used.

(since 0.45.0)

default = false

The results of the search are