-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature request] Run shell script before configuration happens #809
Comments
This might be easily doable by augmenting the Kits schema. Something similar is done to load environment variables for the MSVC compiler, but it's internal to the extension. |
I would also like to see this functionality - I'm using CMake to build some quite old code, in which some build steps are performed in bash scripts. Because I can't source the required rc file before calling CMake, these legacy steps crash the build. The CMake plugin is therefore not usable for these builds! |
I'd like this feature too. My particular use case, and I bet shared by many, is to activate a Conda enviroment before building, so I build with the right Python libraries (CMake itself respects activated envs as priority in FindPython). |
This feature was implemented and will be released with 1.4. |
CMake Tools 1.4.0 Beta is available on GitHub. Please try it out and let us know if you encounter any issues. |
This is essential for my workflow - I have to source several scripts to set up my build environment. This option worked great! Much easier than maintaining a very long list of environment variables. Thanks for adding it!! |
This fix is available in CMake Tools #1.4.0 which has been released. |
I cannot see the settings in the CMake Tools configuration. I tried to set it manually using |
From looking at the PR that introduced this functionality, it should be the "environmentSetupScript" property of a kit. Manually add that to the kit you are using, in the kits file json. Let us know how that goes. |
I tried setting the environmentSetupScript property of a kit in cmake-tools-kits.json and it didn't seem to work. Will the given be script be run or "sourced". My setup script contains many environment variables, therefore i would like vscode to effectively run "source " |
I am having the same issue where this property seems to have no effect. In case it is a run instead of source, I tried making a separate script to source what I need, and though it works when I call it manually it is not called when cmake is configured. |
Thank you! Actually, it works for me. I just edited
Then, whenever I switch to |
I then have a line of |
@duanyutong Try
|
@jheaff1 Thanks. I tried that in various ways and here are my observations.
It seems that executing cmake calls in the same kind of shell as the vscode integrated terminal would be a simpler and more general solution. |
I can confirm that it cannot source an external file. |
In my case the setup script must be sourced even before any attempt to run CMake. The CMake version installed on the remote is very old and not relevant - only the one set up by the script is. (Same is true for git and Python - only after sourcing the setup script they are of the correct version). My manual process is:
|
Same here, need to
|
I'm having issues with the parsing of environment variables. In my case the output of printenv contains these two lines
which causes Maybe the solution to this issue should be adjusted to parse multiline environment variables, or to actually execute the shell script, rather than only importing the environment... EDIT: Should I open a new issue instead of hoping to get a response from a closed one? |
Can it be a custom command to run before build? |
For those who came for ROS. ...
"cmake.configureSettings": {
"CMAKE_PREFIX_PATH": "/opt/ros/${ROS_DISTRO}"
},
... |
Can confirm that
Modules do not work and sourcing Intel OneAPI setvars.sh script fails with failing to parse variables. |
To be honest, I don't understand why this issue is closed? |
Ok, I sort of "solved" this issue to the point that I'm able to use VSCode to run scripts related to ROS. But in this case I have a set environment for all launches I will do in this VSCode. I also still don't know how it can be used to run VSCode remotely on the server with modules. Probably, the only case will be to add sourcing of modules into .bashrc and hope that when VSCode will try to connect to remote server it will also swallow all this sourcing from .bashrc Both ways are ugly and defenitely something I would like to avoid, but at least it gave me working environment I was looking for. |
Brief Issue Summary
When working in console I'm using shell script to source many environment variables required for configuration and build. I see there is a setting to add variables separately, but that's a long and often changing list - I'd love to be able to just pass the script name so it's run in the shell cmake-tools is working.
Expected:
Some setting like "pre-configuration commands".
Other Notes/Information
It might be worth mentioning that I'm working with SSH remote connection plugin, and cmake-tools is installed on remote machine.
The text was updated successfully, but these errors were encountered: