vscode-cmake-tools
vscode-cmake-tools copied to clipboard
Allow alterations to the $PATH in an environmentSetupScript to take effect before searching for the CMake executable
Discussed in https://github.com/microsoft/vscode-cmake-tools/discussions/2299
Currently the extension searches for the CMake executable before environmentSetupScript
is evaluated. In the event that the setup script alters the $PATH, those changes won't be in effect when looking for the CMake binary.
+1 for this feature -- I use a python virtual environment to install my desired cmake version, and I'd either need to activate that virtual environment (preferred) or modify the path to point cmake-tools at the correct binary.
+1, There's unfortunately no documentation on environmentSetupScript
and I expected it to run before the first call to cmake.
I would not call this a clean solution, but this work for me on both Windows and Linux : I created a single script that can act both as batch and bash script. This script activate my virtual environment then call CMake.
.vsode/settings.json
"cmake.cmakePath": "${workspaceFolder}/.vscode/run-cmake.cmd",
.vscode/run-cmake.cmd
:<<BATCH
@echo off
set SOURCE=%~dp0
call %SOURCE%..\activate.bat
@echo on
call cmake %*
@echo off
exit /b
BATCH
SOURCE=$( realpath $( dirname -- "${BASH_SOURCE[0]}"; ); )
source $SOURCE/../activate.sh
cmake "$@"
@jfchenier Thanks for you workaround. But I still get problem.
Now I create .vscode/run-cmake.cmd, just same as you and
linux-64 - ssh /buildarea/ashi/tmp_ws/z_cmake_failed_prj1/.vscode> /buildarea/ashi/tmp_ws/z_cmake_failed_prj1/.vscode/run-cmake.cmd Usage
cmake [options]
Specify a source directory to (re-)generate a build system for it in the current working directory. Specify an existing build directory to re-generate its build system.
Run 'cmake --help' for more information.
linux-64 - ssh /buildarea/ashi/tmp_ws/z_cmake_failed_prj1/.vscode> ./run-cmake.cmd -version cmake version 3.23.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Seems fine now, But still get error like
Bad CMake executable: "/buildarea/ashi/tmp_ws/z_cmake_failed_prj1/.vscode/run_cmake.cmd". Check to make sure it is installed or the value of the "cmake.cmakePath" setting contains the correct path
+1, It is better to support environmentSetupScript and then call to cmake.
@alan-wr
On some Linux distro, I had to add #!/bin/bash
At the top of the run-cmake.cmd
script. This cause an error message on Windows, but it can be ignored. Adding this might solve your issue.
@jfchenier
Typo error
run_cmake.cmd from ".vscode/setting.json"
And run-cmake.cmd from ".vscode/run-cmake.cmd" file.
"_" and "-".
Anyway, fine now.
Many Thanks.
Sorry @bobbrow, can I ask if there's currently any plan to support this feature?
From what I'm seeing I think this has to be modified to run environmentSetup script first: https://github.com/microsoft/vscode-cmake-tools/blob/aa2139531f2ff2bb390ab12beb56025f9efa27b4/src/paths.ts#L228
for reference here's how it's done for the kits: https://github.com/microsoft/vscode-cmake-tools/blob/aa2139531f2ff2bb390ab12beb56025f9efa27b4/src/kit.ts#L646
I don't know basically anything about typescript so I can't make a PR myself
@Pesc0 @adrianinsaval and others, thanks for all of your comments. I am placing this on our backlog and we will work to prioritize this issue among our other bugs and requests. Thank you!
In the meantime, please up-vote this issue to let us know that it is important to you.
Thank you!
@gcampbell-msft This would really simplify setting up the debugger for my VS code environment. I currently have a workaround but it is a hack.
@benmcmorran Hey seeing you postponed this issue for the next release, can I please ask if it could get tackled for the current release cycle? Over at FreeCAD we are kinda depending on this to finally have proper integration with VSCode, and the work on that has been stalled for months now. Many thanks in advance :)