microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 456 forks source link

Add `envFile` property for dynamic injection of env vars before Configuration/Build #2265

Open SpaceIm opened 3 years ago

SpaceIm commented 3 years ago

Brief Issue Summary

Add an envFile property in settings.json to support dotenv files. This way we could inject env variables programmatically generated in a dotenv file by an upstream process. C/C++ extension provides this property for debugger configuration in launch.json.

Rational

It would be very useful when using conan for example. Indeed it is able to create a dotenv file setting PATH, LD_LIBRARY_PATH and DYLD_LIBRARY_PATH to build tools runtimes. For example let's say I want to compile SPIRV shaders through CMake:

Manual setting of env variables in current CMake Tools is not generic enough, conan paths are very specific to each dependency and complex (different for each version, os, arch, compiler). environmentSetupScript works but it's quite static and tied to kits (and I think that this property should not be in kits but settings, or there should be a way to add this in settings also). It means that you have to reload the kit after a modification of the script. It's not very intuitive. And it doesn't seem to work on Windows with .bat (https://github.com/microsoft/vscode-cmake-tools/issues/1463).

bobbrow commented 2 years ago

Thank you for the feature idea. We can't guarantee we will get to this soon, but if someone wants to look into this, we will accept a PR.

github-actions[bot] commented 12 months ago

This issue is now marked as 'stale-old' due to there being no activity on it for the past 720 days. Unless the 'stale-old' label is removed or the issue is commented on, this will be remain open for at least 14 days and then it may be closed. If you would like to make this issue exempt from getting stale, please add the 'stale-exempt' label.

daltonv commented 12 months ago

This would be very helpful for me too. I even have my projects get the CMake exe from Conan.