When setting CMake Tools to be configurationProvider for the C++ extension, does it make all other properties in c_cpp_properties.json redundant?
Or will c_cpp_properties.json override the provider? Or the other way around?
Right now I have a c_cpp_properties.json with configs for Win and Mac with quite a few properties. I'm wondering if I can trim down a bunch of these to make the JSON simpler and reduce risk of duplicate information getting out of date.
cpptools prefers the "configurationProvider" over any other setting. The remaining settings are only used if the configurationProvider is unable to give a configuration for the source file you've opened in the editor.
Short story: You should be able to remove the majority of the other properties in c_cpp_properties.json if you are using "configurationProvider".
{
"name": "config",
"configurationProvider": "vector-of-bool.cmake-tools"
}
Ah, I thought compileCommands was needed as well. I thought it was added by the extension when I told the extension to setup my CMake project.
I'll try to strip it down. (Though I did try that earlier but I had problems with intellisense not picking up all include paths. But maybe that was because I had a mix of overlapping settings.)
(btw, that should be ms-vscode.cmake-tools now, right?)
(btw, that should be
ms-vscode.cmake-toolsnow, right?)
The id is actually just a string that the extension sends to identify itself. We recommend that extensions use their publisher id, but it is not required and cpptools doesn't check it against the publisher id. With that in mind, we haven't changed the id to ms-vscode.cmake-tools yet because we didn't want to break developers who were already configured to use vector-of-bool.cmake-tools.
We added code to cpptools to do the mapping between provider ids, but haven't released it to everyone yet. We will change the id in CMake Tools once we see a critical mass of customers has moved to the version of cpptools that supports both.
Didn't realize that string was unrelated. (I'd opened a PR to update the docs for that: https://github.com/thomthom/vscode-docs/pull/1. Though maybe it would be worth while with a comment to explain why this string differ from the extension ID.)
I'll try to play around more with configurationProvider tomorrow, see if I can simplify my setup and whether I still see the issues I thought I had earlier with intellisense.
Do I understand it correctly that if I set configurationProvider I won't need separate config per platform?
Do I understand it correctly that if I set
configurationProviderI won't need separate config per platform?
That is correct.
That worked like a charm. And I realised that I was getting confused about compileCommands because the C/C++ extension asked to use compile_commands.json.
I need to open an issue against cpptools to delay showing that compileCommands prompt. CMake Tools won't register as a config provider until you successfully configure the project. Sometimes this takes a while.
I'm seeing prompts from CMake Tools when loading a VSCode project asking if I want to configure - even when the project is already configured and unchanged since last it was open. It appear to take a couple of seconds before everything is loaded.
If you have a repro you can share, please open a new issue and we'll take a look.
cpptools prefers the "configurationProvider" over any other setting
Where do I set cppStandard and intelliSenseMode then?
@intractabilis you don't set them. If you use configurationProvider, CMake Tools should get them from your CMake project and tell cpptools for you.
This is exactly what I am asking: how in CMake project I set cppStandard and intelliSenseMode? What in particular CMake Tools is looking for in the project to pass this information down to cpptools? I am especially curious about intelliSenseMode, what should I do to set it to gcc-arm for example?
You should be able to set gcc-arm by selecting the appropriate "Kit" or toolchain.

There was a bug related to the msvc toolset and arm that we recently fixed, but gcc should be working.
Setting the standard should be doable with the CMAKE_CXX_STANDARD variable.
https://stackoverflow.com/questions/42834844/how-to-get-cmake-to-pass-either-std-c14-c1y-or-c17-c1z-based-on-gcc-vers
Thanks!
Setting CMAKE_CXX_STANDARD doesn't work correctly, because it messes up command line. For example, my clang is configured to use -std=c++20 by default. If I add CMAKE_CXX_STANDARD=20 to CMakeLists.txt, cmake adds -std=gnu++2a to the build command line. I don't need cmake to mess up with my clang defaults.
@intractabilis - setting CMAKE_CXX_EXTENSIONS OFF will make CMake use -std=c++20 instead of -std=gnu++2a. Would that work for you?
Thank you, it's good to know. However, this is not the point. The point is that cmake enforces the standard in the command line, while the command line is fine, what is needed is just to say to Intellisense what standard is used.
Most helpful comment
I need to open an issue against cpptools to delay showing that compileCommands prompt. CMake Tools won't register as a config provider until you successfully configure the project. Sometimes this takes a while.