Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dssp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
dssp
Commits
d7a23b87
Unverified
Commit
d7a23b87
authored
Aug 16, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated version string
parent
b0af4c90
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
45 deletions
+51
-45
cmake/VersionString.cmake
+51
-45
No files found.
cmake/VersionString.cmake
View file @
d7a23b87
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2021-2023
NKI/AVL, Netherlands Cancer Institute
# Copyright (c) 2021-2023
Maarten L. Hekkelman
# Redistribution and use in source and binary forms, with or without
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# modification, are permitted provided that the following conditions are met:
...
@@ -30,6 +30,7 @@ cmake_minimum_required(VERSION 3.15)
...
@@ -30,6 +30,7 @@ cmake_minimum_required(VERSION 3.15)
# We want the revision.hpp file to be updated whenever the status of the
# We want the revision.hpp file to be updated whenever the status of the
# git repository changes. Use the same technique as in GetGitRevisionDescription.cmake
# git repository changes. Use the same technique as in GetGitRevisionDescription.cmake
# from https://github.com/rpavlik/cmake-modules
#[=======================================================================[.rst:
#[=======================================================================[.rst:
...
@@ -65,10 +66,8 @@ function(_get_git_dir _start_dir _variable)
...
@@ -65,10 +66,8 @@ function(_get_git_dir _start_dir _variable)
get_filename_component
(
cur_dir
"
${
cur_dir
}
"
DIRECTORY
)
get_filename_component
(
cur_dir
"
${
cur_dir
}
"
DIRECTORY
)
if
(
cur_dir STREQUAL prev_dir OR cur_dir STREQUAL
${
_start_dir
}
)
if
(
cur_dir STREQUAL prev_dir OR cur_dir STREQUAL
${
_start_dir
}
)
# we are not in git since we either hit root or
# we are not in git since we either hit root or
# the CMAKE_SOURCE_DIR which should be the top
# the ${_start_dir} which should be the top
set
(
${
_variable
}
set
(
${
_variable
}
""
PARENT_SCOPE
)
""
PARENT_SCOPE
)
return
()
return
()
endif
()
endif
()
set
(
git_dir
"
${
cur_dir
}
/.git"
)
set
(
git_dir
"
${
cur_dir
}
/.git"
)
...
@@ -248,8 +247,6 @@ function(write_version_header dir)
...
@@ -248,8 +247,6 @@ function(write_version_header dir)
string
(
TIMESTAMP REVISION_DATE_TIME
"%Y-%m-%dT%H:%M:%SZ"
UTC
)
string
(
TIMESTAMP REVISION_DATE_TIME
"%Y-%m-%dT%H:%M:%SZ"
UTC
)
else
()
else
()
message
(
STATUS
"no git info available, cannot update version string"
)
set
(
REVISION_GIT_TAGREF
""
)
set
(
REVISION_GIT_TAGREF
""
)
set
(
BUILD_NUMBER 0
)
set
(
BUILD_NUMBER 0
)
set
(
REVISION_DATE_TIME
""
)
set
(
REVISION_DATE_TIME
""
)
...
@@ -263,6 +260,7 @@ function(write_version_header dir)
...
@@ -263,6 +260,7 @@ function(write_version_header dir)
set
(
IDENT_PREFIX
""
)
set
(
IDENT_PREFIX
""
)
endif
()
endif
()
# And finally, write out the header file
file
(
WRITE
"
${
VERSION_STRING_DATA
}
/
${
file_name
}
.in"
[[// This file was generated by VersionString.cmake
file
(
WRITE
"
${
VERSION_STRING_DATA
}
/
${
file_name
}
.in"
[[// This file was generated by VersionString.cmake
#pragma once
#pragma once
...
@@ -278,38 +276,43 @@ constexpr const char k@VAR_PREFIX@RevisionDate[] = "@REVISION_DATE_TIME@";
...
@@ -278,38 +276,43 @@ constexpr const char k@VAR_PREFIX@RevisionDate[] = "@REVISION_DATE_TIME@";
#ifndef VERSION_INFO_DEFINED
#ifndef VERSION_INFO_DEFINED
#define VERSION_INFO_DEFINED 1
#define VERSION_INFO_DEFINED 1
namespace version_info_v1
{
class version_info_base
class version_info_base
{
{
public:
public:
virtual ~version_info_base() = default;
static void write(std::ostream &os, bool verbose)
static void write(std::ostream &os, bool verbose)
{
{
auto s_head = head();
auto
&
s_head = head();
if (s_head != nullptr)
if (s_head != nullptr)
write(s_head, os, verbose);
write(s_head, os, verbose);
}
}
protected:
protected:
struct instance
version_info_base(const char *name, const char *version, int build_number, const char *git_tag, const char *revision_date)
: m_name(name)
, m_version(version)
, m_build_number(build_number)
, m_git_tag(git_tag)
, m_revision_date(revision_date)
{
{
const char *m_name;
auto &s_head = head();
const char *m_version;
m_next = s_head;
int m_build;
s_head = this;
const char *m_git_tag;
}
const char *m_revision_date;
instance *m_next = nullptr;
};
static void write(const
instanc
e *inst, std::ostream &os, bool verbose)
static void write(const
version_info_bas
e *inst, std::ostream &os, bool verbose)
{
{
if (inst->m_next
!= nullptr
)
if (inst->m_next)
{
{
write(inst->m_next, os, verbose);
write(inst->m_next, os, verbose);
if (not verbose)
if (not verbose)
return;
return;
os << '-' << std::endl;
os << '-' << std::endl;
}
}
...
@@ -317,24 +320,29 @@ class version_info_base
...
@@ -317,24 +320,29 @@ class version_info_base
if (verbose)
if (verbose)
{
{
if (inst->m_build != 0)
if (inst->m_build
_number
!= 0)
{
{
os << "build: " << inst->m_build << ' ' << inst->m_revision_date << std::endl;
os << "build: " << inst->m_build
_number
<< ' ' << inst->m_revision_date << std::endl;
if (inst->m_git_tag[0] != 0)
if (inst->m_git_tag[0] != 0)
os << "git tag: " << inst->m_git_tag << std::endl;
os << "git tag: " << inst->m_git_tag << std::endl;
}
}
else
os << "No revision information available" << std::endl;
}
}
}
}
using
instance_ptr = instanc
e *;
using
version_info_ptr = version_info_bas
e *;
static
instance
_ptr &head()
static
version_info
_ptr &head()
{
{
static
instance
_ptr s_head = nullptr;
static
version_info
_ptr s_head = nullptr;
return s_head;
return s_head;
}
}
const char *m_name;
const char *m_version;
int m_build_number;
const char *m_git_tag;
const char *m_revision_date;
version_info_base *m_next = nullptr;
};
};
template<typename T>
template<typename T>
...
@@ -343,45 +351,43 @@ class version_info : public version_info_base
...
@@ -343,45 +351,43 @@ class version_info : public version_info_base
public:
public:
using implementation_type = T;
using implementation_type = T;
version_info(const char *name, const char *version, int build_number, const char *git_tag, const char *revision_date)
: version_info_base(name, version, build_number, git_tag, revision_date)
{
}
struct register_object
struct register_object
{
{
register_object()
register_object()
{
{
auto &s_head = version_info_base::head();
static implementation_type s_instance;
static instance s_next{
implementation_type::name(),
implementation_type::version(),
implementation_type::build_number(),
implementation_type::git_tag(),
implementation_type::revision_date(),
s_head };
s_head = &s_next;
}
}
};
};
template<register_object&> struct refer
r
ence_object;
template<register_object&> struct reference_object;
static register_object s_registered_object;
static register_object s_registered_object;
static refer
rence_object<s_registered_object> s_refer
renced_object;
static refer
ence_object<s_registered_object> s_refe
renced_object;
};
};
template<typename T> typename version_info<T>::register_object version_info<T>::s_registered_object;
template<typename T> typename version_info<T>::register_object version_info<T>::s_registered_object;
}
inline void write_version_string(std::ostream &os, bool verbose)
inline void write_version_string(std::ostream &os, bool verbose)
{
{
version_info_base::write(os, verbose);
version_info_
v1::version_info_
base::write(os, verbose);
}
}
#endif
#endif
class version_info_@IDENT_PREFIX@impl : public version_info<version_info_@IDENT_PREFIX@impl>
class version_info_@IDENT_PREFIX@impl : public version_info
_v1::version_info
<version_info_@IDENT_PREFIX@impl>
{
{
public:
public:
static constexpr const char *name() { return k@VAR_PREFIX@ProjectName; }
version_info_@IDENT_PREFIX@impl()
static constexpr const char *version() { return k@VAR_PREFIX@VersionNumber; }
: version_info(k@VAR_PREFIX@ProjectName, k@VAR_PREFIX@VersionNumber, k@VAR_PREFIX@BuildNumber, k@VAR_PREFIX@RevisionGitTag, k@VAR_PREFIX@RevisionDate)
static constexpr int build_number() { return k@VAR_PREFIX@BuildNumber; }
{
static constexpr const char *git_tag() { return k@VAR_PREFIX@RevisionGitTag; }
}
static constexpr const char *revision_date() { return k@VAR_PREFIX@RevisionDate; }
};
};
]]
)
]]
)
configure_file
(
"
${
VERSION_STRING_DATA
}
/
${
file_name
}
.in"
"
${
dir
}
/
${
file_name
}
"
@ONLY
)
configure_file
(
"
${
VERSION_STRING_DATA
}
/
${
file_name
}
.in"
"
${
dir
}
/
${
file_name
}
"
@ONLY
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment