Getting ready

We will still use mostly the same code as in the previous recipe, but we will need to modify src/CMakeLists.txt and the Message.hpp header file. The latter will include the new, autogenerated header file, messageExport.h:

#pragma once#include <iosfwd>#include <string>#include "messageExport.h"class message_EXPORT Message {public:  Message(const std::string &m) : message_(m) {}  friend std::ostream &operator<<(std::ostream &os, Message &obj) {    return obj.printObject(os);  }private:  std::string message_;  std::ostream &printObject(std::ostream &os);};std::string getUUID();

The message_EXPORT preprocessor directive was introduced in the declaration of the Message class. This directive will let the compiler generate symbols that are ...

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.