Cmake how to install linux

Installing the Latest CMake on Ubuntu Linux

12 Mar 2020 (Updated 8 May 2021 )

When you install CMake with APT, you’ll notice it installs an older version. This tutorial shows you how to install the latest version so that you can build software that requires newer CMake features.

Remove old version

Before we begin, you’ll want to remove any previous versions of CMake that were installed with APT. Run the following commands to remove it:

Install the latest CMake

As of writing the latest version of CMake is 3.20.2 which can be installed using one of the following two options:

Option 1: Use Snappy

Using the Snappy package manager is the quickest and easiest way to install the latest version of CMake on Ubuntu Linux.

Install it with Snappy by running the following command:

You can check to see if it’s installed by running:

Option 2: Install from source

The second option is to download the source code from the CMake website and compile it on your Linux machine. This can take much longer, depending on how powerful your machines processor is.

Run the following commands to download, compile and install CMake:

(Note: replace v3.20.2 with the version you want to install, see the CMake download page for a list of versions)

That’s it, now you have the latest version of CMake installed on your Ubuntu Linux machine, as you can see from the output of the cmake —version command below.

Источник

Installing CMake

There are several ways to install CMake, depending on your platform.

Windows

There are pre-compiled binaries available on the Download page for Windows as MSI packages and ZIP files. The Windows installer has an option to modify the system PATH environment variable. If that is not selected during installation, one may manually add the install directory (e.g. C:\Program Files\CMake\bin) to the PATH in a command prompt.

One may alternatively download and build CMake from source. The Download page also provides source releases. In order to build CMake from a source tree on Windows, you must first install the latest binary version of CMake because it is used for building the source tree. Once the binary is installed, run it on CMake as you would any other project. Typically this means selecting CMake as the Source directory and then selecting a binary directory for the resulting executables.

macOS

There are pre-compiled binaries available on the Download page for macOS as disk images and tarballs. After copying CMake.app into /Applications (or a custom location), run it and follow the “How to Install For Command Line Use” menu item for instructions to make the command-line tools (e.g. cmake) available in the PATH. Or, one may manually add the install directory (e.g. /Applications/CMake.app/Contents/bin) to the PATH.

One may alternatively download and build CMake from source as in the following section.

Читайте также:  Средства windows для управления файлами

Linux, UNIX

There are pre-compiled binaries available on the Download page for some UNIX platforms. One may alternatively download and build CMake from source. The Download page provides source releases. There are two possible approaches for building CMake from a source tree. If there is no existing CMake installation, a bootstrap script is provided:

(Note: the make install step is optional, cmake will run from the build directory.)

By default bootstrap will build CMake without any debug or optimization flags. To enable optimizations you will need to specify the CMAKE_BUILD_TYPE option to bootstrap like this: ./bootstrap — -DCMAKE_BUILD_TYPE:STRING=Release

For more options with bootstrap, run ./bootstrap —help .

Or, an existing CMake installation can be used to build a new version:

(Note: the make install step is optional, cmake will run from the build directory.) If you are not using the GNU C++ compiler, you need to tell the bootstrap script (or cmake) which compiler you want to use. This is done by setting the environment variables CC and CXX before running it. For example:

Download Verification

Each release on the Download page comes with a file named cmake-$version-SHA-256.txt, where $version is the release version number.
One may use this file to verify other downloads, such as the source tarball. For example:

The SHA-256 file itself can be verified by GPG signature:

The GPG key C6C265324BBEBDC350B513D02D2CEF1034921684 is a signing subkey whose expiry is updated yearly.

Источник

Установка CMake в Ubuntu

CMake — это набор инструментов, который позволяет создавать, тестировать и упаковывать программное обеспечение. Это семейство инструментов доступно сразу на нескольких платформах и распространяется под открытым исходным кодом. Чаще всего CMake применяют для упрощения процесса компиляции созданного ПО путём использования простых кроссплатформенных файлов конфигурации.Также с помощью CMake создаются специальные файлы makefile — наборы инструкций, которые позволяют использовать возможности компилятора в дальнейшем при автоматизации сборки.

