We have to build for a lot of different OSes with lots of options (Rel/Dbg, SonarQube On/Off, Coverage On/Off…). The scripts to get the config command line are duplicated to:
yml (Azure-DevOps Build definition)
VS Code Settings (cmake-kits.json etc)
VS 2019 Settings (CMakeSettings.json)
bat/sh scripts
It is nearly impossible to keep those up to date. I also do not know how to make them look at “a single source of truth”.
This is a painful process and often result on “works on my machine” problems. How can I improve this?
CMake itself supports it of course, as do Visual Studio and Visual Studio Code/VSCode. I know the JetBrains team was working on it for CLion, but it doesn’t look like they’ve finished it yet. In any case, you can always use the cmake command line tool to generate the build tree from a preset.
That being said, it looks like your use cases (VS, VSCode, CI, and local command line) are all fully supported. CI can be done by running cmake with a --preset argument.
Similar to $env{}, except that the value only comes from the parent environment, and never from the environment field. This allows you to prepend or append values to existing environment variables. For example, setting PATH to /path/to/ninja/bin:$penv{PATH} will prepend /path/to/ninja/bin to the PATH environment variable. This is needed because $env{} does not allow circular references.