when building the version number is automatically injected into a header now. This allows for more certainty as to what GF version is being used. Note that this is disabled when building the python wheel as there is no clear way to map this dynamically generated header into the wheel structure. This is however not an issue as the python module has a seperate __version__ variable.
36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
#pragma once
|
|
|
|
#include <format>
|
|
#include <string>
|
|
|
|
namespace gridfire {
|
|
struct version {
|
|
static constexpr int major = @GF_VERSION_MAJOR@;
|
|
static constexpr int minor = @GF_VERSION_MINOR@;
|
|
static constexpr int patch = @GF_VERSION_PATCH@;
|
|
static constexpr const char* tag = "@GF_VERSION_TAG@";
|
|
|
|
static std::string toString() {
|
|
std::string versionStr = std::to_string(major) + "." +
|
|
std::to_string(minor) + "." +
|
|
std::to_string(patch);
|
|
if (std::string(tag) != "") {
|
|
versionStr += "-" + std::string(tag);
|
|
}
|
|
return versionStr;
|
|
}
|
|
};
|
|
}
|
|
|
|
template <>
|
|
struct std::formatter<gridfire::version> : std::formatter<std::string> {
|
|
auto format(const gridfire::version& v, auto& ctx) {
|
|
std::string versionStr = std::to_string(v.major) + "." +
|
|
std::to_string(v.minor) + "." +
|
|
std::to_string(v.patch);
|
|
if (std::string(v.tag) != "") {
|
|
versionStr += "-" + std::string(v.tag);
|
|
}
|
|
return std::formatter<std::string>::format(versionStr, ctx);
|
|
}
|
|
}; |