I cloned a github repository. It has been set to built with CMake. I want to build it in VS Code, but I cannot find a place to set CMake command line arguments.
When I execute CMake configure in VS Code, it complains cannot find some headers or libs. I test in terminal, when I set -D arguments, this error can be solved.
So, I wonder is there a place to pass CMake command line arguments in VS Code?
Passing information onto CMake in VSCode happens in the settings.json file.
You need to install the CMake Tools extention first.
Then, open the command pallet in VSCode with Ctrl+Shift+P and type Open Settings.
Once selected, VSCode will show a settings.json file where you should add cmake.configureArgs e.g.:
{
"other":"settings",
"cmake.configureArgs": [
"-DOPTIONA=ON",
"-DOPTIONB=ON"
],
}
The cmake.configureArgs array of arguments is the same as you would normally use during a command-line cmake configure e.g.
cmake -DOPTIONA=ON -DOPTIONB=ON ..
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