Skip to content

Commit

Permalink
ENH: Additions to nxrunner for detailed version information. (BlueQua…
Browse files Browse the repository at this point in the history
…rtzSoftware#752)

* ENH: additions to nxrunner for detailed version information.

Signed-off-by: Michael Jackson <[email protected]>

* Fix QString usages.

Signed-off-by: Michael Jackson <[email protected]>

* Update cmake/ComplexVersion.hpp

Co-authored-by: Nathan Young <[email protected]>

* Address Code Review Feedback

Signed-off-by: Michael Jackson <[email protected]>

* Fix failing unit test

Signed-off-by: Michael Jackson <[email protected]>

* Export out the ComplexVersion namespace symbols

Signed-off-by: Michael Jackson <[email protected]>

---------

Signed-off-by: Michael Jackson <[email protected]>
Co-authored-by: Nathan Young <[email protected]>
  • Loading branch information
imikejackson and nyoungbq committed Oct 26, 2023
1 parent 8c0c279 commit 6a32bc6
Show file tree
Hide file tree
Showing 8 changed files with 452 additions and 21 deletions.
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

0 comments on commit 6a32bc6

Please sign in to comment.