Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Additions to nxrunner for detailed version information. #752

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,29 @@ list(APPEND COMPLEX_GENERATED_HEADERS
${COMPLEX_GENERATED_PYTHON_HEADER}
)

set(COMPLEX_GENERATED_VERSION_HEADER ${COMPLEX_GENERATED_HEADER_DIR}/ComplexVersion.h)
configure_file(${complex_SOURCE_DIR}/cmake/ComplexVersion.h.in ${COMPLEX_GENERATED_VERSION_HEADER})
# set(COMPLEX_GENERATED_VERSION_HEADER ${COMPLEX_GENERATED_HEADER_DIR}/ComplexVersion.h)
# configure_file(${complex_SOURCE_DIR}/cmake/ComplexVersion.h.in ${COMPLEX_GENERATED_VERSION_HEADER})


set(CMP_VERSION_HDR_TEMPLATE_FILE ${complex_SOURCE_DIR}/cmake/ComplexVersion.hpp)
set(CMP_VERSION_SRC_TEMPLATE_FILE ${complex_SOURCE_DIR}/cmake/ComplexVersion.cpp.in)
set(VERSION_GEN_HEADER_FILE_NAME "ComplexVersion.hpp")

cmpBuildDateRevisionString(GENERATED_HEADER_FILE_PATH "generated/complex/ComplexVersion.hpp"
GENERATED_SOURCE_FILE_PATH "generated/complex/ComplexVersion.cpp"
NAMESPACE complex
PROJECT_NAME complex
EXPORT_MACRO ""
VERSION_MACRO_PATH ""
STRING_CLASS std::string
STRING_INCLUDE "#include <string>"
)



list(APPEND COMPLEX_GENERATED_HEADERS
${COMPLEX_GENERATED_VERSION_HEADER}
${COMPLEX_GENERATED_HEADER_DIR}/ComplexVersion.hpp
${COMPLEX_GENERATED_HEADER_DIR}/ComplexVersion.cpp
)

