# Create .o and .d files based on .c files

**URL:** <https://discourse.cmake.org/t/create-o-and-d-files-based-on-c-files/9442>\
**Category:** Code\
**Created:** [November 16, 2023, 10:54am UTC](https://discourse.cmake.org/t/create-o-and-d-files-based-on-c-files/9442 "2023-11-16T10:54:12Z")\
**Posts on this page:** 4\
**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:** [November 16, 2023, 10:54am UTC](https://discourse.cmake.org/t/create-o-and-d-files-based-on-c-files/9442/1 "2023-11-16T10:54:13Z")

</div>

add\_library(lib\_trial OBJECT ${SOURCE\_FILES})  
target\_include\_directories(lib\_trial PRIVATE ${CMAKE\_SOURCE\_DIR}/include)

Migrating code from omake to cmake. Here my target creates .o and .d files.  
Try to achieve came in cmake  
But By above code lines i was able to create .cpp.obj and .cpp.obj.d files, my requirement is to create .o and .d files

---

<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:** [November 19, 2023, 2:33am UTC](https://discourse.cmake.org/t/create-o-and-d-files-based-on-c-files/9442/2 "2023-11-19T02:33:54Z")

</div>

Those are the files in question…why do you need the extensions to be something specific (especially the `.d` files)?

---

<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:** [November 21, 2023, 1:54am UTC](https://discourse.cmake.org/t/create-o-and-d-files-based-on-c-files/9442/3 "2023-11-21T01:54:43Z")

</div>

Im working on migration from omake to cmake. In omake, object files are created. Im trying to achieve same in cmake

---

<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:** [November 21, 2023, 3:06am UTC](https://discourse.cmake.org/t/create-o-and-d-files-based-on-c-files/9442/4 "2023-11-21T03:06:44Z")

</div>

`.obj` is the typical Windows convention for object files. Also, CMake keeps the source extension so that `foo.c` and `foo.cxx` don’t collide.
