# Object Files

**URL:** https://discourse.cmake.org/t/object-files/10846
**Category:** Code
**Created:** [May 13, 2024, 9:52am UTC](https://discourse.cmake.org/t/object-files/10846 "2024-05-13T09:52:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![RoachMan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@RoachMan](https://discourse.cmake.org/u/RoachMan)
#### Post date: [May 13, 2024, 9:52am UTC](https://discourse.cmake.org/t/object-files/10846/1 "2024-05-13T09:52:47Z")

</div>

Hi

I am trying to add google test to an existing project.

My test project needs to link against a file called Settings.obj which is an artifact of another project.

This a multi config visual studio application.

I have added this lines to include the Debug version

SET(OBJS

${CMAKE\_HOME\_DIRECTORY}/build/apps/Conifer/SeaLink.dir/Debug/Settings.obj

)

And the tell Cmake that they a generated

SET\_SOURCE\_FILES\_PROPERTIES(

${OBJS}

PROPERTIES

EXTERNAL\_OBJECT true

GENERATED true

)

Now this works but I need it to work for Release as well.

If I add the line

${CMAKE\_HOME\_DIRECTORY}/build/apps/Conifer/SeaLink.dir/Release/Settings.obj

Then generate the build tree the build fails as the Release/Settings.obj file is not found.

Is there a way around this?

Thanks

---

<div class="post-metadata">

### Author: ![Oodini](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/o/db5fbb/32.png) [@Oodini](https://discourse.cmake.org/u/Oodini)
#### Post date: [May 14, 2024, 2:07pm UTC](https://discourse.cmake.org/t/object-files/10846/2 "2024-05-14T14:07:41Z")

</div>

I guess the short time answer should be :

`SET(OBJS ${CMAKE_HOME_DIRECTORY}/build/apps/Conifer/SeaLink.dir/$<CONFIG>/Settings.obj)`  
See the [generator expressions](https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:CONFIG).

Else, your code is dirty because your hard-coded paths. You should review your CMake project.

PS: Please format your code samples.

---

<div class="post-metadata">

### Author: ![RoachMan](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/57b2e6/32.png) [@RoachMan](https://discourse.cmake.org/u/RoachMan)
#### Post date: [May 14, 2024, 3:03pm UTC](https://discourse.cmake.org/t/object-files/10846/3 "2024-05-14T15:03:09Z")

</div>

Thanks, I’ll check them out.
