Visual Studio supports creating a CMakeSettings.json
file to keep cmake configurations when opening a CMake project, as described here.
This works perfectly well within the IDE itself, but if I want to automate my builds I cannot re-use the same CMakeSettings.json
file, I have to either parse it, then send the values to CMake with -DFOO=parsed_value
or keep two seperate build configurations (risking the error of them not being in sync).
The IDE must internally do this parsing anyway before it calls CMake so does anyone know if this build step is accessible outside the IDE?
Have a look at the suggestion here to create a settings.cmake which you can use to pre-populate the cache from the command line.
cmake -C <initial-cache>
They suggest a script to export the settings from a build folder to get you started.
I am trying to figure out this too as I would like to have single settings file for commandline, VS2017 and VSCode.
This might not be the answer you are looking for and I am not 100% sure, but CMakeSettings.json seems to be exclusive to Visual Studio 2017. I never came across CMakeSettings.json other than in context with VS2017. Even when you do an advanced google search with "CMakeSettings.json" -Visual -Studio -2017
, you won't get search results other than finding the filename on repositories in github for example. Searching CMakeSettings.json
or CMakeSettings
on cmake.org won't fetch any results either.
If parsing works, that might be the way to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With