CetWriteCXXVersionAPI

cet_write_cxx_version_api
cet_write_cxx_version_api(NAMESPACE      <ns>
                          TYPENAME       <type>
                          [HEADER_FILE   <path>])

Write C++ header and source files defining a compile and runtime API for reporting and checking project version numbers following MAJOR.MINOR.PATCH style versioning.

Identifiers for the C++ namespace and struct holding the API as member functions must be specified using the NAMESPACE and TYPENAME arguments. NAMESPACE may be as many levels deep as you require. For example, setting NAMESPACE to “Foo::Bar” and TYPENAME to “Version” constructs a forward declaration and struct definition:

namespace Foo {
  namespace Bar {
    struct Version;
    }
}

struct Foo::Bar::Version {
  // functions
};

By default the header and source file are output in the current binary directory and named “<type>.h” and “<type>.cc”. This may be modified using the HEADER_FILE argument, supplying <path> as the required output location and name (including extension) of the header. The resultant source file will be output alongside the header with the same name plus an additional .cc extension. If <path> is supplied as a relative path, it is evaluated relative to the current binary directory.

Version component values are taken from the CMake variables <PROJECT_NAME>_VERSION_MAJOR, <PROJECT_NAME>_VERSION_MINOR and <PROJECT_NAME>_VERSION_PATCH are used. A FATAL_ERROR is raised if any of these is not defined. If the variable is defined but empty, the version component is taken as 0.

The header file macros, struct and member functions are documented using Doxygen style markup.

The generated source file includes the header file using an absolute path, so it can be compiled into a target without additional setting of include directories of compile definitions.