# Miss target\_include\_directories

**URL:** <https://discourse.cmake.org/t/miss-target-include-directories/11702>\
**Category:** Code\
**Tags:** os:windows\
**Created:** [September 17, 2024, 2:56am UTC](https://discourse.cmake.org/t/miss-target-include-directories/11702 "2024-09-17T02:56:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sea_sea/32/4025_2.png) [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Post date:** [September 17, 2024, 2:56am UTC](https://discourse.cmake.org/t/miss-target-include-directories/11702/1 "2024-09-17T02:56:33Z")

</div>

[https://simpleitk.readthedocs.io/en/master/link\_CppCMake\_docs.html](https://simpleitk.readthedocs.io/en/master/link_CppCMake_docs.html)

The project is not used target\_include\_directories  
I am confuse about when to use the target\_include\_directories

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [September 17, 2024, 5:47am UTC](https://discourse.cmake.org/t/miss-target-include-directories/11702/2 "2024-09-17T05:47:25Z")

</div>

Use `target_include_directories` if you need to add a path to header files, that is not a part of any linked targets.

In the example you mentioned, I suspect the `SimpleITK_LIBRARIES` actually contains a list of CMake targets to link, not libraries (like \*.so, or \*.a). CMake targets carry the information about include directories with them, thus there’s no need to use `target_include_directories`.

---

<div class="post-metadata">

**Author:** ![Sea\_Sea](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sea_sea/32/4025_2.png) [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Post date:** [September 20, 2024, 4:20am UTC](https://discourse.cmake.org/t/miss-target-include-directories/11702/3 "2024-09-20T04:20:52Z")

</div>

Do you have the method to know whether the target include directories with them?

or  
for a good cmake project, we should use target\_include\_directories and target\_link\_libraries? Both are necessary

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [September 20, 2024, 6:19am UTC](https://discourse.cmake.org/t/miss-target-include-directories/11702/4 "2024-09-20T06:19:35Z")

</div>

If you have a target, it carries the include directories with it (unless there’s a bug).  
I simply test if the oldest version of the required lib that I want to support in the oldest CMake version I want to support provides a correct target. If not - make adjustments.

This is basically something you need to test for each dependency separately. Rule of the thumb would be: if there’s a target - use it. First when that does not work you need to start thinking 😉
