Getting ready

We will use the same version.hpp.in as in the previous recipe, and will modify the example.cpp file only minimally, to make it clear that it prints a build-time Git hash:

#include "version.hpp"#include <iostream>int main() {  std::cout << "This code has been built from version " << GIT_HASH << std::endl;}

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.