Getting ready

This recipe will build the "Hello, World" executable from the following source code (hello-world.cpp):

#include <cstdlib>#include <iostream>#include <string>std::string say_hello() { return std::string("Hello, CMake superbuild world!"); }int main() {  std::cout << say_hello() << std::endl;  return EXIT_SUCCESS;}

The project is structured as follows, with a root CMakeLists.txt, and a src/CMakeLists.txt file:

.├── CMakeLists.txt└── src    ├── CMakeLists.txt    └── hello-world.cpp

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.