You have several choices, depending on your exact requirements.
The CMake Tools extensions is a good choice, but it doesn't come with a GUI. If you want to use cmake-gui, you could still use it in your vscode CMake build directory, by executing cmake-gui <path_to_build_folder>
in the vscode terminal.
In case you need to run this command often, you could customize your vscode settings, for a better cmake-gui integration, by using the Command Runner extension, which allows to run custom shell commands. After installation add the following to your settings.json
:
"command-runner.commands": {
"cmake-gui": "cmake-gui ${workspaceFolder}/build"
}
and, if you like, a key binding to keybindings.json
{
"key": "ctrl+alt+1",
"command": "command-runner.run",
"args": { "command": "cmake-gui" }
}
Personally I would do none of the above methods, but just use ccmake
in the terminal.
All of the above describes how to change settings in the current existing build directory (which is usually created by CMake Tools on first launch). However, the settings will get lost if you switch to a different compiler or delete the CMake cache in any other way.
To persist your settings and configure CMake by default with your preferred configuration, you can add your CMake arguments to your vscode workspace settings (in ${workspaceFolder}/.vscode/settings.json
), e.g.
{
"cmake.configureArgs": [
"-DBUILD_WITH_TESTS=ON"
]
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…