Skip to content

Commit

Permalink
Merge branch 'trunk' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Mar 13, 2024
2 parents 068b315 + 8193839 commit a6281bc
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 136 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ endif()

# Optionally build a version to be installed inside CCP4
option(BUILD_FOR_CCP4 "Build a version to be installed in CCP4" OFF)
option(GENERATE_DOCUMENTATION "Generate the documentation files using pandoc" OFF)
option(BUILD_DOCUMENTATION "Generate the documentation files using pandoc" OFF)

if(BUILD_FOR_CCP4)
if("$ENV{CCP4}" STREQUAL "" OR NOT EXISTS $ENV{CCP4})
Expand All @@ -60,6 +60,7 @@ endif()
if(MSVC)
# make msvc standards compliant...
add_compile_options(/permissive-)
add_link_options(/NODEFAULTLIB:library)

macro(get_WIN32_WINNT version)
if(WIN32 AND CMAKE_SYSTEM_VERSION)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ automatically. So in theory, building is as simple as:
```console
git clone https://github.com/PDB-REDO/dssp.git
cd dssp
mkdir build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build
cmake --build build
cmake --install build
```
Expand Down
8 changes: 7 additions & 1 deletion changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Version 4.4.4
Version 4.4.6
- Update dependency on libcifpp to version 7

Version 4.4.5
- Changes required for building on Windows

Version 4.4.4
- Fix unit test

Version 4.4.3
- Split the code in a sub project for libdssp and the main
code for the executable.
Expand Down
142 changes: 11 additions & 131 deletions cmake/VersionString.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ cmake_minimum_required(VERSION 3.15)
variables contained in the revision file.
#]=======================================================================]

# Record the location of this module now, not at the time the CMakeLists.txt
# is being processed
get_filename_component(_current_cmake_module_dir ${CMAKE_CURRENT_LIST_FILE} PATH)

# First locate a .git file or directory.
function(_get_git_dir _start_dir _variable)

Expand Down Expand Up @@ -233,7 +237,11 @@ function(write_version_header dir)

if(res EQUAL 0)
set(REVISION_STRING "${out}")
else()
message(STATUS "Git hash not found, does this project has a 'build' tag?")
endif()
else()
message(STATUS "Git hash not found")
endif()

# Check the revision string, if it matches we fill in the required info
Expand All @@ -255,141 +263,13 @@ function(write_version_header dir)
if(VERSION_STRING_OPTION_LIB_NAME)
set(VAR_PREFIX "${VERSION_STRING_OPTION_LIB_NAME}")
set(IDENT_PREFIX "${VERSION_STRING_OPTION_LIB_NAME}_")
set(BOOL_IS_MAIN "false")
else()
set(VAR_PREFIX "")
set(IDENT_PREFIX "")
set(BOOL_IS_MAIN "true")
endif()

