# Install EXPORT for multiple build types

**URL:** https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023
**Category:** Code
**Created:** [April 15, 2020, 11:24am UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023 "2020-04-15T11:24:31Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![abroekhuis](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abroekhuis/32/524_2.png) [@abroekhuis](https://discourse.cmake.org/u/abroekhuis)
#### Post date: [April 15, 2020, 11:24am UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/1 "2020-04-15T11:24:31Z")

</div>

Hi all,

I have a project for which I can do a Debug and Release build. Using a debug postfix, libraries are named differently. So I though I could do a make install in both build directories, resulting in a mixed installation.

I also have an install(EXPORT …) task, and this generates a Targets-Release or Targets-Debug, depending on the build type. But when installing the second build type, the files for the first build type are removed. So I always end up with either a Targets-Release, or Targets-Debug, and not both.

What is the proper way to do a Release and Debug installation so that I can have both build types installed and useable? I kinda expected the Targets-\* files to be left, especially since the Targets.cmake file itself seems to be the same for the different build types.

TiA!

---

<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: [April 15, 2020, 1:34pm UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/2 "2020-04-15T13:34:19Z")

</div>

I think the only way, right now, is to use a multi-config generator. 3.17 has Ninja-Multi you can use. I don’t know the history of removing all the old `targets.cmake` files off-hand, but it might be something we can address.

Cc: @kyle.edwards

---

<div class="post-metadata">

### Author: ![abroekhuis](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abroekhuis/32/524_2.png) [@abroekhuis](https://discourse.cmake.org/u/abroekhuis)
#### Post date: [April 15, 2020, 2:27pm UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/3 "2020-04-15T14:27:00Z")

</div>

Thanks for the reply,

I’m now looking at ninja, although a more generic fix would be nice to have!

Question regarding multi-config, previously I could use a BUILD\_TYPE variable to get the buildtype, but that doesn’t work now. How can I differentiate between the different configs? In my case I generate a file, which has config specific content (lib name with debug postfix vs regular lib name).

Perhaps I’m looking in the wrong place, but I can’t find a simple answer…

Again, thanks!

---

<div class="post-metadata">

### Author: ![Angew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/angew/32/229_2.png) [@Angew](https://discourse.cmake.org/u/Angew)
#### Post date: [April 15, 2020, 2:54pm UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/4 "2020-04-15T14:54:21Z")

</div>

> [@abroekhuis](#):
>
> Question regarding multi-config, previously I could use a BUILD\_TYPE variable to get the buildtype, but that doesn’t work now. How can I differentiate between the different configs? In my case I generate a file, which has config specific content (lib name with debug postfix vs regular lib name).

For this bit, what you’re looking for is most likely the command [`file(GENERATE)`](https://cmake.org/cmake/help/latest/command/file.html#generate)

---

<div class="post-metadata">

### Author: ![abroekhuis](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abroekhuis/32/524_2.png) [@abroekhuis](https://discourse.cmake.org/u/abroekhuis)
#### Post date: [April 15, 2020, 2:59pm UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/5 "2020-04-15T14:59:39Z")

</div>

I am already using file(GENERATE …) with INPUT and OUTPUT. But get an error

```
CMake Error in bundles/remote_services/discovery_configured/CMakeLists.txt:
   Evaluation file to be written multiple times with different content. This
   is generally caused by the content evaluating the configuration type,
   language, or location of object files:

```

The documentation mentions to use ${CONFIG} to have a config specific output, but I must be doing something wrong…

---

<div class="post-metadata">

### Author: ![Angew](https://discourse.cmake.org/user_avatar/discourse.cmake.org/angew/32/229_2.png) [@Angew](https://discourse.cmake.org/u/Angew)
#### Post date: [April 15, 2020, 3:07pm UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/6 "2020-04-15T15:07:24Z")

</div>

> [@abroekhuis](#):
>
> The documentation mentions to use ${CONFIG} to have a config specific output, but I must be doing something wrong…

It’s mentioning using `$<CONFIG>`, not `${CONFIG}`. The former is a generator expression, the latter is a CMake variable expansion. If you post your use of `file(GENERATE)`, someone might be able to help (I have to go offline now, but I can take a look tomorrow if it’s not resolved by then).

---

<div class="post-metadata">

### Author: ![abroekhuis](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abroekhuis/32/524_2.png) [@abroekhuis](https://discourse.cmake.org/u/abroekhuis)
#### Post date: [April 15, 2020, 5:54pm UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/7 "2020-04-15T17:54:35Z")

</div>

Ah yes, now I see, my bad. This works!

Many thanks!

---

<div class="post-metadata">

### Author: ![abroekhuis](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abroekhuis/32/524_2.png) [@abroekhuis](https://discourse.cmake.org/u/abroekhuis)
#### Post date: [April 15, 2020, 6:14pm UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/8 "2020-04-15T18:14:15Z")

</div>

Hi Ben,

Petr helped me with getting ninja going, but I’d still like to see this work with Makefiles as well. Any feedback/ideas on the targets.cmake behaviour are still welcome!

---

<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: [April 15, 2020, 6:39pm UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/9 "2020-04-15T18:39:03Z")

</div>

I suggest filing an issue about the `-targets.cmake` removal being unconditional. Maybe some control can be given over that behavior somehow.

---

<div class="post-metadata">

### Author: ![abroekhuis](https://discourse.cmake.org/user_avatar/discourse.cmake.org/abroekhuis/32/524_2.png) [@abroekhuis](https://discourse.cmake.org/u/abroekhuis)
#### Post date: [April 20, 2020, 7:20am UTC](https://discourse.cmake.org/t/install-export-for-multiple-build-types/1023/10 "2020-04-20T07:20:55Z")

</div>

Somehow I ended up with different configs for my release and debug build. This triggered the deletion of the Targets file.

See issue: [https://gitlab.kitware.com/cmake/cmake/-/issues/20589](https://gitlab.kitware.com/cmake/cmake/-/issues/20589)

So making the config the same again makes it all work as expected!
