CMake 프리셋을 사용하여 빌드하기
프로젝트를 빌드할 때 CMake 키트를 사용하는 대신, ` CMakePresets.json ` 파일에 빌드 옵션을 설정할 수 있습니다. CMake: cmake-presets(7) 에 설명된 형식으로 프리셋 파일을 생성하고 프로젝트의 루트 디렉터리에 저장하십시오.
VS Code용 Qt 확장 프로그램은 CMake 확장 프로그램이 지원하는 모든 필드를 읽어와 사용합니다.
설치된 CMake Tools 확장 프로그램이 너무 오래되어 프리셋을 지원하지 않는 경우, VS Code용 Qt 확장 프로그램에서 경고가 표시됩니다. 이 경고를 끄려면 Qt settings 로 이동하십시오.
프리셋 구성
다음 구성 프리셋은 CMake가 CMAKE_TOOLCHAIN_FILE 에서 설정한 Qt 버전을 사용하여 디버그 빌드를 수행하도록 지시합니다:
{
"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"
}
]
}다음 섹션에서는 CMake 프리셋을 사용하여 Qt를 등록하는 다른 방법들을 설명합니다.
CMake 변수
CMAKE_TOOLCHAIN_FILE 대신 다음 키 중 하나를 사용할 수도 있습니다:
CMAKE_PREFIX_PATHQt5_DIRQt6_DIRQt6_ROOTQT_ADDITIONAL_PACKAGES_PREFIX_PATHQT_PACKAGES_PREFIX_PATHQt_ROOTQTDIR
CMake 구성 프리셋
CMake 키 대신, toolchainFile CMake configure 프리셋을 사용하여 툴체인 파일의 경로를 설정할 수 있습니다:
{
"version": 3,
"configurePresets": [
{
"name": "debug",
"displayName": "my debug configure preset",
"binaryDir": "build-debug",
},
"toolchainFile": "/home/user/vcpkg/scripts/buildsystems/vcpkg.cmake"
]
}Qt 벤더 프리셋
Qt 설치 위치를 등록하기 위해 Qt 벤더 프리셋을 사용할 수도 있습니다.
Qt 설치 경로를 설정하려면 VSCODE_QT_INSTALLATION 를 사용하십시오:
"vendor": {
"qt-cpp": {
"VSCODE_QT_INSTALLATION": "C:\Qt\6.9.1\msvc2022_64"
}
}qtpaths 의 경로를 설정하려면 ' VSCODE_QT_QTPATHS_EXE'을 선택하십시오:
"vendor": {
"qt-cpp": {
"VSCODE_QT_QTPATHS_EXE": "C:\Qt\6.9.1\msvc2022_64\bin\qtpaths"
}
}© 2026 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.