# Can we change/set the export target name

**URL:** https://discourse.cmake.org/t/can-we-change-set-the-export-target-name/6357
**Category:** Usage
**Created:** [August 26, 2022, 6:33pm UTC](https://discourse.cmake.org/t/can-we-change-set-the-export-target-name/6357 "2022-08-26T18:33:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![JRR](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@JRR](https://discourse.cmake.org/u/JRR)
#### Post date: [August 26, 2022, 6:33pm UTC](https://discourse.cmake.org/t/can-we-change-set-the-export-target-name/6357/1 "2022-08-26T18:33:43Z")

</div>

Hello,

Is it possible to change a package export target’s name?

For example, if foo is my target to create a library I understand that

```auto
    install(TARGETS foo EXPORT foo_targets ...)

```

Will cause files:

1. `fooTargets.cmake`
2. `fooTargets-<CONFIG>.cmake`

to be generated.

This causes logic inside these files such as:

```auto
fooTargets.cmake:add_library(foo STATIC IMPORTED)

```

The problem is, we’ve us the target property `OUTPUT_NAME` on `foo`. So while `foo` is the target, the generated library would be `bar.lib`, etc.

My team wants their package searches to be for `bar` since that’s the library name, and there are reasons that the target cannot simply be `bar`.

What can you teach me for resolving this problem?

Thank you.

---

<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: [August 26, 2022, 8:48pm UTC](https://discourse.cmake.org/t/can-we-change-set-the-export-target-name/6357/2 "2022-08-26T20:48:52Z")

</div>

You can rename on export with the `EXPORT_NAME` target property. If you use a namespace (e.g., `foo::`) you can then make it show up as `foo::bar` with an `EXPORT_NAME bar` setting.

---

<div class="post-metadata">

### Author: ![JRR](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/ecccb3/32.png) [@JRR](https://discourse.cmake.org/u/JRR)
#### Post date: [August 26, 2022, 10:13pm UTC](https://discourse.cmake.org/t/can-we-change-set-the-export-target-name/6357/3 "2022-08-26T22:13:31Z")

</div>

Thank you @ben.boeckel !

I was able to follow your advice:

```auto
    set_target_properties(foo PROPERTIES EXPORT_NAME bar)
    install(TARGETS foo EXPORT foo_targets ...)

```

And this caused the autogenerated files to have the desired target of bar.

Thank you!