Автором CMake является команда Kitware. Создание этого ПО было продиктовано необходимостью формирования мощной среды, которая могла бы работать сразу на нескольких платформах с проектами, где открыт исходный код (прежде всего — с Insight Segmentation and Registration Toolkit и Visualization Toolkit). В этом материале вы узнаете, как установить CMake Ubuntu, используя графический интерфейс либо командную строку. Если вы пытаетесь собрать программу и получаете ошибку cmake not found, то эта статья будет для вас очень полезной.

Установка CMake в Ubuntu

1. Менеджер приложений

На момент написания этой статьи использовалась самая последняя версия CMake (3.15.2). Она была доступна в рамках известного всем магазина Snap Store. Ниже вы узнаете, как установить CMake через штатный в Менеджер приложений в Ubuntu.

Если вы не хотите тратить много времени на взаимодействие с командной строкой, то работа с графическим интерфейсом должна вам понравиться из-за своей простоты. На панели инструментов, расположенной слева, щёлкните значок Менеджер приложений.

В верхней части открывшегося окна нажмите на значок поиска и в появившейся строке введите CMake. Результаты отобразятся следующим образом:

Первый пакет в результатах поиска — это и есть нужный нам файл, доступный в рамках магазина Snap Store. Щёлкните по этой записи и вы попадёте в раздел с подробной информацией о приложении, который будет выглядеть так:

Нажмите кнопку Установить, чтобы запустить процесс установки CMake. Возможно, вам придётся ввести свой пароль в окошке аутентификации, которе появится сразу после нажатия кнопки Установить. Это одна из форм защиты в Ubuntu — только авторизированный пользователь может устанавливать программное обеспечение в этой системе.

Введите свой пароль и нажмите кнопку Enter. После этого вы сможете наблюдать за статусом установки на отображающемся графическом индикаторе.

Читайте также:  Обновление для системы безопасности windows 10 для 64 разрядных систем

После успешной установки система выдаст вам следующее сообщение:

Из этого окна уже можно запустить CMake (или тут же, например, удалить).

2. Менеджер пакетов snap и apt

Такую же версию CMake можно установить через командную строку, если воспользоваться следующей командой:

sudo snap install cmake

Установка cmake ubuntu 18.04 из официальных репозиториев выполняется командой:

sudo apt install cmake

3. Сборка CMake из исходников

Если по каким-то причинам вы не хотите использовать графический интерфейс, или вы хотите самую свежую версию, можно прибегнуть к помощи командной строки. Нам надо будет скачать исходный код с официального сайта (https://cmake.org/download/), скомпилировать его, а потом установить.

Откройте командную строку — для этого либо найдите приложение «Терминал», либо нажмите сочетание клавиш Ctrl+Alt+T. Введите команду, которая начнёт загрузку исходного кода:

Когда tar.gz полностью скачается, его нужно распаковать. Воспользуемся следующей командой:

tar -zxvf cmake-3.15.2.tar.gz

Перейдём с помощью терминала к папке с распакованными файлами:

Чтобы провести компиляцию скачанного кода, выполним ещё одну команду:

После правильного выполнения всех операций, командная строка выдаст следующий результат:

Теперь можно запустить процесс установки с помощью простой команды:

Затем выполните ещё одну команду:

sudo make install

Процесс установки завершён. Теперь можно проверить версию CMake, чтобы убедиться в правильности своих действий.

На момент написания этого материала CMake был доступен в версии 1.15.2, с которой мы и работали. Теперь вы можете использовать этот инструмент для выполнения своих рабочих задач.

Как удалить CMake?

Если вы решили удалить CMake, который был установлен через Менеджер приложений, то этот процесс будет происходить следующим образом. Снова откройте Менеджер приложений, в открывшемся списке найдите пункт CMake (рядом с ним будет надпись Установлен). Нажмите на иконку приложения, перейдите к следующему экрану и найдите кнопку Удалить. Так будет запущен процесс деинсталляции.

После этого система вновь предложит ввести вам пароль — и сразу же после этого приложение будет удалено.

Источник

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:

Читайте также:  Windows search look in

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

#4 CMake executable will be in ./cmake-3.13.4-Linux-x86_64/bin/ directory.

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

Источник

Оцените статью