I want to use the CMake Tools extension for developing a CMake project in Visual Studio Code.
I build the project in the command line with following command:
PS project\build> cmake -G"Visual Studio 14 2015 Win64" -DBOOST_ROOT=some\path -DQT_ROOT=another\path\ project\path
How can I set the same command with same options in the .cmaketools.json
file that I've under the .vscode
folder? I want to run it from inside the editor and, if possible, specify also the output folder instead of creating a build
folder inside my project one.
This is my actual .cmaketools.json
:
{
"variant": {
"label": "Debug",
"keywordSettings": {
"buildType": "debug"
},
"description": "Emit debug information without performing optimizations"
},
"activeEnvironments": [
"Visual C++ 14.0 - amd64"
]
}
Open the Command Palette (Ctrl+Shift+P) and run the CMake: Build command, or select the Build button from the Status bar. You can select which targets you'd like to build by selecting CMake: Set Build Target from the Command Palette. By default, CMake Tools builds all targets.
There are two different ways to configure with cmake ; one is to run cmake in a fresh directory passing some options on the command line, and the other is to run ccmake and use its editor to change options. For both, assume you are in a directory called debug and the IMP source is in a directory at ../imp .
CMake will use whatever path the running CMake executable is in. Furthermore, it may get confused if you switch paths between runs without clearing the cache. So what you have to do is simply instead of running cmake <path_to_src> from the command line, run ~/usr/cmake-path/bin/cmake <path_to_src> .
The .vscode\.cmaketools.json
file is only the "workspace cache" of Visual Studio Code - CMake Tools Extension. See their code:
/** * The workspace cache stores extension state that is convenient to remember * between executions. Things like the active variant or enabled environments * are stored here so that they may be recalled quickly upon extension * restart. */
I think what you want is a .vscode\settings.json
as described here with e.g. the following content:
{
"cmake.generator": "Visual Studio 14 2015 Win64",
"cmake.configureSettings": { "BOOST_ROOT": "some/path", "QT_ROOT": "another/path" }
}
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