# And finally, write out the header file
file(WRITE "${VERSION_STRING_DATA}/${file_name}.in" [[// This file was generated by VersionString.cmake

#pragma once

#include <ostream>

constexpr const char k@VAR_PREFIX@ProjectName[] = "@PROJECT_NAME@";
constexpr const char k@VAR_PREFIX@VersionNumber[] = "@PROJECT_VERSION@";
constexpr int k@VAR_PREFIX@BuildNumber = @BUILD_NUMBER@;
constexpr const char k@VAR_PREFIX@RevisionGitTag[] = "@REVISION_GIT_TAGREF@";
constexpr const char k@VAR_PREFIX@RevisionDate[] = "@REVISION_DATE_TIME@";

#ifndef VERSION_INFO_DEFINED
#define VERSION_INFO_DEFINED 1

namespace version_info_v1
{

class version_info_base
{
public:

static void write(std::ostream &os, bool verbose)
{
auto &s_head = head();
if (s_head != nullptr)
write(s_head, os, verbose);
}

protected:

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)
{
auto &s_head = head();
m_next = s_head;
s_head = this;
}

static void write(const version_info_base *inst, std::ostream &os, bool verbose)
{
if (inst->m_next)
{
write(inst->m_next, os, verbose);

if (not verbose)
return;

os << '-' << std::endl;
}

os << inst->m_name << " version " << inst->m_version << std::endl;

if (verbose)
{
if (inst->m_build_number != 0)
{
os << "build: " << inst->m_build_number << ' ' << inst->m_revision_date << std::endl;
if (inst->m_git_tag[0] != 0)
os << "git tag: " << inst->m_git_tag << std::endl;
}
}
}

using version_info_ptr = version_info_base *;

static version_info_ptr &head()
{
static version_info_ptr s_head = nullptr;
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>
class version_info : public version_info_base
{
public:
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
{
register_object()
{
static implementation_type s_instance;
}
};

template<register_object&> struct reference_object;

static register_object s_registered_object;
static reference_object<s_registered_object> s_referenced_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)
{
version_info_v1::version_info_base::write(os, verbose);
}

#endif

class version_info_@IDENT_PREFIX@impl : public version_info_v1::version_info<version_info_@IDENT_PREFIX@impl>
{
public:
version_info_@IDENT_PREFIX@impl()
: version_info(k@VAR_PREFIX@ProjectName, k@VAR_PREFIX@VersionNumber, k@VAR_PREFIX@BuildNumber, k@VAR_PREFIX@RevisionGitTag, k@VAR_PREFIX@RevisionDate)
{
}
};
]])
configure_file("${VERSION_STRING_DATA}/${file_name}.in" "${dir}/${file_name}" @ONLY)
configure_file("${_current_cmake_module_dir}/revision.hpp.in" "${dir}/${file_name}" @ONLY)
endfunction()

121 changes: 121 additions & 0 deletions cmake/revision.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// This file was generated by VersionString.cmake

#pragma once

#include <ostream>

constexpr const char k@VAR_PREFIX@ProjectName[] = "@PROJECT_NAME@";
constexpr const char k@VAR_PREFIX@VersionNumber[] = "@PROJECT_VERSION@";
constexpr int k@VAR_PREFIX@BuildNumber = @BUILD_NUMBER@;
constexpr const char k@VAR_PREFIX@RevisionGitTag[] = "@REVISION_GIT_TAGREF@";
constexpr const char k@VAR_PREFIX@RevisionDate[] = "@REVISION_DATE_TIME@";

#ifndef VERSION_INFO_DEFINED
#define VERSION_INFO_DEFINED 1

namespace version_info_v1_1
{

class version_info_base
{
public:
static void write_version_string(std::ostream &os, bool verbose)
{
auto s_main = registered_main();
if (s_main != nullptr)
s_main->write(os, verbose);

if (verbose)
{
for (auto lib = registered_libraries(); lib != nullptr; lib = lib->m_next)
{
os << "-\n";
lib->write(os, verbose);
}
}
}

protected:
version_info_base(const char *name, const char *version, int build_number, const char *git_tag, const char *revision_date, bool is_main)
: m_name(name)
, m_version(version)
, m_build_number(build_number)
, m_git_tag(git_tag)
, m_revision_date(revision_date)
{
if (is_main)
registered_main() = this;
else
{
auto &s_head = registered_libraries();
m_next = s_head;
s_head = this;
}
}

void write(std::ostream &os, bool verbose)
{
os << m_name << " version " << m_version << '\n';

if (verbose)
{
if (m_build_number != 0)
{
os << "build: " << m_build_number << ' ' << m_revision_date << '\n';
if (m_git_tag[0] != 0)
os << "git tag: " << m_git_tag << '\n';
}
}
}

using version_info_ptr = version_info_base *;

static version_info_ptr &registered_main()
{
static version_info_ptr s_main = nullptr;
return s_main;
}

static version_info_ptr &registered_libraries()
{
static version_info_ptr s_head = nullptr;
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>
class version_info : public version_info_base
{
public:
using implementation_type = T;

version_info(const char *name, const char *version, int build_number, const char *git_tag, const char *revision_date, bool is_main)
: version_info_base(name, version, build_number, git_tag, revision_date, is_main)
{
}
};

} // namespace version_info_v1_1

inline void write_version_string(std::ostream &os, bool verbose)
{
version_info_v1_1::version_info_base::write_version_string(os, verbose);
}

#endif

const class version_info_@IDENT_PREFIX@impl : public version_info_v1_1::version_info<version_info_@IDENT_PREFIX@impl>
{
public:
version_info_@IDENT_PREFIX@impl()
: version_info(k@VAR_PREFIX@ProjectName, k@VAR_PREFIX@VersionNumber, k@VAR_PREFIX@BuildNumber, k@VAR_PREFIX@RevisionGitTag, k@VAR_PREFIX@RevisionDate, @BOOL_IS_MAIN@)
{
}
} s_version_info_@IDENT_PREFIX@instance;
2 changes: 1 addition & 1 deletion libdssp/src/dssp-io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "dssp-io.hpp"
#include "revision.hpp"

#include <cif++/pdb.hpp>
#include <cif++.hpp>
#include <cif++/dictionary_parser.hpp>

#include <exception>
Expand Down
4 changes: 4 additions & 0 deletions libdssp/src/dssp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#include <numeric>
#include <thread>

#ifdef near
#undef near
#endif

using residue = dssp::residue;
using statistics = dssp::statistics;
using structure_type = dssp::structure_type;
Expand Down

0 comments on commit a6281bc

Please sign in to comment.