Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio, running cmakesettings.json from the command line

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?

like image 462
arynaq Avatar asked Jul 05 '18 13:07

arynaq


2 Answers

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.

like image 153
Richard Scott Avatar answered Sep 28 '22 17:09

Richard Scott


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.

like image 45
Tim L. Avatar answered Sep 28 '22 19:09

Tim L.