Skip to content

CMake3: How to Compile from Source

In this blog,  CMake3 is compiled from source code in detail. CMake3 is an essential tool to have when compiling certain opensource software from scratch. In my case, I came upon CMake3 when I delved into the wonderful world of GSM gateways and the GAMMU framework.

Check them out here:

In the previously mentioned posts, the need to compile Gammu from source was necessary because the RPMs, although successfully installed, had some major dependency issues that could not be resolved by brute force manual linking. Admittedly, I was forced to learn how to compile from source because of Gammu. So, that’s a yehey for me. Anyway, as expected, I encountered certain hiccups along the way. That’s what Linux is and that probably how will it be forever. It is a helluva software to figure out but once tamed, it will never ever die (fingers crossed).

At any rate, whilst installing gammu-1.38.1 the compilation process was stopped midstream by the need to install the latest version of CMake3. Hence, this blog.

But before we begin, we must understand first what CMake is.

What is CMAKE?

According to its website,

“CMake is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice. The suite of CMake tools were created by Kitware in response to the need for a powerful, cross-platform build environment for open-source projects such as ITK and VTK.
“CMake is part of Kitware’s collection of commercially supported open-source platforms for software development.”

That doesn’t give us anything much, right? But let me try to explain as I understand it. CMake is a collection of open source utilities that builds, tests, and packages software. It provides a safe environment wherein the entirety of the compilation environment, including the necessary tools and dependencies, are handled by CMake. Thus, in essence, it simplifies the compilation process while making it fool proof.

Cmake3 is the latest version of the utility.

Whew! That is a mouthful.

How to compile CMake3 from source

The first step to compiling CMake3 from source is to download the tar file or source code from the CMake website. Here’s the link: Or you may download it using wget. One thing to take note of when doing this is to download CMake3 into the Dowloads or Home folder. Extract it there, then don’t worry about the dependencies and linking. Everything will be resolved by a custom “linking” script later on. Here are the commands:

Step 1: Download the tar file

[root@lappy]# wget

Step 2: Untar the file

[root@lappy]# tar -xvf cmake-3.8.0-rc1.tar.gz

Step 3: Enter the directory

[root@lappy]# cd cmake-3.8.0-rc1.tar.gz

Step 4: Run the following commands to initialize the compilation environment

[root@lappy]# ./bootstrap

This command takes a long time to execute.

[root@lappy]# gmake

This command takes a long time to execute.

[root@lappy]# sudo gmake install

Step 5: Check the version

[root@lappy]# cmake –version

This should be the old cmake still

Step 6: Register the cmake directory to .bashrc

[root@lappy]# vi /root/.bashrc

The location of CMake3 is at /usr/local/bin. Add this to the .bashrc file:

export PATH

Step 7: Restart .bashrc

[root@lappy]# source /root/.bashrc

Step 8: Check whether or not Cmake3 is available in the system

[root@lappy]# cmake –version

This should say cmake version 3.8.0-rc1.


Like everything Linux, the binaries and other utilities that we users/server admins/network admins/enthusiasts love and heavily rely on are difficult to learn at first. They require patience, time, and a clear mind to figure out. In this sense, Linux is truly a gift to those who put in the effort to learn it. Cmake3 is such an example. It is a tool or a collection of tools that make it relatively painless to compile other software. However, it itself requires compilation — thus its own time for learning, love, and affection.

I sincerely hope that this helps you my reader, because certainly it helps me — the future me.



Special thanks to  Xinyustudio. Without this blog, this guide would never have existed. Give them some love here:

Be First to Comment

Leave a Reply

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