How to reinstall the latest cmake version?
Following the comments made on how to Install the latest CMake version and to post the answer for this question:
Ans:
This depends with Ubuntu OS version currently installed on your PC or Mac. If you have the following Ubuntu OS version then you have this CMake installed or that you could install and reinstall with "sudo apt-get install cmake". Even if you uninstall your version and try to reinstall later version.
Ubuntu 16.04 ships with cmake-3.5.1
Ubuntu 17.10 ships with cmake-3.9.1
Ubuntu 18.04 ships with cmake-3.10.2
Ubuntu 20.04 ships with cmake-3.16.3
Ubuntu 21.04 ships with cmake-3.18.4
Now if you have Ubuntu 16.04 installed and you want cmake-3.10, there is OS problem since you can only install and reinstalled cmake-3.5.1. To get cmake-3.10 or any other version, you have to download and install the package from https://packages.ubuntu.com/. Once you find the latest version of cmake .targz files, you have to build it yourself from the command line.
Configure CMake version in Visual Studio 2019
You can download the latest CMake from here to your system. To point Visual Studio to this latest version, you have to edit your CMakeSettings.json file. You must change the value of the cmakeExecutable
option to the installed location of the latest CMake version.
CMakeSettings.json:
...
"cmakeExecutable": "C:/path/to/new/cmake/executable",
...
How can I install CMake with PowerShell? (automatic installation)
ADD_CMAKE_TO_PATH=User
does what it should do, but there are two problems in your case:
You have to wait until
msiexec.exe
finishes. To do that, either pipe the result of the direct invocation to somewhere:msiexec.exe /i $exePath ADD_CMAKE_TO_PATH=User /qn | Out-Null
Or use
Start-Process
with the-Wait
parameter (which you already did):Start-Process msiexec.exe -ArgumentList "/i $exePath ADD_CMAKE_TO_PATH=User /qn" -Wait
You can read more about that in this Q&A.
When you update the environment variables of the
Machine
orUser
scope, existing processes will not inherit them into their existingProcess
scope. That's why your already running PowerShell process still does not knowcmake
after its installation. You can read more about that in this Q&A.You either have to start a really new PowerShell process (see above linked Q&A) or you have to reimport the environement variables of the
Machine
andUser
scope into yourProcess
scope:foreach($level in "Machine","User") {
[Environment]::GetEnvironmentVariables($level).GetEnumerator() | % {
# For Path variables, append the new values, if they're not already in there
if($_.Name -match 'Path$') {
$_.Value = ($((Get-Content "Env:$($_.Name)") + ";$($_.Value)") -split ';' | Select -unique) -join ';'
}
$_
} | Set-Content -Path { "Env:$($_.Name)" }
}This code is taken from this answer.
After that,
cmake --version
andGet-Command cmake
will work.
Side notes:
If
Start-Process
can findmsiexec.exe
, then the direct invocation should also work. Maybe you just had a typo, when trying that.A more PowerShelly way to download a file is:
Invoke-WebRequest -Uri https://github.com/Kitware/CMake/releases/download/v3.24.0/cmake-3.24.0-windows-x86_64.msi -UseBasicParsing -OutFile $exePath
Related Topics
Where Is Hardware Timer Interrupt
Call to Daemon in a /Etc/Init.D Script Is Blocking, Not Running in Background
Fast Concatenate Multiple Files on Linux
Pipe Output to Use as the Search Specification for Grep on Linux
How to List All Users in a Linux Group
One Core Exclusively for My Process
Ld: Using -Rpath,$Origin Inside a Shared Library (Recursive)
Linux Serial Port Listener and Interpreter
Application 'Appname' Failed to Start (Port 8080 Not Available) on Open Shift Node App
How to Record What Process or Kernel Activity Is Using the Disk in Gnu/Linux
Bash: Difference Between "Export K=1" VS. "K=1"
Apt-Get Error: Sub-Process /Usr/Bin/Dpkg Returned an Error Code (1)
Sighup for Reloading Configuration
Fastest Way to Tell If Two Files Have the Same Contents in Unix/Linux
Using Grep to Search for a String That Has a Dot in It