Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass command line arguments to CMake in VS Code?

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?

like image 267
yuexia_wrp Avatar asked Nov 20 '25 06:11

yuexia_wrp


1 Answers

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 ..
like image 187
Jan Gabriel Avatar answered Nov 22 '25 20:11

Jan Gabriel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!