include_directories.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. include_directories
  2. -------------------
  3. Add include directories to the build.
  4. .. code-block:: cmake
  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. Signaling 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. .. |command_name| replace:: ``include_directories``
  25. .. include:: GENEX_NOTE.txt
  26. .. note::
  27. Prefer the :command:`target_include_directories` command to add include
  28. directories to individual targets and optionally propagate/export them
  29. to dependents.
  30. See Also
  31. ^^^^^^^^
  32. * :command:`target_include_directories`