@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.
I would love to contribute by implementing more preset, given the complex state of complier support, I wonder if we should first implement tool chain files with CMAKE_CXX_FLAGS_Debug_INIT as suggested by @bretbrownjr in the original create CMake preset PR.
The suggestion were:
You can use variables like CMAKE_CXX_FLAGS_Debug_INIT to tune what a Debug or Release build entails, for what it’s worth. It’s maybe a little nicer to use those variables instead of CMAKE_CXX_FLAGS. But not a huge deal.
We are already seeing sanitizers getting disabled across board in preset due to Apple Clang not supporting leak sanitizer. Plus, we may need to conditionally pass in different flags when library develops need cutting-edge compilers. Looks like right now is the best time to implement tool chain files for standard Debug/ Release config to avoid combination explosion (e.g. macos-gcc-debug).
I would suggest that sanitizer builds should be part of the normal dev workflow, not something that is CI only. Fixing an msan, asan, ubsan, tsan, rtsan …, bug is easiest right after you introduce it. Using asan and ubsan is my personal default for running tests. I don’t have any threads, and msan doesn’t compose well, although I should probably look again.
Note: this is a request to make sure what ever mechanisms we use in CI can be easily replicated on my laptop, not a requirement for anyone to change their personal software process. Or PSP if you’re fancy.
I will add a follow-up PR that: fails with a message if you are using gcc-* preset but the underlying compiler is apple clang (apple clang trying to disguise as gcc). I think this would be a significant enough use case to warren this check, but I don’t think we are detecting for every erroneous use.
I have created a prove of concept preset set at execution26.
I created the simples preset possible: a generic one with only tow workflowsdebug and release which works on each OS and with each toolchain. Just as demo and to have one.
The preset used in examplar will be more and more complex and unreadable!
It needs a workflow for each compiler and each build config type that should be supported.
At inplace_vector I developed an other one with more generic presets: