Does CPM work with CMakePresets? #493
Replies: 3 comments
-
Not sure I understand the problem 100%, but would setting the |
Beta Was this translation helpful? Give feedback.
-
Hello, I've got the same initial question. |
Beta Was this translation helpful? Give feedback.
-
@janos-ijgyarto, one way around having to have a separate configuration per compiler, generator, etc, is to use a multi config generator. Currently CMake supports two, When using a CMakePreset, build and test presents need to explicitly set With this setup, a single build step or workflow can be used and CPM will work as expected. If a multi-config generator cannot be used, then CPM cache will need to be set and shared across projects. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I have a somewhat complicated project setup, where I use CMakePresets combined with VS 2022 to manage different configurations (compiler, generator, platform, etc.) Because of how CMakePresets currently works, practically every one of the variables will require a whole different config preset, and thus a whole new configuration. For builds, this was not a problem, I could just set it so CMake's output and the binaries would be placed in a subfolder named after the config preset.
The problems began when I tried to combine this with FetchContent. Because of how it works, it wasn't possible to "share" the fetched libraries between different build configs. Ideally all I want is that I fetch the sources once, configure if needed (some libraries are header-only and don't even contain a CMakeLists.txt), and output the builds based on the current configuration (i.e make it behave as a package manager)
With how FetchContent works, however, I had to set the FetchContent base directory within the config-specific subfolder, which means I had to re-fetch every dependency for every different configuration (including when I just swap between debug and release). There is a thread on the CMake forums which illustrates the issue.
Does CPM offer a way around this? Or would I end up having the same issue?
Beta Was this translation helpful? Give feedback.
All reactions