Install CMake

sudo apt-get install libssl-dev
wget https://github.com/Kitware/CMake/releases/download/v3.15.5/cmake-3.15.5.tar.gz
tar xzvf cmake-3.15.5.tar.gz
cd cmake-3.15.5/
./configure
gmake
sudo make install
cmake --version
    cmake version 3.15.5

Write a C++ Pragram

//main.cpp
#include <iostream>

int main(){
    std::cout << "Hello World!" << std::endl;
    return 0;
}

Write a CMakeLists.md file

cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
set(project_name MyApp)
set(CMAKE_CXX_STANDARD 17)
project(${project_name} LANGUAGES CXX)
message(STATUS "==> C++ compiler ID: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "==> C++ compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "==> C++ standard: ${CMAKE_CXX_STANDARD}")
if(NOT CMAKE_BUILD_TYPE)
	set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
endif()
message(STATUS "==> Build type: ${CMAKE_BUILD_TYPE}")

# message(STATUS "==> C++ flags, Debug configuration: ${CMAKE_CXX_FLAGS_DEBUG}")
# message(STATUS "==> C++ flags, Release configuration: ${CMAKE_CXX_FLAGS_RELEASE}")
# message(STATUS "==> C++ flags, Release configuration with Debug info: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
# message(STATUS "==> C++ flags, minimal Release configuration: ${CMAKE_CXX_FLAGS_MINSIZEREL}")

add_executable(${project_name} main.cpp)

Build the program

mkdir -p build; cd build
cmake ..
make

Run the program

./MyApp 
Hello World!