make vs ninja

make vs ninja

In this blog post, we'll looking how to build c++ apps with make and ninja.

We'll be using cmake to create the build files.

Sample C++ Hello World Program

#include <iostream>

using namespace std;


int main() { 
    cout << "hello world!" << endl;

}

CMakeLists.txt file :

cmake_minimum_required(VERSION 3.15)
project(myapp)
add_executable(app main.cpp)

Cmake command to generate the build files for Unix Makefiles :

cmake .. -G "Unix Makefiles"

Cmake command to generate the build files for Ninja :

cmake .. -G "Ninja"

To build the application with make :

make -j16

To Build the application with ninja

ninja