Creating a "hello world" executable
First, we will create a simple executable from a simple hello world C++ program. The following C++ program will print out Welcome to CMake Best Practices
:
#include <iostream> int main(int, char **) { Â Â std::cout << "Welcome to CMake Best Practices\n"; Â Â return 0; }
To build this, we need to compile it and give the executable a name. Let's see what the CMakeLists.txt
file to build this executable looks like:
cmake_minimum_required(VERSION 3.21) project(     hello_world_standalone     VERSION 1.0     DESCRIPTION"A simple C++ project"     HOMEPAGE_URL https://github.com/PacktPublishing/CMake-Best-       Practices     LANGUAGES CXX ) add_executable(hello_world) target_sources(hello_world PRIVATE src/main.cpp)
With the first line, cmake_minimum_required...