mirror of
https://github.com/PDB-REDO/libcifpp.git
synced 2026-06-04 22:14:24 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ad7e47b2e | ||
|
|
f72a2c69d0 | ||
|
|
84d9275cb8 | ||
|
|
1b7c387c8b | ||
|
|
2f1adbd22c | ||
|
|
65031523a6 | ||
|
|
02cc0fa0f6 | ||
|
|
1e1afa023f |
@@ -25,7 +25,7 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
# set the project name
|
||||
project(libcifpp VERSION 5.2.0 LANGUAGES CXX)
|
||||
project(libcifpp VERSION 5.2.1 LANGUAGES CXX)
|
||||
|
||||
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
@@ -36,6 +36,7 @@ include(CheckLibraryExists)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(GenerateExportHeader)
|
||||
include(CTest)
|
||||
|
||||
set(CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
@@ -83,8 +84,6 @@ else()
|
||||
endif()
|
||||
|
||||
# Unit tests
|
||||
option(ENABLE_TESTING "Build test exectuables" OFF)
|
||||
|
||||
if(BUILD_FOR_CCP4)
|
||||
if("$ENV{CCP4}" STREQUAL "" OR NOT EXISTS $ENV{CCP4})
|
||||
message(FATAL_ERROR "A CCP4 built was requested but CCP4 was not sourced")
|
||||
@@ -395,11 +394,10 @@ install(FILES
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
||||
set(cifpp_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR})
|
||||
set_target_properties(cifpp PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION "${cifpp_MAJOR_VERSION}.${cifpp_MINOR_VERSION}"
|
||||
INTERFACE_cifpp_MAJOR_VERSION ${cifpp_MAJOR_VERSION})
|
||||
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
|
||||
INTERFACE_cifpp_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
|
||||
|
||||
set_property(TARGET cifpp APPEND PROPERTY
|
||||
COMPATIBLE_INTERFACE_STRING cifpp_MAJOR_VERSION
|
||||
@@ -411,9 +409,7 @@ write_basic_package_version_file(
|
||||
COMPATIBILITY AnyNewerVersion
|
||||
)
|
||||
|
||||
if(ENABLE_TESTING)
|
||||
enable_testing()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
find_package(Boost REQUIRED)
|
||||
|
||||
list(APPEND CIFPP_tests unit-v2 unit-3d format model rename-compound sugar spinner)
|
||||
|
||||
@@ -108,13 +108,9 @@ This checks out the source code from github, creates a new directory
|
||||
where cmake stores its files. Run a configure, build the code and then
|
||||
it installs the library and auxiliary files.
|
||||
|
||||
If you want to run the tests before installing, you should add `-DENABLE_TESTING=ON`
|
||||
to the first cmake command. So that would be:
|
||||
Tests are created by default, and to test the code you can run:
|
||||
|
||||
```console
|
||||
git clone https://github.com/PDB-REDO/libcifpp.git --recurse-submodules
|
||||
cd libcifpp
|
||||
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$HOME/.local -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=ON
|
||||
cmake --build build
|
||||
ctest --test-dir build
|
||||
```
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
Version 5.2.1
|
||||
- New versionstring module
|
||||
- small fixes for generating documentation
|
||||
- correctly setting SONAME
|
||||
|
||||
Version 5.2.0
|
||||
- With lots of documentation
|
||||
- Refactored coloured text output
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -255,141 +259,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()
|
||||
|
||||
|
||||
138
cmake/revision.hpp.in
Normal file
138
cmake/revision.hpp.in
Normal file
@@ -0,0 +1,138 @@
|
||||
// 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 << '-' << std::endl;
|
||||
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 << std::endl;
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
if (m_build_number != 0)
|
||||
{
|
||||
os << "build: " << m_build_number << ' ' << m_revision_date << std::endl;
|
||||
if (m_git_tag[0] != 0)
|
||||
os << "git tag: " << m_git_tag << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using version_info_ptr = version_info_base *;
|
||||
|
||||
static version_info_ptr ®istered_main()
|
||||
{
|
||||
static version_info_ptr s_main = nullptr;
|
||||
return s_main;
|
||||
}
|
||||
|
||||
static version_info_ptr ®istered_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)
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
} // 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
|
||||
|
||||
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@)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -7,36 +7,39 @@ set(CIFPP_PUBLIC_HEADER_DIR ${PROJECT_SOURCE_DIR}/include)
|
||||
file(GLOB_RECURSE CIFPP_PUBLIC_HEADERS ${CIFPP_PUBLIC_HEADER_DIR}/*.hpp)
|
||||
|
||||
set(DOXYGEN_INPUT_DIR ${CIFPP_PUBLIC_HEADER_DIR})
|
||||
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml)
|
||||
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/xml)
|
||||
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/index.xml)
|
||||
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
|
||||
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||
|
||||
#Replace variables inside @@ with the current values
|
||||
# Replace variables inside @@ with the current values
|
||||
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
|
||||
|
||||
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR}/xml) #Doxygen won't create this for us
|
||||
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
|
||||
BYPRODUCTS ${DOXYGEN_OUTPUT_DIR}/xml
|
||||
DEPENDS ${CIFPP_PUBLIC_HEADERS} ${DOXYFILE_OUT}
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
|
||||
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
|
||||
COMMENT "Generating docs")
|
||||
add_custom_command(
|
||||
OUTPUT ${DOXYGEN_OUTPUT_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOXYGEN_OUTPUT_DIR})
|
||||
|
||||
add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})
|
||||
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
|
||||
BYPRODUCTS ${DOXYGEN_OUTPUT_DIR}
|
||||
DEPENDS ${DOXYGEN_OUTPUT_DIR} ${CIFPP_PUBLIC_HEADERS} ${DOXYFILE_OUT}
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
|
||||
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
|
||||
COMMENT "Generating docs")
|
||||
|
||||
add_custom_target("Doxygen-${PROJECT_NAME}" ALL DEPENDS ${DOXYGEN_INDEX_FILE})
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_SOURCE_DIR}/conf.py @ONLY)
|
||||
|
||||
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx)
|
||||
|
||||
add_custom_target(Sphinx ALL
|
||||
COMMAND ${SPHINX_EXECUTABLE} -b html
|
||||
-Dbreathe_projects.${PROJECT_NAME}=${DOXYGEN_OUTPUT_DIR}/xml
|
||||
${SPHINX_SOURCE} ${SPHINX_BUILD}
|
||||
DEPENDS ${DOXYGEN_INDEX_FILE}
|
||||
BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/api
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating documentation with Sphinx")
|
||||
add_custom_target("Sphinx-${PROJECT_NAME}" ALL
|
||||
COMMAND ${SPHINX_EXECUTABLE} -b html
|
||||
-Dbreathe_projects.${PROJECT_NAME}=${DOXYGEN_OUTPUT_DIR}
|
||||
${SPHINX_SOURCE} ${SPHINX_BUILD}
|
||||
DEPENDS ${DOXYGEN_INDEX_FILE}
|
||||
BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/api
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating documentation with Sphinx")
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/sphinx/ DESTINATION ${CMAKE_INSTALL_DOCDIR} PATTERN .doctrees EXCLUDE)
|
||||
|
||||
@@ -77,6 +77,9 @@ extern CIFPP_EXPORT int VERBOSE;
|
||||
/// return the git 'build' number
|
||||
std::string get_version_nr();
|
||||
|
||||
/// return the width of the current output terminal, or 80 if it cannot be determined
|
||||
uint32_t get_terminal_width();
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
namespace colour
|
||||
|
||||
@@ -43,11 +43,6 @@
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
|
||||
#if not defined(_WIN32)
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
#endif
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -88,6 +83,8 @@ uint32_t get_terminal_width()
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
#include <limits.h>
|
||||
|
||||
uint32_t get_terminal_width()
|
||||
|
||||
Reference in New Issue
Block a user