How to download, compile, and install CMake on Linux

CMake is a cross-platform, open-source build system. CMake is a family of tools designed to build, test and package software.

Here are the simple steps to download, configure, compile, and install CMake on a Linux machine. I have tested these instructions on Debian/Ubuntu Linux distributions but they should work on all Linux machines where compilers and make utilities are installed. Please take a look at configuring Ubuntu Linux after installation to configure your Debian/Ubuntu Linux box for the required tools.

Please make sure you check the downloaded file's integrity before unzipping it. '#' (w/o quotes) in front of commands below means you have to run the command as root user (or use sudo instead if your system supports that).

Download:

$ wget http://www.cmake.org/files/v2.8/cmake-2.8.3.tar.gz

Extration of cmake source code from downloaded file:

$ tar xzf cmake-2.8.3.tar.gz
$ cd cmake-2.8.3

Configuration:

If you want to see the available conifuration options, run command below.

$ ./configure --help

In order to configure cmake before installation, run command below.

$ ./configure --prefix=/opt/cmake

We basically instructed the install script to install CMake in /opt/cmake.

Compilation:

$ make

Installation:

# make install

Verification:

After installation without any errors you can verify the installation by running the command below:

$ /opt/cmake/bin/cmake -version

The output should look something like below (depending upon cmake version you are installing).

cmake version 2.8.3

Did this tutorial help a little? How about buy me a cup of coffee?

Buy me a coffee at ko-fi.com

Please feel free to use the comments form below if you have any questions or need more explanation on anything. I recommend thoroughy testing on a production-like test system first before moving to production.

Comments (write a comment):

Hey,
Thanks for this guide man.
It really helped my out as I am new on Ubuntu platform.

Keep helping others as well.

Regards,
Sunny Posted by: Sunny on May 12, 2011

when i got to the part with
./configure --prefix=/opt/cmake
it just says "command not found"
i even tried . configure...
and it still says the same thing. what a i doing wrong? Posted by: james on Dec 08, 2011

please make sure you cd into the cmake folder first before running the ./configure command. Posted by: shahryar ghazi on Dec 12, 2011

just awesome... Posted by: lalit on Dec 22, 2011

when i did /opt/cmake/bin/cmake -version
i get following message

bash: /opt/cmake/bin/cmake: No such file or directory Posted by: atraya on Dec 24, 2011

@atraya:that means cmake was not installed properly at that location ... are you sure you followed the instructions and did not see any error messages at the end of configure and make commands? Posted by: shahryar on Dec 25, 2011

Morning,

When i run the instruction : make install,
the result is :

CMake Error at cmake_install.cmake:36 (FILE):
file cannot create directory: /opt/cmake/doc/cmake-2.8. Maybe need
administrative privileges.

So, I can't to run - verification...

What's the meaning of messaege ? and what can I do to continue...

Thanks Posted by: mohammad on Jan 17, 2012

try running the command as root or sudo or use some other directory that is writeable by your username as the target directory.

In order to select a different target directory, you will have to restart from configure command and mention the writeable new target directory as the value for --prefix option of configure. Posted by: shahryar ghazi on Feb 01, 2012

@atraya try using :
cd bin
./cmake -version
./ is used for executable files
it should show the output :
cmake version 2.8.3 Posted by: Muqaddas Jamil on Mar 16, 2012

Yup it worked for me.
Thank you, it is very useful. I used it on RHEL 3. Posted by: Deepti on May 11, 2012

thanks man. I really need it. it was helpful Posted by: hojat on Oct 26, 2012

Thanks a lot! Posted by: ggd on Jan 02, 2013

Hallo!

I GOT THIS ERROR MESSAGE

CMake 2.8.10.2, Copyright 2000-2012 Kitware, Inc.
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /home/xyz/cmake-2.8.10.2/Bootstrap.cmk/cmake_bootstrap.log

ANY SUGGESTIONS

MATS

[email protected] Posted by: Mats on Apr 07, 2013

