• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include_directories
2-------------------
3
4Add include directories to the build.
5
6.. code-block:: cmake
7
8  include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...])
9
10Add the given directories to those the compiler uses to search for
11include files.  Relative paths are interpreted as relative to the
12current source directory.
13
14The include directories are added to the :prop_dir:`INCLUDE_DIRECTORIES`
15directory property for the current ``CMakeLists`` file.  They are also
16added to the :prop_tgt:`INCLUDE_DIRECTORIES` target property for each
17target in the current ``CMakeLists`` file.  The target property values
18are the ones used by the generators.
19
20By default the directories specified are appended onto the current list of
21directories.  This default behavior can be changed by setting
22:variable:`CMAKE_INCLUDE_DIRECTORIES_BEFORE` to ``ON``.  By using
23``AFTER`` or ``BEFORE`` explicitly, you can select between appending and
24prepending, independent of the default.
25
26If the ``SYSTEM`` option is given, the compiler will be told the
27directories are meant as system include directories on some platforms.
28Signalling this setting might achieve effects such as the compiler
29skipping warnings, or these fixed-install system files not being
30considered in dependency calculations - see compiler docs.
31
32Arguments to ``include_directories`` may use "generator expressions" with
33the syntax "$<...>".  See the :manual:`cmake-generator-expressions(7)`
34manual for available expressions.  See the :manual:`cmake-buildsystem(7)`
35manual for more on defining buildsystem properties.
36
37.. note::
38
39  Prefer the :command:`target_include_directories` command to add include
40  directories to individual targets and optionally propagate/export them
41  to dependents.
42