- Published on
Using CMake
- Authors
- Name
- Yair Mark
- @yairmark
Today I came across a project that used CMake. You can tell a project uses CMake as it will have a CMakeLists.txt file in the root of the project. Looking at the CMake site it is not immediately clear how to use it. After a bit of Googling I came across this excellent blog post that gets you up and running pretty fast. Based on this blog post CMake works as follows:
- You define your build steps in a
CMakeLists.txtfile - CMake has the concept of generators which are alternate build system files that
CMakeList.txtis converted to when runningcmake - The default generator (when not specifying one) is
makeas in makefiles
The easiest way to run CMake in a project that has it is:
- Go to the root of the project
- Create a new directory and cd into it e.g.
mkdir build && cd &_
- Run cmake which generates a makefile and meta data in the
_builddirectory
cmake ..
- Finally run make:
make
sudo make install
- You may not have to
sudodepending on what you are installing - If you are running this in a
DockerFileyou do not need to and cannot run commands assudo