Getting ready

We will use the following arch-dependent.cpp example source:

#include <cstdlib>#include <iostream>#include <string>#define STRINGIFY(x) #x#define TOSTRING(x) STRINGIFY(x)std::string say_hello() {  std::string arch_info(TOSTRING(ARCHITECTURE));  arch_info += std::string(" architecture. ");#ifdef IS_32_BIT_ARCH  return arch_info + std::string("Compiled on a 32 bit host processor.");#elif IS_64_BIT_ARCH  return arch_info + std::string("Compiled on a 64 bit host processor.");#else  return arch_info + std::string("Neither 32 nor 64 bit, puzzling ...");#endif}
int main() {  std::cout << say_hello() << std::endl;  return EXIT_SUCCESS;}

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.