How to update cmake
How to update cmake
How to reinstall the latest cmake version?
9 Answers 9
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
As far as I know the best way to get the latest CMake version installed on any Linux is not by apt but using pip.
Remove the apt cmake and install the latest version from pip which can easily keep up-to-date.
Edit: As GNUton has pointed out, the following only works on Ubuntu 16.04 and 18.04(Checked on June 2019).
Now CMake developer team in Kitware Inc provides APT repositiory. It allows you to install latest CMake via apt-get.
If you are using a minimal Ubuntu image or a Docker image, you may need to install the following packages:
Obtain a copy of our signing key:
Add the repository to your sources list and update.
For Ubuntu Bionic Beaver (18.04):
For Ubuntu Xenial Xerus (16.04):
. Optional steps. See details in reference.
You can try the following steps that have worked for me on Ubuntu 18.04.3 LTS as OS of the NVIDIA jetson Nano to get the last version of cmake «cmake-3.14.0» from https://cmake.org/download/.
Delete the installed version in your system
Download cmake3.13.4 source
Execute the following commands in this order to build it
Verify the version is installed correctly
Following the comments made on how to Install the latest CMake version and to post the answer for this question:
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.
How do I install the latest version of cmake from the command line?
It is always retrying. Any thoughts?
Does anyone know what wrong I am doing here? Or is there any better way of installing latest version of cmake in my linux box?
12 Answers 12
The most common situation is when you want to install the latest version of cmake, but your Operating System’s repositories are not updated. For example, in my case I have a laptop running Ubuntu 16.04, and when I executed the command sudo apt install cmake the installed version was 3.5.1; instead of 3.23.2 which is the current version at cmake.org.
Teo, how can I get the latest version?
Well, we can install it by following one of these methods:
A. Using APT Repositories (Recommended for normal users)
Kitware now provides an APT Repository that supports Ubuntu 16.04, 18.04, and 20.04. So we can install it easily following these steps:
A-1. Uninstall the default version provided by Ubuntu’s package manager and configuration by using:
A-2. Prepare for installation
A-3. Obtain a copy of kitware’s signing key.
A-4. Add kitware’s repository to your sources list for Ubuntu Focal Fossa (20.04), Ubuntu Bionic Beaver (18.04) and Ubuntu Xenial Xerus (16.04).
A-5. As an optional step, is recommended that we also install the kitware-archive-keyring package to ensure that Kitware’s keyring stays up to date as they rotate their keys.
A-5.Note If running sudo apt update gets the following error:
Copy the public key 6AF7F09730B3F0A4 and run this command:
A-6. Finally we can update and install the cmake package.
B. Building and Installing (Recommended for developers)
For this approach you need to install the GCC tools:
B-1. Uninstall the default version provided by Ubuntu’s package manager as in A-1.
B-2. Go to the official CMake webpage, then download and extract the latest version. Update the version and build variables in the following command to get the desired version:
B-3. Install the extracted source by running:
B-4. Test your new cmake version.
C. Using binary files ( cmake-gui might not work well)
C-1. Uninstall the default version provided by Ubuntu’s package manager as in A-1.
C-3. Add the installed binary link to /usr/local/bin/cmake by running this:
C-4. Test your new cmake version as in B-4.
In 3.23.X the X represents the last part of the version that we defined as build. The build may change if cmake is updated. According to the official web page the Latest Release is 3.23.2. If you want the Previous Release 3.21.4 just replace the version and build parameters like this:
Observation
How to Install the Latest Version of CMake on Ubuntu 16.04/18.04 Linux
This post will guide you how to download and install the latest stable version of CMake on your Ubuntu Linux server. How do I install CMake tool from source code on Ubuntu Linux 16.04/18.04. How to install CMake from binary distrubtion on Ubuntu system.
What is CMake?
CMake is a cross-platform free and open-source software application for managing the build process of software using a compiler-independent method. It supports directory hierarchies and applications that depend on multiple libraries. CMake can be used to build, test, and package software on your system.
CMake can be used to control the software compilation process to geneate a native build environment that will compile source code, create libraries, generate wrappers and build executables in arbitray combinations.
Installing CMake from Default Ubuntu Repo
CMake package is available in the default Ubuntu 16.04 or 18.04 repository (it may be a older version of CMake), so you can use apt install command to install it directlry, type:
After installed, you can try to verify CMake version to check if it is successfully installed on your system, type:
From the above outputs you can see, the installed version of cmake is 3.10.2. You can go to the official download web page of CMake to see that the latest stable version of CMake is 3.13.4.
Installing CMake from PPA on Ubuntu 16.04
If you are using Ubuntu 16.04 system, you can also use a PPA repository to install CMake tool on your system with the following commands:
If CMake is alreay installed on your Ubuntu system, you can use apt upgrade command to upgrade CMake to the latest version, type:
Or you can add the following entries into /etc/apt/sources.list file:
Next, run the following command to update Package manager cache, type:
Then, install CMake tool using this PPA with the following command:
Installing CMake from Binary Distrubtion
You should know that the above two methods is not able to install the latest statble version (now the latest version is 3.13.4) of CMake. You can go to the official CMake webpage to download the latest version of CMake binary distrubtion file.
The Binary Distrubtion of CMake have two file extention, one is shell script, and another is archive file. The below will show you how to use those two files to install CMake.
For Shell Binary Distrubtion of CMake:
#1 Downloading CMake Bianary file with the following wget command:
#2 After intalled CMake Binary file, just execute it:
Note: you need to press y key on your keyboard to accept the license to continue the installation process. You also need to specify one target directory, if you type Y key, it will use the default setting to install CMake in the current directory.
#3 you need to change the current directory to ./cmake-3.13.4-Linux-x86_64/bin/, and all of CMake executables are located here.
For Archive Binary Distrubtion of CMake:
You can also install CMake from binary distrubtion its extention is tar.gz. You just need to download it to your local disk, and then extract all file to a specified direcotry.
#1 Download archive binary file of CMake with the following command:
#2 Extract all files from the above downloaded CMake archive binary file, type:
#3 changing the current directory to cmake-3.13.4-Linux-x86_64
#5 executing cmake script to check the current CMake version, type:
Installing CMake from Source Code
You can also compile the latest source code of CMake to install it. At this time, the latest stable version of CMake is 3.13.4. So you need to donwload the archive source code from the offical CMake web page, then compiling it. Just do the following steps:
#1 before downloading souce code, you need to unisntall the defualt older version of CMake by the default Ubuntu Package manager. Type:
#2 go to the official download page to get the latest version of CMake with the following wget command:
#3 extract all files from downloaded archive file, type:
#4 changing the current dirctory to cmake-3.13.4, type:
#5 compiling and install cmake with the following commands:
#6 checking CMake version to verify if it is installed successfully, type:
Installing CMake GUI
If you want to install CMake GUI on your Ubuntu system, you just need to use apt install command to install it, type:
Then you can use the following commands to check if CMake-gui package is installed normally:
You can run the cmake-gui command in Ubuntu terminal to launch the cmake gui, type:
Conclusion
You should know that how to install CMake tool on Ubuntu 16.04 or 18.04 from this guide, and you also know how to install CMake with the different methods on Ubuntu Linux server(default ubuntu repo, PPA, Source code). If you want to see more information about CMake, you can go the official web site of CMake directly.
How to update cmake on Ubuntu
Due to various applications’ request, the original version of cmake needs to be updated. This article will elaborate the whole process to update cmake to any specific version.
Uninstall
Here we should separate the problem into two situations according to the way you installed the current cmake.
Firstly, if the current cmake is the default version provided by Ubuntu package manager, just run
to remove all the related binary, configuration, data and dependency files which is no need anymore.
Refer to this article to fully understand the exact meaning of commands above:
The difference between apt remove, purge, and autoremove
A brief discription to help you understand the main difference between ench apt commands related to package…
Besides, if the current cmake is compiled and installed from source codes by yourself manually, chang your direcrory into the path you ran sudo make install before and run
Building and Installing
Go to the official cmake webpage, then download and extract the latest version. Here take cmake-3.22.1.tar.gz for example. Run
$(nproc) stands for your number of processing units available, and this can accelerate your process of compilation.
It is not caused by the lack of openssl, actually run apt policy openssl and we’ll see it has already been installed in our system directory, but needs the dev package of openssl. Simply run
Then, test your new cmake version.
Some hints here:
Extra
Refer to this article to use cmake by alternatives.
Installing latest cmake on Ubuntu 18.04.3 LTS run via WSL: OpenSSL error
Using CLion on Windows (a C++ IDE), I’d like to install the latest version of cmake on Ubuntu 18.04.3 LTS run via WSL (the current version of CLion requires cmake > 3.15, while I have only version 3.10.2 installed).
Following cmake installation instructions found in a related answer, an error occurs when bootstrapping CMake (first step in A-3 in linked answer):
I have already installed libssl-dev as recommended in another cmake-related thread.
Any ideas on how this issue can be fixed?
2 Answers 2
I ran into the same problem last year. My solution was this:
run the following in your WSL terminal
After that is finished
Next add the updated repository by typing in the following
And it should be updated to the latest version.
Note: if the above doesn’t work, be very careful when trying the below steps. It is not elegant, it is not clean, but it does work.
If this does not work. Go to https://cmake.org/download/ and download the Latest Ubuntu version. If you have a folder where you maintain all your projects I suggest downloading the file into your top most directory where your projects are.
For example all my projects are in a folder called «Github» so I would download the file into my «Github» Folder. If there is not a top level directory create a cmake folder in the C drive or what ever drive you save your projects to.
Next after its finished downloading Extract the file (through winrar/winzip/7zip/ or terminal) into that same directory. Once extracted cd into the folder (cmake-
This will make the latest version of cmake and then install the required components. It can take a while to have everything build and installed.
Once that is done you are going to want to locate the /bin/ folder inside your cmake folder. Make sure a file called «cmake» is in this folder. Copy the path of this directory and type the following
You can use vi or vim or whatever text editor you want from within the terminal. At the end of the file type the following
Make sure if you copied the path from windows explorer you replace \ with / save the file and exit.
Restart your terminal and type
It should show up with whichever version you just downloaded.
Congrats you now have the updated version of cmake.
As per the comment by John, this is version specific, these exact same directions (for the first method at least) are available here for the latest version of CMake.
Источники информации:
- http://askubuntu.com/questions/355565/how-do-i-install-the-latest-version-of-cmake-from-the-command-line
- http://www.osetc.com/en/how-to-install-the-latest-version-of-cmake-on-ubuntu-16-04-18-04-linux.html
- http://medium.com/@lyl1617670866/how-to-update-cmake-on-ubuntu-9602521deecb
- http://askubuntu.com/questions/1203635/installing-latest-cmake-on-ubuntu-18-04-3-lts-run-via-wsl-openssl-error