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

Can prepend PATH in kit? #460

Closed
pbl-pw opened this issue Jun 10, 2018 · 13 comments
Closed

Can prepend PATH in kit? #460

pbl-pw opened this issue Jun 10, 2018 · 13 comments
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: configure Feature: settings
Milestone

Comments

@pbl-pw
Copy link

pbl-pw commented Jun 10, 2018

I have two mingw : C:\mingw32 and C:\mingw64
so not good to add both to PATH.
Add below to cmake-kits.json but not work:

	{
		"name": "mingw64",
		"compilers": {
			"CC": "c:/mingw64/bin/gcc.exe",
			"CXX": "c:/mingw64/bin/g++.exe"
		},
		"environmentVariables": {
			"PATH":"C:\\mingw64\\bin;${env:PATH}"
		}
	}
@vector-of-bool
Copy link
Contributor

@KoeMai is this related to modifying the path for mingw?

@KoeMai
Copy link
Contributor

KoeMai commented Jun 10, 2018

yes, i belongs to #449

@tehKaiN
Copy link

tehKaiN commented Aug 12, 2018

I need this for totally separate reasons.

I'm using https://github.com/bebbo/amiga-gcc to compile stuff for Amiga, but on windows it only builds on Cygwin. So I was until now using it with following build command using make:

		{
			"label": "make",
			"type": "shell",
			"command": "make",
			"problemMatcher": "$gcc",
			"group": "build",
			"options": {
				"env": {
					"PATH": "path/to/cygwin/bin;path/to/amiga_gcc/bin;%PATH%"
				}
			}
		}

Right now I'd like to make a transition to CMake using toolchain file. So I did:

	{
		"name": "m68k",
		"toolchainFile": "path/to/m68k.cmake"
	}

but it appears there are no means to set cygwin & compiler paths into PATH so that *nixy stuff isn't visible all over my OS outside working on this project.

@vector-of-bool vector-of-bool added the enhancement an enhancement to the product that is either not present or an improvement to an existing feature label Aug 14, 2018
@vector-of-bool vector-of-bool added this to the Backlog milestone Aug 14, 2018
@vector-of-bool
Copy link
Contributor

Looks like a separate prependPath and/or appendPath option to kits might be of good use...

@bjude
Copy link

bjude commented Oct 9, 2018

I'd like this too, but as a workspace local option not just for kits.
Often i need to expose specific versions of libraries to a cmake program that will cause big headaches to simple add to the system PATH variable and currently i'm at a loss for how to do that.

Adding the below modifies the path, but seems to prevent the kits adding the required paths (the MSVC paths aren't added if i do this)
"cmake.configureEnvironment": { "PATH": "${env:Path};C:/code/libFoo" }

@lygstate
Copy link
Contributor

Don't know if this issue are fixed

@vector-of-bool
Copy link
Contributor

prependPath and appendPath may still be useful. The existing MinGW kit's PATH variable might be rewritten in terms of this.

@lygstate
Copy link
Contributor

Leave this open.

@lygstate
Copy link
Contributor

Refer to #596

@pm-ur
Copy link

pm-ur commented Mar 25, 2021

I'd like this too, but as a workspace local option not just for kits.
Often i need to expose specific versions of libraries to a cmake program that will cause big headaches to simple add to the system PATH variable and currently i'm at a loss for how to do that.

Adding the below modifies the path, but seems to prevent the kits adding the required paths (the MSVC paths aren't added if i do this)
"cmake.configureEnvironment": { "PATH": "${env:Path};C:/code/libFoo" }

I also need to prepend some directories to the path when building using CMake. Encountering thee same issue that the MSVC paths are overridden if I specify the environments from cmake tools settings. Options for prepending or appending to existing variables would certainly be helpful.

The only thing I can do right now is to launch VS Code from a batch file or something that sets up an environment. This prevents me from using other VS Code features like opening workspace via right click menu in explorer.

@andreeis
Copy link
Contributor

@pm-energid, we have a fix for the path override problem that will be included in 1.7. Also there is the possibility to run a script when setting your kit (try "environmentSetupScript" in the definition of the kit you are using).
Even before we release 1.7 you can try the latest vsix of this extension, for example from here (look at the vsix link at the bottom): https://github.com/microsoft/vscode-cmake-tools/actions/runs/687275647.
Let us know if all these unblock you.

@pm-ur
Copy link

pm-ur commented Mar 26, 2021

@pm-energid, we have a fix for the path override problem that will be included in 1.7. Also there is the possibility to run a script when setting your kit (try "environmentSetupScript" in the definition of the kit you are using).
Even before we release 1.7 you can try the latest vsix of this extension, for example from here (look at the vsix link at the bottom): https://github.com/microsoft/vscode-cmake-tools/actions/runs/687275647.
Let us know if all these unblock you.

Hi Andreea,

How should I try this newer version? I installed it, but don't see any option changes. Are the changes in behavior of how CMake environment, CMake build environment, CMake configure environment work?

Also, I didn't see anything about "environmentSetupScript" in the CMake Tools documentation. I do see some references to it in certain issues though.

My requirement is similar to: #1463, where I want to use binaries from custom builds (as a result of CMake configuration step). Expansion in cmake.environment works better for me as I can update the workspace file after CMake configuration step finishes. Ideally, I'd want to run a script before every call to cmake. :)

Thanks,
Piyoosh

Update: Looks like expansion in the environment settings works now. So, I can specify my PATH as <new path>;${env:PATH}.

@andreeis
Copy link
Contributor

@pm-energid, yes we should explain environmentSetupScript. Our documentation needs some updates in general.

Regarding execution of a script before any call to cmake. Does it really have to be every time before any cmake invocation (configure, build, ...etc) or once at load time is enough, as long as the environment changes are persisted throughout the entire VSCode session? environmentSetupScript is meant to keep the environment effects of running it for all the future configure/build operations during the current VSCode session. Let us know if that's not the case (it would be a bug that we'd want to fix).

I am glad that trying the latest vsix confirmed that the environment settings expansion bug was fixed. So, are you completely unblocked and your scenario works or there's something else you'd like us to address?

philippewarren added a commit to philippewarren/vscode-cmake-tools that referenced this issue Mar 14, 2023
philippewarren added a commit to philippewarren/vscode-cmake-tools that referenced this issue Mar 15, 2023
philippewarren added a commit to philippewarren/vscode-cmake-tools that referenced this issue Mar 18, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2023
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 Feature: settings
Projects
None yet
Development

No branches or pull requests

9 participants