6

I am trying to use CMake in the command line on Windows 10. This used to work before, but I don't know why it doesn't work anymore. I installed new version of CMake and added the path to the Environment Variables. However, when trying to use it in Powershell like this: cmake -G "Visual Studio 14 2015 Win64" ..

it shows this error:

cmake : The term 'cmake' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

This is my Environment Variables:

enter image description here

I have added C:\Program Files\CMake\bin to the end of the path variable. I have also tried uninstall and reinstalling CMake, but didn't help.

Hadi GhahremanNezhad
  • 2,377
  • 5
  • 29
  • 58
  • 2
    what is in the path variable as seen in your powershell session? use `$env:Path -split ';'` to see what the value is in the session. – Lee_Dailey Dec 27 '19 at 17:00
  • @Lee_Dailey I saw it. It is exactly the same , except the last line `C:\Program Files\CMake\bin` is not in the powershell path. – Hadi GhahremanNezhad Dec 27 '19 at 17:25
  • then you need to add it BEFORE the PoSh session starts OR you need to add it _inside_ the current PoSh session. it really otta be part of your permanent path, so i would add it prior to starting powershell. – Lee_Dailey Dec 27 '19 at 17:27
  • @Lee_Dailey I added it to the permanent path before starting the PowerShell, but did not work. However, adding it ***inside*** the current PowerShell works. Maybe I should reinstall PowerShell. – Hadi GhahremanNezhad Dec 27 '19 at 17:29
  • 1
    reinstalling PoSh will NOT change the problem. [*grin*] you can make a permanent change from inside your PoSh session for that account by using the dotnet method shown here >>> `Environment.SetEnvironmentVariable Method (System) | Microsoft Docs — https://learn.microsoft.com/en-us/dotnet/api/system.environment.setenvironmentvariable?view=netframework-4.8` << – Lee_Dailey Dec 27 '19 at 17:53

1 Answers1

5

In current powershell session, you have to add the path to path environment variable. You have to use this:

$env:path += ";C:\Program Files\cmake\bin"
cmake -g ...
Wasif
  • 14,755
  • 3
  • 14
  • 34