Skip to content
Jason Charney edited this page Mar 31, 2017 · 12 revisions

CMake is cross-platform free and open-source software for managing the build process of software using a compiler-independent method. It is designed to support directory hierarchies and applications that depend on multiple libraries. It is used in conjunction with native build environments such as make, Apple's Xcode, and Microsoft Visual Studio. It has minimal dependencies, requiring only a C++ compiler on its own build system.

Prerequirements

CMake likely requires Python. Raspbian has Python 2 and 3 included.

Installation

$ sudo apt-get install cmake

Building with CMake instead of Make

Building software with CMake kinda has a different set of instructions that building software with Make.

Make is pretty much your standard software for building software, and the instructions of using it generally look like this.

./configure && make && sudo make install

What happens here

  • ./configure run a script that executes configuration. Some software projects don't have this.
  • make which is the command that tells the software to look for a makefile in the current diretory and use it to build software. This file contains a list of gcc and/or g++ commands for the most part. A makefile allows for the person who downloads the software to automate this process rather than compile each file individually, much like a shell script. Multicore devices, like the Raspberry Pi 2, add the -jn argument where n is the number of processors you want to devote to completing this process. The advantage of doing this is that things are completed much sooner when you use -j4. Older Raspberry Pis (Pre-Pi 2) can't use this option.
  • sudo make install is often the third and final step of the ./configure && make && sudo make install trio. It executes the install command that may be in the make file to move the software that we built into some place like /usr/local. Because that directory is outside of the home directory, root access is required, hence the sudo command.

CMake projects are constructed a bit differently. Generally you have to creat the build/ directory, go to it, and then run a cmake command to execute the makefile in the parent directory like so.

mkdir build && cd build
cmake .. && make && sudo make install

Basically, cmake replaces the need to create a configure script by making one. Don't forget you can use the -j4 argument if you are using a Raspberry Pi 2.

See Also

External Links

Setup

  1. [Assemble the Hardware](Assemble the Hardware)
  2. [Install the Software](Install the Software)
  3. 🆙 [Setup your Raspberry Pi](Setup your Raspberry Pi)
  4. [Download the Missing Parts](Download the Missing Parts)

Typical Utilities

  • [Downloading and extracting with curl and tar](curl and tar)
  • [Browsing with ls and cat](ls and cat)
  • [Searching with grep and find](grep and find)
  • [Filtering with sed and awk](sed and awk)
  • [Piping with less, pv, and tee](less, pv, and tee)
  • Monitor your system with htop
  • Multiplex with tmux

Clone this wiki locally