CMake Project File
The entry point for a CMake project is a file called
Let's set up the top level
CMakeLists.txt in the project root folder.
The top level
CMakeLists.txt must start with command
cmake_minimum_required. For this exercise we will be using CMake version
Next is the
Our time machine project should be named TimeMachine, should have version 1.0.2 and its language should be set to C++.
Building a CMake project
In order to build a CMake project we need a working directory for the build.
In our example we use a folder
build in the project folder.
For project initialization you must change into the build folder. But you only need to initialize a build folder once.
# create the build folder
mkdir -p /project/build
# for initialization we must change into the build folder
cmake -G Ninja /project
# build the project
cmake --build /project/build
-G of the
cmake command line tool sets the generator.
There are generators for different build systems like make or ninja.
Also, there are generators to create projects for IDEs like eclipse or visual studio.