'VS Code CMake with several configurations

I am trying to contribute to a rather large (C++) project built with CMake, using the CMake Tools extension of Visual Studio Code.

I have several configurations I would like to develop, and have VS Code correctly find. At the moment, when the default configuration (or whatever I have in my build directory) doesn't use some file, then when it is #include'd I get red squiggles and the popup cannot open source file. If I change the configuration to include this, then this happens to other files. I start the build with a command like cmake -DSOME_OPTION=SOMETHING $SRC. I would like to have the workspace configured for all options possible (which can be found in the CMakeLists.txt file in src).

The most relevant question to this I found was this but it's not what I want by my understanding: this only handles the build type (release, debug etc) not options. Ideally there would be a way for CMake Tools to find all these options and configure itself (e.g. for projects with several options and many combinations of options), but if there's a workaround like the one linked, but for the build configurations/options I am talking about then that would be great too.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source