install_headers()

Installs the specified header files from the source tree into the system header directory (usually /{prefix}/include) during the install step. This directory can be overridden by specifying it with the install_dir keyword argument. If you just want to install into a subdirectory of the system header directory, then use the subdir argument. As an example if this has the value myproj then the headers would be installed to /{prefix}/include/myproj.

Please note that this can only install static files from the source tree. Generated files are installed via the install_dir: kwarg on the respective generators, such as custom_target() or `configure_file().

Signature

# Installs the specified header files from the source tree into the
void install_headers(
  file | str file...,  # Header files to install

  # Keyword arguments:
  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
  preserve_path   : bool              # Disable stripping child-directories from header files when installing
  subdir          : str               # Install to the `subdir` subdirectory of the default includedir
)

Example

For example, this will install common.h and kola.h into /{prefix}/include:

install_headers('common.h', 'proj/kola.h')

This will install common.h and kola.h into /{prefix}/include/myproj:

install_headers('common.h', 'proj/kola.h', subdir : 'myproj')

This will install common.h and kola.h into /{prefix}/cust/myproj:

install_headers('common.h', 'proj/kola.h', install_dir : 'cust', subdir : 'myproj')

This will install common.h into /{prefix}/include and kola.h into /{prefix}/include/proj/:

install_headers('common.h, 'proj/kola.h', preserve_path : true)

Arguments

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

Header files to install.

The function install_headers() accepts the following keyword arguments:

Name Type Description Tags
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)

preserve_path bool

Disable stripping child-directories from header files when installing.

This is equivalent to GNU Automake's nobase option.

(since 0.63.0)

default = false

subdir str

Install to the subdir subdirectory of the default includedir.

Incompatible with the install_dir kwarg.

The results of the search are