Need a file which stores preset build options
It is often the case that a developer will want to save their build settings in a script so that they can easily redo the build if the tree gets deleted. Visual Studio has a file called CMakeSettings.json
which serves this purpose. However, the Visual Studio has a number of issues:
- It expects the platform name for Visual Studio generators to be at the end of the generator name. This is deprecated in CMake for generators for Visual Studio 2017 and below, and removed altogether for the 2019 generator. There is no way to make Visual Studio's expectations in this regard compatible with CMake without changes to Visual Studio.
- Some of the names in the JSON file are not consistent with CMake terminology.
- The file allows arbitrary arguments to be passed to CMake, which we don't want. Instead, we want explicit variable definitions, and booleans for the other flags.
- There is no version information, which hinders compatibility between versions of the file format.
To that end, I propose a new format inspired by CMakeSettings.json
, called CMakePresets.json
. It has most of the functionality of CMakeSettings.json
, with some simplifications, and fixes the issues listed above.
An example of what the new format will look like:
{
"version": 1,
"presets": [
{
"name": "VS2019",
"generator": "Visual Studio 16 2019",
"architecture": "x64",
"toolset": "Toolset",
"binaryDir": "${sourceDir}/build/vs2019",
"variables": [
{
"name": "VARIABLE_1",
"type": "STRING",
"value": "Hello world!"
},
{
"name": "VARIABLE_2",
"value": "Good bye!"
}
]
}
]
}
Edited by Kyle Edwards