[Bug] ${buildKitTargetArch} is 'unknown' for Visual Studio Kits
Brief Issue Summary
When using ${buildKitTargetArch} as Variable substitution in Build Directory (${workspaceFolder}/build/${buildKitTargetArch}) for Visual Studio Kits (tested in Visual Studio Professional 2019 and 2022 Release) the created folder is 'build/unknown' for all target architectures:
CMake Tools Diagnostics
{
"os": "win32",
"vscodeVersion": "1.103.1",
"cmtVersion": "1.22.7",
"configurations": [
{
"folder": "e:\\DeltaIdPlus\\OCR\\cpp",
"cmakeVersion": "4.1.1",
"configured": false,
"generator": "Visual Studio 17 2022",
"usesPresets": false,
"compilers": {}
}
],
"cpptoolsIntegration": {
"isReady": false,
"hasCodeModel": false,
"activeBuildType": "",
"buildTypesSeen": [],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 0,
"executablesCount": 0,
"librariesCount": 0,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": true
}
]
}
Debug Log
[main] Configuring project: cmaketest
[main] Saving open files before configure/build
[expand] expanded ${workspaceFolder}/build/${buildKitTargetArch}
[driver] Start configure
[driver] Running pre-configure checks and steps
[expand] expanded ${workspaceFolder}/build/${buildKitTargetArch}
[cmakefileapi-driver] Configuring using kit
[cmakefileapi-driver] Invoking CMake C:\Program Files\CMake\bin\cmake.exe with arguments ["-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE","--no-warn-unused-cli","-S","E:/cmaketest","-B","e:/cmaketest/build/unknown","-G","Visual Studio 17 2022","-T","host=x64","-A","x64"]
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.exe" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE --no-warn-unused-cli -S E:/cmaketest -B e:/cmaketest/build/unknown -G "Visual Studio 17 2022" -T host=x64 -A x64
[proc] with environment: {"windir":"C:\\WINDOWS"}
[cmake] CMake Warning (dev) in CMakeLists.txt:
[cmake] No project() command is present. The top-level CMakeLists.txt file must
[cmake] contain a literal, direct call to the project() command. Add a line of
[cmake] code such as
[cmake]
[cmake] project(ProjectName)
[cmake]
[cmake] near the top of the file, but after cmake_minimum_required().
[cmake]
[cmake] CMake is pretending there is a "project(Project)" command on the first
[cmake] line.
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] CMake Warning (dev) in CMakeLists.txt:
[cmake] cmake_minimum_required() should be called prior to this top-level project()
[cmake] call. Please see the cmake-commands(7) manual for usage documentation of
[cmake] both commands.
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: E:/cmaketest/build/unknown
[cmakefileapi-parser] Read reply folder: e:\cmaketest\build\unknown\.cmake\api\v1\reply
[cmakefileapi-parser] Found index files: ["cache-v2-601efeae2835cb0cd94f.json","cmakeFiles-v1-7c2c6f222de125540abf.json","codemodel-v2-abef0fa53ac10be45b2d.json","directory-.-Debug-d0094a50bb2071803777.json","directory-.-MinSizeRel-d0094a50bb2071803777.json","directory-.-Release-d0094a50bb2071803777.json","directory-.-RelWithDebInfo-d0094a50bb2071803777.json","index-2025-08-29T08-35-50-0185.json","target-ALL_BUILD-Debug-21b93cdebeda8b7eaff2.json","target-ALL_BUILD-MinSizeRel-21b93cdebeda8b7eaff2.json","target-ALL_BUILD-Release-21b93cdebeda8b7eaff2.json","target-ALL_BUILD-RelWithDebInfo-21b93cdebeda8b7eaff2.json","target-ZERO_CHECK-Debug-a51371a7c25be58acdcf.json","target-ZERO_CHECK-MinSizeRel-a51371a7c25be58acdcf.json","target-ZERO_CHECK-Release-a51371a7c25be58acdcf.json","target-ZERO_CHECK-RelWithDebInfo-a51371a7c25be58acdcf.json","toolchains-v1-07df8119f147e128ca2e.json"]
[kit] VS installation instance not found for kit "Visual Studio Professional 2022 Release - amd64" - (7649b17b). It is recommended you re-scan the kits and also remove any user-local entries that are not present anymore on the system.
[cache] Reading CMake cache file e:/cmaketest/build/unknown/CMakeCache.txt
[cache] Parsing CMake cache string
Additional Information
No response
Hi @gerardcarbo , thank you for reporting this issue. We tried to check this issue in Visual Studio Code v1.103.2 + CMake Tools v1.22.2. But we can't reproduce this issue. Could you help to take a look at it? If we missed something, please let us know. In order for us to investigate this further, could you please provide a sample project to us that can reproduce this issue? Thanks.
Hi @yanghhhhhhh, the problem is with ${buildKitTargetArch} (x86, x64, ...). With ${buildKit} works properly.
The output forder should be: build/x86, build/x64, ... as indicated in vscode-cmake-tools doc
Not buid/Visual Studio Professional 2022 Release - amd64 as you are getting
Now with ${buildKitTargetArch} it generates the folder 'unknown':
Hi @gerardcarbo , thanks for reporting issue here! Reproduced this issue on VS Code v1.103.2 + CMake Tools v1.22.8 release version. Repro Steps:
- Launch VS Code and open a test folder.
- Add a CMakeLists.txt and add the following code.
cmake_minimum_required(VERSION 3.10.0)
project(test VERSION 0.1.0 LANGUAGES C CXX)
- Open the command palette (F1 or Ctrl+Shift+P) run command: "Preferences: Open Settings (UI)".
- Set the "Cmake: Build Directory" option to "${workspaceFolder}/build/${buildKitTargetArch}".
- Open the command palette (F1 or Ctrl+Shift+P) run command: "CMake:configure".
- Observe the build output folder.
Details please see following video:
FYI: @gcampbell-msft