Installation of CMake

Home / Installation of CMake

Installation of CMake

December 9, 2015 | Article | 2 Comments

CMake is a cross platform, open-source build system consists of tools designed to build, test, and packaging software. It used to control the software compilation process using simple platform and compiler independent configuration files.

In general, CMake generates native makefiles and workspaces that can be used in the chosen compiler environment.

In this article, we will discuss about how to install CMake, either binary or from sources. The method we use here is generic way, which means, it can be applied to any Operating System. However, for demonstration I will use following machine:

  1. Slackware64 14.0 Linux
  2. GCC (Compiler)

Preparation

At least you have privileges for installing the files later.

Obtain the Materials

A binary and source code can be obtained here. The latest version per June 29th, 2013 is 2.8.11. Both binaries and source codes can be downloaded from here.

As I use Linux I would download source code (http://www.cmake.org/files/v2.8/cmake-2.8.11.1.tar.gz) and unfortunately no binary for Linux x64 so we download this binary (http://www.cmake.org/files/v2.8/cmake-2.8.11.1-Linux-i386.sh). If you want to download for Windows version, go grab source code (http://www.cmake.org/files/v2.8/cmake-2.8.11.1.zip) and binary (http://www.cmake.org/files/v2.8/cmake-2.8.11.1-win32-x86.exe)

Binary Installation

Assuming we download shell archive cmake-2.8.11.1-Linux-i386.sh.

Make sure the file is executable (having +x permission). Do following if you want to set the permission:

chmod +x cmake-2.8.11.1-Linux-i386.sh

Then execute it from terminal

./cmake-2.8.11.1-Linux-i386.sh

Make sure you have privileges to do installation.

Binary installation for Windows system is similar. Just execute the application to initiated installation.

Source Code Compilation & Installation

There are two case for compilation, whether you have CMake or not installed in your system. If you have CMake, we can use CMake to build CMake. However, we can also build it from scratch. Either way we should extract the sourcecode from. A simple way is using command:

tar -xf cmake-2.8.11.1-Linux-i386.tar.gz
cd cmake-2.8.11.1

From Scratch

This case will describe compilation from scratch and suitable for us who either don’t have CMake installed before or just want to compile it from scratch.

We need a compiler and a make utility and running UNIX/Mac OSX/MinGW/MSYS/Cygwin.

Run the bootstrap script in the source directory of CMake. If CMake is going to be installed on particular path, use –prefix. For this example I use /usr/local as my base path.

./bootstrap --prefix=/usr/local
make
make install

Unfortunately for Windows user who didn’t use Cygwin, you can’t do this method. Instead, you should download the binary version of CMake.

Build With CMake

Building CMake with CMake is like building any CMake-based project. Run CMake to the root of cmake directory (e.x: ~/cmake-2.8.11.1).

cd ~/cmake-2.8.11.1
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local .
make
make install

Notice the “.” (dot) in the trail, that’s part of command.

At this point, we have successfully install CMake

About Author

about author

xathrya

A man who is obsessed to low level technology.

2 Comments
  1. Installing libHaru from Source - Xathrya.ID

    […] can use cmake for building. To build libHaru, do […]

  2. Before Wt: Installing Prerequisite for Wt - Xathrya.ID

    […] For information on how to install CMake, follow this article. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Social media & sharing icons powered by UltimatelySocial