Skip to content
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

Allow setting environment variables via shell/cmd script #288

Closed
emptyVoid opened this issue Dec 26, 2017 · 10 comments
Closed

Allow setting environment variables via shell/cmd script #288

emptyVoid opened this issue Dec 26, 2017 · 10 comments
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: configure
Milestone

Comments

@emptyVoid
Copy link

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).

@vector-of-bool vector-of-bool added enhancement an enhancement to the product that is either not present or an improvement to an existing feature feedback wanted! labels Dec 26, 2017
@vector-of-bool
Copy link
Contributor

Sounds useful.

What sort of design/UX would you like to see?

@emptyVoid
Copy link
Author

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"

@KoeMai
Copy link
Contributor

KoeMai commented Dec 26, 2017

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?

@vector-of-bool
Copy link
Contributor

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?

@emptyVoid
Copy link
Author

Do you need the script only in the build step or in the configure step of Cmake?

Actually all of them:

  • in the configure step: to detect the presence of a third-party library (e.g., Intel Performance Libraries set <LIB>ROOT environment variables)
  • in the build step: to pick up correct paths and/or compiler flags (e.g., Intel Performance Libraries set CPATH/INCLUDE and LIBRARY_PATH/LIB environment variables)
  • in the test step and debug: to launch an application built against a third-party library (e.g., Intel Performance Libraries set LD_LIBRARY_PATH/PATH environment variables)

@KoeMai
Copy link
Contributor

KoeMai commented Dec 27, 2017

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.

@no-realm no-realm added this to the Backlog milestone Mar 1, 2018
@mika-fischer
Copy link

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?

@MBetters
Copy link

MBetters commented Jul 1, 2019

I made a workaround script. Use at your own risk.

@danieroux
Copy link

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.

@bobbrow
Copy link
Member

bobbrow commented Jun 29, 2020

This request was addressed by the addition of environmentSetupScript in the Kit schema in version 1.4.0.

@bobbrow bobbrow closed this as completed Jun 29, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: configure
Projects
None yet
Development

No branches or pull requests

8 participants