@river landed CMake preset support in beman.exemplar and one can now build and test with cmake --workflow --preset gcc-debug
. This works great on Linux, but that’s about the only platform it supports right now.
The intent with these presets is that they are a way for developers to get up-and-running with a best-practice project quickly. The ideas is to eliminate a confusing array of choices. The gcc-debug preset, for example, has several sanitizers turned on . . . which is plainly a good practice for development.
The question remains, however, what should our list of presets be? Here are some ponderings about that.
One answer would be “we should have the most popular generator with the most popular compiler on each of the three major platforms”. That would lead to something like this:
Platform | Presets provided | Explanation |
---|---|---|
Linux | gcc-debug | Ninja MultiConfig, sanitizers, etc. |
gcc-release | RelWithDebugInfo, -O3, etc. | |
MacOS | xcode-debug | XCode, Apple clang w/ sanitizers, etc. |
xcode-release | RelWithDebugInfo, -O3, etc. | |
Windows | vs2022-debug | VS2022, TBD |
vs2022-release | TBD |
Why include release variants? When developing C++ libraries it is frequently important to measure performance and inspect the generated assembly of optimized code.
There are other ways we could cut this. We could, for example, provide presets for Ninja on every platform. That would be great for the Linux-centric folks, but will be a turn-off for people who primarily develop using the popular IDEs on those other platforms.
What about someone who wants to use clang on Windows or any other number of dizzying variations. The message would be that those folks can call CMake directly however they like or supply their own CMakeUserPresets.json
file. The goal here is to avoid surfacing complexity and capturing the 90% use case.