Hi! When I run the configure command I get the following error
gmake: `cmake' is up to date.
loading initial cache file /home/Babar/cmake-2.8.10.2/Bootstrap.cmk/InitialCacheFlags.cmake
Curses libraries were not found. Curses GUI for CMake will not be built.
CMake Error at Modules/FindPackageHandleStandardArgs.cmake:97 (message):
Could NOT find Qt4 (missing: QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE
QT_RCC_EXECUTABLE QT_UIC_EXECUTABLE QT_INCLUDE_DIR QT_LIBRARY_DIR
QT_QTCORE_LIBRARY) (Required is at least version "4.4.0")
Call Stack (most recent call first):
Modules/FindPackageHandleStandardArgs.cmake:291 (_FPHSA_FAILURE_MESSAGE)
Modules/FindQt4.cmake:1223 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
Source/QtDialog/CMakeLists.txt:32 (find_package)
Can you pl help me out. Thank You Posted by: Zaheer Babar on Apr 19, 2013

@Mats: looks like you do not have a proper C++ compiler installed on your machine...this might help

http://www.geeksww.com/tutorials/operating_systems/linux/configuration/configuring_ubuntu_linux_after_installation.php



which command were you running when you got the error? Posted by: shahryar on May 27, 2013

@Zaheer: I hope you are running the exact same command on a Linux machine

looks like its asking for Qt4 library for some reason... try installing that Posted by: shahryar on May 27, 2013

I installed this just fine but when i type cmake I am still getting command not found. I am not sure what the problem is. Posted by: Hotsammysliz on Jun 04, 2013

@hotsammysliz: did you finish the verification step in tutorial successfully?

If you want to use cmake from anywhere then you have to add/append /opt/cmake/bin/ (or whatever installation directory you chose for cmake) to your system PATH variable.

See http://www.geeksww.com/tutorials/operating_systems/linux/tips_and_tricks/working_bash_environment_variables_beginners_linux.php for details on system variables and how to change them. But, you should be able to use the full path to cmake in any case. Posted by: shahryar on Jun 08, 2013

hello
i am getting this error
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
Log of errors: /home/saket/Desktop/cmake-2.8.11.1/Bootstrap.cmk/cmake_bootstrap.log

any help plz i was running following command
$./configure --prefix=/opt/cmake Posted by: saket on Jul 01, 2013

Amazing stuff man.. It worked fine, thanks a lot.. Posted by: Parth on Aug 29, 2013

Thanks for the guide. It helped me alot. Posted by: sagar on Oct 02, 2013

Hello,

my make install command was succesfull,
i have positive output to $ /opt/cmake/bin/cmake -version command
.... but im still getting an error mesage > bash: cmake: command not found.

When i try > dpkg --get-selections, cmake isnt here.

can you help please ? :) Posted by: Duri on Nov 03, 2013

@Duri: looks like you need to add cmake to your PATH environment variable to be able to use cmake from anywhere without specifying the complete path to command.

see the article http://www.geeksww.com/tutorials/operating_systems/linux/tips_and_tricks/working_bash_environment_variables_beginners_linux.php and append /opt/cmake/bin/ to your environment variable Posted by: shahryar on Nov 24, 2013

Sir i have completed all the steps given above and have successfully executed them but still when i use it i get the error
cmake command not found
What should i do??? Posted by: Sohaib Bin Altaf on Dec 04, 2013

I GOT THIS ERROR MESSAGE

CMake 2.8.10.2, Copyright 2000-2012 Kitware, Inc.
C compiler on this system is: cc
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
---------------------------------------------
Log of errors: /home/xyz/cmake-2.8.10.2/Bootstrap.cmk/cmake_bootstrap.log

ANY SUGGESTIONS


try this command
sudo apt-get install build-essential Posted by: Tanya on Jan 21, 2014

Very nice and THANX.. :)
but one more thing I tried
$cmake <enter>
it shows me:
bash: cmake: command not found

{I am new in 'cmake;' so pls cop-up with me if m asking smthing very foolish :( }
though I got the message what u have mentioned in 'verification' section earlier.
but i want to ask you that why it doesnt give error similar to 'make' error if it is installed and we dont have makefile that place.
I mean that the 'make' error hows that cmd is working fine but fault is bcoz of unavailability of 'makefile' but here the error seems to be bcoz of un-installed 'cmake' Posted by: Pranav on Feb 21, 2014

@Shoaib: If you ran everything successfully then what was the output of running the following:

/opt/cmake/bin/cmake --version

if it successfully prints the version number then you need to put /opt/cmake/bin in your system PATH variable

See http://www.geeksww.com/tutorials/operating_systems/linux/tips_and_tricks/working_bash_environment_variables_beginners_linux.php Posted by: Shahryar on Apr 08, 2014

@Tanya: So, did you try the command as suggested in the error message you pasted?

"try this command
sudo apt-get install build-essential" Posted by: shahryar on Apr 08, 2014

@Pranav: it looks like you may not have added the cmake binary files' location in your system's PATH variable.

See http://www.geeksww.com/tutorials/operating_systems/linux/tips_and_tricks/working_bash_environment_variables_beginners_linux.php for some help on how to play with bash variables. Posted by: Shahryar on Apr 08, 2014

hello
i am getting this error
Error when bootstrapping CMake:
Cannot find appropriate C++ compiler on this system.
Please specify one using environment variable CXX.
See cmake_bootstrap.log for compilers attempted.
Log of errors: /home/geeta/Desktop/cmake-2.8.12.2/Bootstrap.cmk/cmake_bootstrap.log
Plzzz help me out. Posted by: geeta on Apr 26, 2014

@geeta: have you made sure you installed build tools on your system. For example, for Ubuntu Linux you can get some instructions from http://www.geeksww.com/tutorials/operating_systems/linux/configuration/configuring_ubuntu_linux_after_installation.php (under GCC tools) Posted by: shahryar on Apr 30, 2014

Hey!
Thanks a lot for such clear explanations! Really helps. The only thing is that I have installed it in Ubuntu and I need to put 'sudo' in front of 'make' and 'make install', .e. 'sudo make'. Posted by: Oksana on Jun 20, 2014

I cannot build cmake,
when I run make, it uses up all RAM, then all swap, then stops.
strace shows make is looking for libncurses.so.5 forever ...
Hints / help?
Tx! Posted by: cmake-probs on Jul 31, 2014

I did it all and everything ran fine. However, when I try to use cmake, I get the old version 2.8.10.2. Perhaps the install went into the wrong directory. Posted by: Bruce on Aug 10, 2014

@cmake-probs: I think you should try and install libncurses then ... you may find instructions on this site too. Posted by: shahryar on Sep 02, 2014

@Bruce: Or, perhaps you are downloading and installing a different version. Posted by: shahryar on Sep 02, 2014

How to include cmake into path automatically? Posted by: hensem on Nov 20, 2014

I am having trouble getting CMake to install on my Synology DSM 5.1 server. I get the following:

Segmentation fault (core dumped)
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------

This happens with 2.8.3 and 3.0.2 versions of CMake.

Help? Posted by: Darell Craighead on Nov 30, 2014

hello. I try to install gromacs-4.6 on ubuntu 12.10. i download cmake on flash memory and paste it on home folder download and use from above installization procedure but i have not successed so far, please help me Posted by: eskandari on Jan 20, 2015

Thank you !!! Posted by: Sumudu on Jan 25, 2015

hello everyone!!
i got this message how to fix it? newbie!!

[[email protected] cmake-2.8.11.1]# ./configure --prefix=/opt/cmake
---------------------------------------------
CMake 2.8.11.1, Copyright 2000-2012 Kitware, Inc.
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
See cmake_bootstrap.log for compilers attempted.

---------------------------------------------
Log of errors: /opt/cmake-2.8.11.1/Bootstrap.cmk/cmake_bootstrap.log
--------------------------------------------- Posted by: simao pedro on Mar 11, 2015

Ive installed cmake successfully but somehow, when i try to use "cmake ../" , it would still use the older version of cmake which is pre-installed in kali linux. how do i set the newer version of cmake that i have downloaded to default? Posted by: Yves on Apr 20, 2015

@Yves: you have to use the full path to cmake installed binary. For example:

/opt/cmake/bin/cmake ../ Posted by: geeksww on Apr 28, 2015

@simao: You do not have a C compiler installed ... you need to do it for your Linux distro

see below article for Ubuntu

http://www.geeksww.com/tutorials/operating_systems/linux/configuration/configuring_ubuntu_linux_after_installation.php Posted by: geeksww on Apr 28, 2015

Thanks .. It works for me.. Posted by: sagar on May 12, 2015

when i run this
[email protected]:/opt/cmake-2.8.3# ./configure --help
i get this
-bash: ./configure: Permission denied
whats wrong wih my bash? Posted by: zoe on May 12, 2015

@zoe: can you run the following command and provide output here please?

ls -lah /opt/cmake-2.8.3/configure Posted by: shahryar on Jun 09, 2015

useful! thanks! Posted by: dfg on Jun 10, 2015

I got the following error. Any way to fix this problem ???
CMake Error at cmake_install.cmake:36 (FILE):
file cannot create directory: /opt/cmake/doc/cmake-2.8. Maybe need
administrative privileges.


make: *** [install] Error 1 Posted by: santo on Jun 12, 2015

@santo: looks like you do not have the privileges to create a sub directory there.

try running the command as root or with sudo (recommended). Posted by: shahryar on Jun 18, 2015

Thank you, for the guidance Posted by: Shrinivas kalal on Jul 23, 2015

Very good tutorial
Thank you Posted by: Oladele ZANNOU on Nov 06, 2015

Hey,
Thanks a lot.
It really helped me as I am new on Ubuntu platform. Posted by: Anusha on Dec 07, 2015

No such command make, can't make it work after installing, env doesn't help. Posted by: Peho on Mar 04, 2016

Did you follow
http://geeksww.com/tutorials/operating_systems/linux/configuration/configuring_ubuntu_linux_after_installation.php properly?

You seem to be missing build tools. The make command should be available (or try to find its path). Posted by: Shahryar on Mar 14, 2016

i get this while installing
make: ** no targets specified and no makefile found Posted by: nitheesh on May 02, 2016

@nitheesh: the info provided is not enough

you need to mention version number, command executed, directory in which command was executed.

What other commands were executed before that and did all of them finish successfully or with errors? Posted by: Geeksww on May 08, 2016

- i have ubuntu 13.10 ,32 bit os.
- I downloaded cmake from the above link and extracted properly.

-when i type the command < ./configure --help> it shows error..permission denied.
- when i type the same command as sudo it gives error .. ./configure:command not found.

- i tried skipping this portion and went to compilation part.
- when i wrote the command < make > it gave error.. no target specified and no makefile found.

Please Help.
Thanks Posted by: Archit Mathur on May 25, 2016

@Archit: You have to configure first before you could make

Did you cd into the downloaded directory of cmake?

weird ..but looks like the directory you are trying to configure from lacks permissions for the OS user. Posted by: Shahryar on Sep 25, 2016

leave a comment on tutorial leave a comment