You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ Improvements:
42
42
- Set the `VSCODE_CMAKE_TOOLS` environment variable for all spawned subprocesses so that `CMakeLists.txt` can detect when CMake is run from VS Code. [#4233](https://github.com/microsoft/vscode-cmake-tools/issues/4233)
43
43
- Ensure kit `environmentVariables` expansions (for example, `${env:PATH}` or `${env.PATH}`) use the environment produced by `environmentSetupScript`, so script-updated values are preserved during expansion. [#4091](https://github.com/microsoft/vscode-cmake-tools/issues/4091)
44
44
- Honor `debugger.workingDirectory` from the CMake File API when debugging a target, so that the `DEBUGGER_WORKING_DIRECTORY` target property is used as the debugger working directory. [#4595](https://github.com/microsoft/vscode-cmake-tools/issues/4595)
45
+
- Honor the active kit environment (including `environmentSetupScript` and kit-defined environment variables) when resolving `cmake.cmakePath` in kits mode, enabling `auto`/`cmake` mode discovery and `${env:...}` substitutions to use kit-provided environment values. [#4475](https://github.com/microsoft/vscode-cmake-tools/issues/4475)
45
46
- Add `cmake.removeStaleKitsOnScan` setting to optionally remove stale compiler kits from the kit picker after a "Scan for Kits" when they are no longer rediscovered. This is useful after compiler upgrades that leave older versions outside `PATH`. Set `"keep": true` in a kit entry to prevent automatic removal. [#3852](https://github.com/microsoft/vscode-cmake-tools/issues/3852)
46
47
- Add `pr-readiness` Copilot skill to verify PRs have a descriptive title, meaningful description, and a properly formatted CHANGELOG entry. [#4862](https://github.com/microsoft/vscode-cmake-tools/pull/4862)
Copy file name to clipboardExpand all lines: docs/kits.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -190,6 +190,40 @@ The following additional options may be specified:
190
190
> The absolute path to a script or a string in form of `"script path" [arg ...]`that modifies/adds environment variables for the kit.
191
191
Uses `call` on Windows and `source` in `bash` otherwise.
192
192
193
+
### Kit environment and CMake executable resolution
194
+
195
+
When using kits mode (not CMake Presets), the active kit's environment—including variables set via `environmentSetupScript` and `environmentVariables`—influences how CMake Tools resolves the CMake executable path:
196
+
197
+
1. **Auto discovery (`cmake.cmakePath: auto` or `cmake`):**
198
+
The active kit's `PATH` is searched first before falling back to the system `PATH`. This allows a kit's setup script to prepend a custom directory containing a CMake binary, and that binary will be discovered and used.
199
+
200
+
2. **Environment variable substitution:**
201
+
If `cmake.cmakePath` uses `${env:VARIABLE_NAME}` syntax, the substitution resolves to values from the active kit's environment. For example, if a kit defines `MY_CMAKE_PATH` via `environmentVariables` or `environmentSetupScript`, you can set `"cmake.cmakePath":"${env:MY_CMAKE_PATH}/cmake"` and it will resolve using the kit-provided value.
202
+
203
+
**Example:**
204
+
205
+
In `.vscode/cmake-kits.json`, define the environment variable in the kit:
In `.vscode/settings.json`, reference the variable (do not define it here):
219
+
```json
220
+
{
221
+
"cmake.cmakePath": "${env:MY_CMAKE_PATH}/cmake"
222
+
}
223
+
```
224
+
225
+
When this kit is selected, `cmake.cmakePath` will resolve to `/custom/cmake/path/cmake` using the kit's environment variable. Environment variables are resolved from the active kit's context, not from workspace settings.
226
+
193
227
`description`
194
228
195
229
> A short description of the kit, which will appear next to its name in the selection menu.
// Force re-reading of cmake exe, this will ensure that the debugger capabilities are updated.
844
844
constcmakeInfo=awaitthis.getCMakeExecutable();
845
845
if(!cmakeInfo.isPresent){
846
-
voidvscode.window.showErrorMessage(localize('bad.executable','Bad CMake executable: {0}. Check to make sure it is installed or the value of the {1} setting contains the correct path',`"${cmakeInfo.path}"`,'"cmake.cmakePath"'));
846
+
// Do not show a popup here to avoid duplicate "Bad CMake executable" messages.
847
+
// The canonical user-facing error is shown when a command actually needs a driver
848
+
// and getCMakeDriverInstance() validates the executable.
847
849
telemetry.logEvent('CMakeExecutableNotFound');
848
850
}
849
851
@@ -1399,21 +1401,34 @@ export class CMakeProject {
1399
1401
}
1400
1402
1401
1403
asyncsetKit(kit: Kit|null){
1404
+
constpriorCMakePath=awaitthis.getCMakePathofProject();// used for later comparison to determine if we need to update the driver's cmake.
1402
1405
this._activeKit=kit;
1406
+
this.cachedCMakePathEnvironment=null;// Invalidate cache on kit change
1407
+
this.cachedCMakePathEnvironmentKit=null;
1403
1408
if(kit){
1404
1409
log.debug(localize('injecting.new.kit','Injecting new Kit into CMake driver'));
1405
1410
constdrv=awaitthis.cmakeDriver;// Use only an existing driver, do not create one
log.warning(localize('failed.to.compute.kit.env.for.cmake.path','Unable to evaluate the active kit environment while resolving cmake.cmakePath: {0}',e?.message||e));
0 commit comments