Build with CMake presets
Instead of using CMake kits for building projects, you can set build options in a CMakePresets.json file. Create the presets file in the format described in CMake: cmake-presets(7) and store it in the project's root directory.
Qt Extension for VS Code reads and uses all the fields that the CMake extension supports.
Configure presets
The following configure presets tell CMake to do a Debug build with the Qt version that you set in CMAKE_TOOLCHAIN_FILE:
{
"version": 3,
"configurePresets": [
{
"name": "debug",
"displayName": "my debug configure preset",
"binaryDir": "build-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_TOOLCHAIN_FILE": "C:\Qt\6.9.1\msvc2022_64\lib\cmake\Qt6\qt.toolchain.cmake"
}
]
}The following sections describe alternative ways of using CMake presets to register Qt.
CMake variables
Instead of CMAKE_TOOLCHAIN_FILE, you can also use one of the following keys:
CMAKE_PREFIX_PATHQt5_DIRQt6_DIRQt6_ROOTQT_ADDITIONAL_PACKAGES_PREFIX_PATHQT_PACKAGES_PREFIX_PATHQt_ROOTQTDIR
CMake configure presets
Instead of CMake keys, you can use the toolchainFile CMake configure preset to set the path to the toolchain file:
{
"version": 3,
"configurePresets": [
{
"name": "debug",
"displayName": "my debug configure preset",
"binaryDir": "build-debug",
},
"toolchainFile": "/home/user/vcpkg/scripts/buildsystems/vcpkg.cmake"
]
}Qt vendor presets
You can also use Qt vendor presets to register the Qt installation.
To set the path to the Qt installation, use VSCODE_QT_INSTALLATION:
"vendor": {
"qt-cpp": {
"VSCODE_QT_INSTALLATION": "C:\Qt\6.9.1\msvc2022_64"
}
}To set the path to qtpaths, select VSCODE_QT_QTPATHS_EXE:
"vendor": {
"qt-cpp": {
"VSCODE_QT_QTPATHS_EXE": "C:\Qt\6.9.1\msvc2022_64\bin\qtpaths"
}
}See also Register Qt installations.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.