Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify where CMake is installed in Ubuntu?

I have downloaded the cmake-3.11.3-Linux-x86_64.sh file. Then I executed it and it created a folder that has a bin file there is cmake on it. I tried to edit /etc/environment like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/m/FILES/CMake/cmake-3.11.3-Linux-x86_64/bin"

But when I try this command:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

I get this message:

The program 'cmake' is currently not installed. You can install it by typing: sudo apt install cmake

Which part of what I did, is wrong and how can I fix that?

like image 555
Hasani Avatar asked Jun 02 '18 11:06

Hasani


Video Answer


2 Answers

I assume you downloaded the script from CMake's Download Page. The documentation how to use it is admittedly a little sparse.

In short, call (installation path for CMake here is /usr/local):

# sudo cmake-3.11.3-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local

Note: You need to uninstall any package manager installed CMake packages first

# sudo apt remove cmake
# sudo apt purge --auto-remove cmake

Options

The script has the following options:

# cmake-3.11.3-Linux-x86_64.sh --help
Usage: cmake-3.11.3-Linux-x86_64.sh [options]
Options: [defaults in brackets after descriptions]
  --help            print this message
  --version         print cmake installer version
  --prefix=dir      directory in which to install
  --include-subdir  include the cmake-3.11.3-Linux-x86_64 subdirectory
  --exclude-subdir  exclude the cmake-3.11.3-Linux-x86_64 subdirectory
  --skip-license    accept license

The one you are searching for is --prefix=dir. Otherwise it will just use the current directory to extract the installation files.

Test Output on Ubuntu

# cmake-3.11.3-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
CMake Installer Version: 3.11.3, Copyright (c) Kitware
This is a self-extracting archive.
The archive will be extracted to: /usr/local

Using target directory: /usr/local
Extracting, please wait...

Unpacking finished successfully

# cmake --version
cmake version 3.11.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Reference / Alternative

  • Ask Ubuntu: How do I install the latest version of cmake from the command line?
like image 104
Florian Avatar answered Nov 15 '22 07:11

Florian


Rather than installing CMake mannually,
Please let apt take care of it.

Just rollback whatever changes you've done.
Simply type sudo apt install cmake on your terminal.

and you're ready to use CMake since apt takes care of all dependencies installations and environment variable settings.

I hope, this will help.

like image 31
Muhammad Iliyas Avatar answered Nov 15 '22 09:11

Muhammad Iliyas