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.
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.
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.
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
@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…