include_directories.rst 1.5 KB

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