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.
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.
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…
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…
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).
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!