# How do I export (or import) just the Release version of an exeutable

**URL:** https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707
**Category:** Usage
**Created:** [October 21, 2022, 10:40pm UTC](https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707 "2022-10-21T22:40:55Z")
**Posts on this page:** 8
**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: [October 21, 2022, 10:40pm UTC](https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707/1 "2022-10-21T22:40:56Z")

</div>

I’ve followed the instructions for creating relocatable export packages as defined in the documenation at this location [[https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#exporting-targets](https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#exporting-targets)]

We have a tool that generates Release and Debug images of the executables and creates the cmake files that allow me to use `find_package` to get an imported exe target to use. **I LOVE THIS!**

However, I only want to use the Release version of the executables. We may want to use the Debug version if we have an issue to work out (rare). I only want a Release version.

But the code creates relocatable packages for R and D, and if we’re building a debug version and use the imported target, it uses the debug version of the executable.

I tried deleting the `fooTargets-debug.cmake` file that gets generated, and found that this will limit me to just Release. However, that feels hacky or inelegant.

What’s the correct way for me to limit this to just the Release instance of the executable.

P.S. I couldn’t believe how easy it was to transition to using exported executables. We’ve done libraries for awhile, and now tried executables and it was just trivial to take it to the next step. BEAUTIFUL.

We only have this one wrinkle.

---

<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: [October 25, 2022, 9:57pm UTC](https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707/2 "2022-10-25T21:57:11Z")

</div>

One way would be to have different export sets for the executables and the other targets. You can then just not install the export for the executables for the Release (or any other) configuration. This might need to be an option so that those only building Debug builds can skip the Release build that would otherwise be necessary.

---

<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: [October 25, 2022, 10:03pm UTC](https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707/3 "2022-10-25T22:03:13Z")

</div>

Thank you.

Sorry for the double post. I wasn’t able to find my original post, even under my profile listing.

I don’t understand your answer though.

What do you mean by “different export sets”?

I’m “importing” by using the find tool.

I export using the logic as explained from the documentation.

---

<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: [October 25, 2022, 10:47pm UTC](https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707/4 "2022-10-25T22:47:20Z")

</div>

When you export a target, the name you give to `EXPORT` is the “export set”. You’ll need different `export(EXPORT)` and/or `install(EXPORT)` commands you use to create the export sets.

---

<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: [October 27, 2022, 6:20pm UTC](https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707/5 "2022-10-27T18:20:27Z")

</div>

@ben.boeckel , thank you for your continued patience.

I don’t understand the changes you are suggesting.

I’ll expand on what I’m doing and understand, and perhaps this will illustrate the area where my knowledge needs a tune-up 🙂.

We have logic such as the following (adapted from [Importing and Exporting Guide](https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html))

> **Click to expand pseudo-code**
>
> ```auto
> set(TARGETS_CMAKE "${TARGET}Targets.cmake")
> set(TARGETS_CONFIG "${TARGET}Config.cmake")
> 
> # Control where items are installed too
> install(TARGETS ${TARGET}
> EXPORT ${TARGET}_Targets
> LIBRARY DESTINATION lib
> ARCHIVE DESTINATION lib
> RUNTIME DESTINATION bin
> PUBLIC_HEADER DESTINATION include)
> 
> ...
> 
> SET(CONFIG_IN "${CMAKESTVNPACKAGEMACROS_DIR}/CMakeStvnConfig.cmake.in")
> 
> # Generate the top-level Config.cmake file for find_package
> configure_package_config_file(
> "${CONFIG_IN}"
> "${PROJECT_BINARY_DIR}/${TARGETS_CONFIG}"
> INSTALL_DESTINATION cmake
> )
> 
> # Create the ***Targets.cmake file for find_package()
> # ***Targets.cmake is used in the .in file from
> # configure_package_config_file() step and install them to cmake
> install(EXPORT ${TARGET}_Targets
> FILE "${TARGETS_CMAKE}"
> DESTINATION cmake
> )
> 
> # install the top-level Config.cmake file
> install(FILES "${PROJECT_BINARY_DIR}/${TARGETS_CONFIG}"
> DESTINATION cmake)
> 
> ```

  

Where our `CMakeStvnConfig.cmake.in` file is:

> **Click to view CMakeStvnConfig.cmake.in**
>
> ```auto
> @PACKAGE_INIT@
> 
> message(STATUS "Package @CMAKE_FILE_BASE@ found at ${PACKAGE_PREFIX_DIR}")
> 
> include("${CMAKE_CURRENT_LIST_DIR}/@TARGET@Targets.cmake")
> check_required_components("@TARGET@")
> 
> ```

So this is all ‘logic’ that is executed on our Windows Platform when we build Release and Debug. From the above, I don’t understand what you mean by changing the export so it would skip the Debug export.

Granted, I could wrap this logic in a `CMAKE_CONFIG_TYPE` check that only executes for Release builds…

---

<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: [October 27, 2022, 8:02pm UTC](https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707/6 "2022-10-27T20:02:27Z")

</div>

I’m reading and playing more and I _ **think** _ I’m starting to understand. I’m looking at the `CONFIGURATIONS` parameter for the `install(EXPORT` signature…

---

<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: [October 27, 2022, 8:53pm UTC](https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707/7 "2022-10-27T20:53:06Z")

</div>

I got it now.

```auto
install(EXPORT ${TARGET}_Targets
    CONFIGURATIONS Release # <<<<<<< THIS LINE
    FILE "${TARGETS_CMAKE}"
    DESTINATION cmake
    )

```

Using the `CONFIGURATIONS Release` options with `install(EXPORT` appears to be doing what I want.

---

<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: [October 28, 2022, 12:34am UTC](https://discourse.cmake.org/t/how-do-i-export-or-import-just-the-release-version-of-an-exeutable/6707/8 "2022-10-28T00:34:35Z")

</div>

Ah, that is indeed a way more straightforward solution than what I had thought was required.
