Reputation: 354
I cloned a github repo. It has been set to built with cmake. I now want to build it in vscode, but I cannot find a place to set cmake command line argument.
When I execute cmake configure in vscode, 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 vscode?
Thank you very much!
Upvotes: 21
Views: 28582
Reputation: 243
In general, command line arguments can be given by specifying cmake.configureArgs
in the settings.json file, as shown by Jan Gabriel's answer.
But there is another setting (also in settings.json) specifically for -D arguments:
{
"cmake.configureSettings": {
"OPTIONA": "ON",
"OPTIONB": "ON"
}
}
See https://vector-of-bool.github.io/docs/vscode-cmake-tools/settings.html
Upvotes: 5
Reputation: 1206
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 ..
Upvotes: 30