How to fix CMake 'make: *** No targets specified and no makefile found. Stop.'

Problem:

You are trying to build a software that is using the CMake build system.

You are trying to run make to build, but you see this error message:

make: *** No targets specified and no makefile found.  Stop.

Solution

Before running make, you need to configure your build using CMake.

The simplest way of doing that is to run

cmake .

Typically you only need to do that once for each project ; CMake will automatically detect changes to CMakeLists.txt when you run make.

After that, you can run make again. If the build is successful, you’ll see a message like this:

[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
[100%] Linking CXX executable main
[100%] Built target main