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

I’ve followed the instructions for creating relocatable export packages as defined in the documenation at this location []

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.

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.

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.

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.

@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 :slight_smile:.

We have logic such as the following (adapted from Importing and Exporting Guide)

Click to expand pseudo-code
set(TARGETS_CMAKE "${TARGET}Targets.cmake")
set(TARGETS_CONFIG "${TARGET}Config.cmake")

# Control where items are installed too
    EXPORT ${TARGET}_Targets



# Generate the top-level Config.cmake file for find_package

# 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

# install the top-level Config.cmake file
    DESTINATION cmake)

Where our file is:

Click to view

message(STATUS "Package @CMAKE_FILE_BASE@ found at ${PACKAGE_PREFIX_DIR}")


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…

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…

I got it now.

install(EXPORT ${TARGET}_Targets
    CONFIGURATIONS Release        # <<<<<<< THIS LINE

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

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