# Help me in creating .d and .o for list of c files in cmake

**URL:** <https://discourse.cmake.org/t/help-me-in-creating-d-and-o-for-list-of-c-files-in-cmake/9562>\
**Category:** Code\
**Created:** [December 5, 2023, 1:55pm UTC](https://discourse.cmake.org/t/help-me-in-creating-d-and-o-for-list-of-c-files-in-cmake/9562 "2023-12-05T13:55:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![deeptii1410](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/eb9ed0/32.png) [@deeptii1410](https://discourse.cmake.org/u/deeptii1410)\
**Post date:** [December 5, 2023, 1:55pm UTC](https://discourse.cmake.org/t/help-me-in-creating-d-and-o-for-list-of-c-files-in-cmake/9562/1 "2023-12-05T13:55:24Z")

</div>

I try to create .d and .o files from c files using minGW makefiles. I have list of header files in different folder path. Confused whether to use include\_directories / target\_include\_directories

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [December 6, 2023, 12:58pm UTC](https://discourse.cmake.org/t/help-me-in-creating-d-and-o-for-list-of-c-files-in-cmake/9562/2 "2023-12-06T12:58:30Z")

</div>

Prefer `target_include_directories` as this applies to targets and can be inherited via usage requirements. `include_directories` adds the paths to all targets defined after it in the same and any subdirectories.

Syntax:

```cmake
target_include_directories(
  name_of_target_needing_include
  PUBLIC
    /path/needed/by/this/target/and/any/using/it # (for example, headers from here are included by your own public headers)
  PRIVATE
    /path/needed/only/by/this/target # (only included in sources or private headers)
  INTERFACE
    /path/needed/only/by/using/targets # (not needed by your sources, but are in your headers; generally only used for header-only targets)
)

```
