### Navigation

- index
- next |
- previous |
- CMake »
- 3.2.1 Documentation »
- cmake-properties(7) »

# INTERFACE_INCLUDE_DIRECTORIES

List of public include directories requirements for a library.

Targets may populate this property to publish the include directories required to compile against the headers for the target. The `target_include_directories()` command populates this property with values given to the `PUBLIC` and `INTERFACE` keywords. Projects may also get and set the property directly.

When target dependencies are specified using `target_link_libraries()`, CMake will read this property from all target dependencies to determine the build properties of the consumer.

Contents of `INTERFACE_INCLUDE_DIRECTORIES` may use “generator expressions” with the syntax `$<...>`. See the `cmake-generator-expressions(7)` manual for available expressions. See the `cmake-buildsystem(7)` -manual for more on defining buildsystem properties.

Include directories usage requirements commonly differ between the build-tree and the install-tree. The `BUILD_INTERFACE` and `INSTALL_INTERFACE` generator expressions can be used to describe separate usage requirements based on the usage location. Relative paths are allowed within the `INSTALL_INTERFACE` expression and are interpreted relative to the installation prefix. For example:

    target_include_directories(mylib INTERFACE
      $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/mylib>
      $<INSTALL_INTERFACE:include/mylib>  # <prefix>/include/mylib
    )

Note that it is not advisable to populate the `INSTALL_INTERFACE` of the `INTERFACE_INCLUDE_DIRECTORIES` of a target with paths for dependencies. That would hard-code into installed packages the include directory paths for dependencies as found on the machine the package was made on.

The `INSTALL_INTERFACE` of the `INTERFACE_INCLUDE_DIRECTORIES` is only suitable for specifying the required include directories of the target itself, not its dependencies.

That is, code like this is incorrect for targets which will be used to generate `cmake-packages(7)`:

    target_include_directories(mylib INTERFACE
      $<INSTALL_INTERFACE:${Boost_INCLUDE_DIRS};${OtherDep_INCLUDE_DIRS}>
    )

Dependencies must provide their own IMPORTED targets which have their own `INTERFACE_INCLUDE_DIRECTORIES` populated appropriately. Those IMPORTED targets may then be used with the `target_link_libraries()` command for `mylib`.

That way, when a consumer uses the installed package, the consumer will run the appropriate `find_package()` command to find the dependencies on their own machine and populate the IMPORTED targets with appropriate paths. See Creating Packages for more. Note that many modules currently shipped with CMake do not currently provide IMPORTED targets.

### Navigation

- index
- next |
- previous |
- CMake »
- 3.2.1 Documentation »
- cmake-properties(7) »