It would be great to have support for setting environment variables via a script in addition to the current name-value lists (i.e. cmake.environment). This would help building against third-party libraries relying on shell/batch scripts to prepare the build environment (e.g., _Intel Performance Libraries_ - each library exposes a .sh/.bat script which sets relevant environment variables).
Sounds useful.
What sort of design/UX would you like to see?
I'm not really sure how it's usually done, though I was thinking about something like this:
"cmake.environmentScript": "source ${workspaceRoot}/path/to/script.sh"
and on Windows:
"cmake.environmentScript": "${workspaceRoot}\\path\\to\\script.bat"
Do you need the script only in the build step or in the configure step of Cmake?
I would prefer a preConfigure and preBuild Script step.
Is this script step multiproject specific, project specific, variant specific or kit specific?
I almost feel like this is getting close to the idea of another Kit type. The VS kits are generated in a similar manner (by invoking the vcvars batch files and collecting environment variables). Perhaps it belongs there?
Do you need the script only in the build step or in the configure step of Cmake?
Actually all of them:
<LIB>ROOT environment variables)CPATH/INCLUDE and LIBRARY_PATH/LIB environment variables)LD_LIBRARY_PATH/PATH environment variables)I think the environmentPreparationScript belongs to the kits. It is a additional preparation step before cmake is running. May be it needs to be added to each kit, because it is not a separate compiler more a extended compiler configuration.
I would also be interested in something like this. We already have a batch file that sets all necessary variables for our version of VS2017 build tools as well as some others we need internally. It would be great if we could just make cmake-tools use that as a kit.
Has there been any progress in that direction? What would be the direction forward?
I made a workaround script. Use at your own risk.
This will also be useful for Yocto SDKs: https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#sdk-running-the-sdk-environment-setup-script
The work-around script doesn't work as-is for it, since the setup script sources other files in as well.
This request was addressed by the addition of environmentSetupScript in the Kit schema in version 1.4.0.
Most helpful comment
This request was addressed by the addition of
environmentSetupScriptin the Kit schema in version 1.4.0.