set(COMPLEX_ALL_HDRS
Expand Down
189 changes: 189 additions & 0 deletions cmake/ComplexVersion.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
/*--------------------------------------------------------------------------
* This file is autogenerated from:
* @CMAKE_CURRENT_LIST_DIR@/ComplexVersion.cpp.in
* during the cmake configuration of your project. If you need to make changes,
* edit the original file NOT THIS FILE.
* --------------------------------------------------------------------------*/

#include "ComplexVersion.hpp"

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::ApplicationName()
{
return {"@PROJECT_PREFIX@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Complete()
{
return {"@VERSION_GEN_VER_MAJOR@.@VERSION_GEN_VER_MINOR@.@VERSION_GEN_VER_PATCH@@VERSION_GEN_VER_SUFFIX@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Major()
{
return {"@VERSION_GEN_VER_MAJOR@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Minor()
{
return {"@VERSION_GEN_VER_MINOR@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Patch()
{
return {"@VERSION_GEN_VER_PATCH@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Suffix()
{
return {"@VERSION_GEN_VER_SUFFIX@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::Package()
{
return {"@VERSION_GEN_VER_MAJOR@.@VERSION_GEN_VER_MINOR@.@VERSION_GEN_VER_PATCH@@VERSION_GEN_VER_SUFFIX@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::PackageComplete()
{
return {"@PROJECT_PREFIX@ Version @VERSION_GEN_VER_MAJOR@.@VERSION_GEN_VER_MINOR@.@VERSION_GEN_VER_PATCH@@VERSION_GEN_VER_SUFFIX@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::BuildDate()
{
return {"@VERSION_BUILD_DATE@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::GitHashShort()
{
return {"@VERSION_GEN_GIT_HASH_SHORT@"};
}

// -----------------------------------------------------------------------------
@GVS_STRING_CLASS@ @VERSION_GEN_NAMESPACE@::Version::GitHash()
{
return {"@GVS_GIT_HASH@"};
}

// -----------------------------------------------------------------------------
@VERSION_GEN_NAMESPACE@::Version::AppVersion::AppVersion() = default;

// -----------------------------------------------------------------------------
@VERSION_GEN_NAMESPACE@::Version::AppVersion::AppVersion(int majorNum, int minorNum, int patchNum)
{
m_MajorNum = majorNum;
m_MinorNum = minorNum;
m_PatchNum = patchNum;
}

// -----------------------------------------------------------------------------
@VERSION_GEN_NAMESPACE@::Version::AppVersion::~AppVersion() = default;

// -----------------------------------------------------------------------------
@VERSION_GEN_NAMESPACE@::Version::AppVersion::AppVersion(const @VERSION_GEN_NAMESPACE@::Version::AppVersion& rhs)
{
m_MajorNum = rhs.m_MajorNum;
m_MinorNum = rhs.m_MinorNum;
m_PatchNum = rhs.m_PatchNum;
}

// -----------------------------------------------------------------------------
@VERSION_GEN_NAMESPACE@::Version::AppVersion& @VERSION_GEN_NAMESPACE@::Version::AppVersion::operator=(const AppVersion& rhs) = default;

// -----------------------------------------------------------------------------
bool @VERSION_GEN_NAMESPACE@::Version::AppVersion::operator==(const @VERSION_GEN_NAMESPACE@::Version::AppVersion& rhs)
{
return (m_MajorNum == rhs.m_MajorNum && m_MinorNum == rhs.m_MinorNum && m_PatchNum == rhs.m_PatchNum);
}

// -----------------------------------------------------------------------------
bool @VERSION_GEN_NAMESPACE@::Version::AppVersion::operator>(const @VERSION_GEN_NAMESPACE@::Version::AppVersion& rhs)
{
if(m_MajorNum > rhs.m_MajorNum)
{
return true;
}

if(m_MajorNum == rhs.m_MajorNum)
{
if(m_MinorNum > rhs.m_MinorNum)
{
return true;
}

if(m_MinorNum == rhs.m_MinorNum)
{
return m_PatchNum > rhs.m_PatchNum;
}
return false;
}
return false;
}

// -----------------------------------------------------------------------------
bool @VERSION_GEN_NAMESPACE@::Version::AppVersion::operator<(const @VERSION_GEN_NAMESPACE@::Version::AppVersion& rhs)
{
if(m_MajorNum < rhs.m_MajorNum)
{
return true;
}

if(m_MajorNum == rhs.m_MajorNum)
{
if(m_MinorNum < rhs.m_MinorNum)
{
return true;
}

if(m_MinorNum == rhs.m_MinorNum)
{
return m_PatchNum < rhs.m_PatchNum;
}
return false;
}
return false;
}

// -----------------------------------------------------------------------------
int @VERSION_GEN_NAMESPACE@::Version::AppVersion::getMajorNum()
{
return m_MajorNum;
}

// -----------------------------------------------------------------------------
int @VERSION_GEN_NAMESPACE@::Version::AppVersion::getMinorNum()
{
return m_MinorNum;
}

// -----------------------------------------------------------------------------
int @VERSION_GEN_NAMESPACE@::Version::AppVersion::getPatchNum()
{
return m_PatchNum;
}

// -----------------------------------------------------------------------------
void @VERSION_GEN_NAMESPACE@::Version::AppVersion::setMajorNum(int major)
{
m_MajorNum = major;
}

// -----------------------------------------------------------------------------
void @VERSION_GEN_NAMESPACE@::Version::AppVersion::setMinorNum(int minor)
{
m_MinorNum = minor;
}

// -----------------------------------------------------------------------------
void @VERSION_GEN_NAMESPACE@::Version::AppVersion::setPatchNum(int patch)
{
m_PatchNum = patch;
}
8 changes: 0 additions & 8 deletions cmake/ComplexVersion.h.in

This file was deleted.

52 changes: 52 additions & 0 deletions cmake/ComplexVersion.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma once

#include "complex/complex_export.hpp"

#include <string>

namespace complex::Version
{

COMPLEX_EXPORT std::string ApplicationName();
COMPLEX_EXPORT std::string Complete();
COMPLEX_EXPORT std::string Major();
COMPLEX_EXPORT std::string Minor();
COMPLEX_EXPORT std::string Patch();
COMPLEX_EXPORT std::string Suffix();
COMPLEX_EXPORT std::string Package();
COMPLEX_EXPORT std::string PackageComplete();
COMPLEX_EXPORT std::string BuildDate();
COMPLEX_EXPORT std::string GitHashShort();
COMPLEX_EXPORT std::string GitHash();

class COMPLEX_EXPORT AppVersion
{
public:
AppVersion();
AppVersion(int majorNum, int minorNum, int patchNum);

AppVersion(const AppVersion&);
AppVersion(const AppVersion&&) = delete;
AppVersion& operator=(const AppVersion&);
AppVersion& operator=(AppVersion&&) = delete;

bool operator==(const AppVersion&);
bool operator>(const AppVersion&);
bool operator<(const AppVersion&);

virtual ~AppVersion();

int getMajorNum();
int getMinorNum();
int getPatchNum();

void setMajorNum(int major);
void setMinorNum(int minor);
void setPatchNum(int patch);

private:
int m_MajorNum = -1;
int m_MinorNum = -1;
int m_PatchNum = -1;
};
} // namespace complex::Version
Loading
Loading