Commit 031d9ea6 by Maarten L. Hekkelman

Updated packaging

parent f4fcf3c2
...@@ -6,3 +6,4 @@ mkdssp ...@@ -6,3 +6,4 @@ mkdssp
build build
.gdb_history .gdb_history
**/*.dssp **/*.dssp
src/revision.hpp
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
# set the project name # set the project name
project(mkdssp VERSION 4.1.0 LANGUAGES CXX) project(mkdssp VERSION 4.1.1 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
...@@ -37,7 +37,6 @@ include(CMakePackageConfigHelpers) ...@@ -37,7 +37,6 @@ include(CMakePackageConfigHelpers)
include(Dart) include(Dart)
include(FindFilesystem) include(FindFilesystem)
include(GenerateExportHeader) include(GenerateExportHeader)
include(AddGitSubmodule)
set(CXX_EXTENSIONS OFF) set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
...@@ -81,7 +80,7 @@ endif() ...@@ -81,7 +80,7 @@ endif()
# Create a revision file, containing the current git version info # Create a revision file, containing the current git version info
include(VersionString) include(VersionString)
write_version_header() write_version_header("${PROJECT_SOURCE_DIR}/src")
# Optionally use mrc to create resources # Optionally use mrc to create resources
find_package(Mrc) find_package(Mrc)
...@@ -92,23 +91,18 @@ else() ...@@ -92,23 +91,18 @@ else()
message(WARNING "Not using resources since mrc was not found") message(WARNING "Not using resources since mrc was not found")
endif() endif()
if(USE_RSRC)
set(USE_RSRC 1)
message("Using resources compiled with ${MRC}")
add_compile_definitions(USE_RSRC)
endif()
set(CMAKE_THREAD_PREFER_PTHREAD) set(CMAKE_THREAD_PREFER_PTHREAD)
set(THREADS_PREFER_PTHREAD_FLAG) set(THREADS_PREFER_PTHREAD_FLAG)
find_package(Threads) find_package(Threads)
if(NOT PDB_REDO_META) if(NOT PDB_REDO_META)
add_git_submodule(date EXCLUDE_FROM_ALL) find_package(libconfig QUIET)
if(NOT libconfig_FOUND)
add_subdirectory(libconfig EXCLUDE_FROM_ALL)
endif()
find_package(gxrio REQUIRED) find_package(cifpp 5.0.4 REQUIRED)
find_package(libconfig REQUIRED)
find_package(cifpp 5.0.0 REQUIRED)
endif() endif()
# The DSSP code is in a separate library, optionally to be used by others # The DSSP code is in a separate library, optionally to be used by others
...@@ -124,9 +118,10 @@ add_executable(mkdssp ...@@ -124,9 +118,10 @@ add_executable(mkdssp
$<TARGET_OBJECTS:dssp_library>) $<TARGET_OBJECTS:dssp_library>)
target_include_directories(mkdssp PRIVATE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/date/include) target_include_directories(mkdssp PRIVATE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/date/include)
target_link_libraries(mkdssp PRIVATE dssp_library cifpp::cifpp libconfig::libconfig gxrio::gxrio) target_link_libraries(mkdssp PRIVATE dssp_library cifpp::cifpp libconfig::libconfig)
if(USE_RSRC) if(USE_RSRC)
message("Using resources compiled with ${MRC}")
mrc_target_resources(mkdssp ${CIFPP_SHARE_DIR}/mmcif_pdbx.dic ${CIFPP_SHARE_DIR}/mmcif_ddl.dic) mrc_target_resources(mkdssp ${CIFPP_SHARE_DIR}/mmcif_pdbx.dic ${CIFPP_SHARE_DIR}/mmcif_ddl.dic)
endif() endif()
...@@ -161,7 +156,7 @@ if(ENABLE_TESTING) ...@@ -161,7 +156,7 @@ if(ENABLE_TESTING)
${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include
) )
target_link_libraries(unit-test-dssp PRIVATE dssp_library cifpp::cifpp date::date Boost::boost) target_link_libraries(unit-test-dssp PRIVATE dssp_library cifpp::cifpp Boost::boost)
if(MSVC) if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions # Specify unwind semantics so that MSVC knowns how to handle exceptions
......
Version 4.1.1
- Better packaging
Version 4.1.0 Version 4.1.0
- Based on new libcifpp version 5 - Based on new libcifpp version 5
......
cmake_minimum_required(VERSION 3.16..3.19)
function(add_git_submodule dir)
# add a Git submodule directory to CMake, assuming the
# Git submodule directory is a CMake project.
#
# Usage: in CMakeLists.txt
#
# include(AddGitSubmodule.cmake)
# add_git_submodule(mysubmod_dir)
find_package(Git REQUIRED)
if(NOT EXISTS ${dir}/CMakeLists.txt)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY)
else()
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()
endif()
set(ENABLE_TESTING OFF)
add_subdirectory(${dir} ${ARGV})
endfunction(add_git_submodule)
\ No newline at end of file
...@@ -25,7 +25,12 @@ ...@@ -25,7 +25,12 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
# Create a revision file, containing the current git version info, if any # Create a revision file, containing the current git version info, if any
function(write_version_header) function(write_version_header dir)
# parameter check
if(NOT IS_DIRECTORY ${dir})
message(FATAL_ERROR "First parameter to write_version_header should be a directory where the final revision.hpp file will be placed")
endif()
include(GetGitRevisionDescription) include(GetGitRevisionDescription)
if(NOT(GIT-NOTFOUND OR HEAD-HASH-NOTFOUND)) if(NOT(GIT-NOTFOUND OR HEAD-HASH-NOTFOUND))
git_describe_working_tree(BUILD_VERSION_STRING --match=build --dirty) git_describe_working_tree(BUILD_VERSION_STRING --match=build --dirty)
...@@ -39,14 +44,13 @@ function(write_version_header) ...@@ -39,14 +44,13 @@ function(write_version_header)
endif() endif()
endif() endif()
else() else()
set(BUILD_VERSION_STRING "no git info available") message(WARNING "no git info available, cannot update version string")
endif() endif()
include_directories(${PROJECT_BINARY_DIR} PRIVATE)
string(TIMESTAMP BUILD_DATE_TIME "%Y-%m-%dT%H:%M:%SZ" UTC) string(TIMESTAMP BUILD_DATE_TIME "%Y-%m-%dT%H:%M:%SZ" UTC)
if(ARGC GREATER 0) if(ARGC GREATER 1)
set(VAR_PREFIX "${ARGV0}") set(VAR_PREFIX "${ARGV1}")
endif() endif()
file(WRITE "${PROJECT_BINARY_DIR}/revision.hpp.in" [[// Generated revision file file(WRITE "${PROJECT_BINARY_DIR}/revision.hpp.in" [[// Generated revision file
...@@ -72,6 +76,6 @@ inline void write_version_string(std::ostream &os, bool verbose) ...@@ -72,6 +76,6 @@ inline void write_version_string(std::ostream &os, bool verbose)
} }
} }
]]) ]])
configure_file("${PROJECT_BINARY_DIR}/revision.hpp.in" "${PROJECT_BINARY_DIR}/revision.hpp" @ONLY) configure_file("${PROJECT_BINARY_DIR}/revision.hpp.in" "${dir}/revision.hpp" @ONLY)
endfunction() endfunction()
Subproject commit 22ceabf205d8d678710a43154da5a06b701c5830
# Copyright Maarten L. Hekkelman, 2022
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.16)
# set the project name
project(libconfig VERSION 1.2.0 LANGUAGES CXX)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(Dart)
set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The minimum version of C++ required for this library")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(ENABLE_TESTING "Build the unit test applications" OFF)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
if(MSVC)
# make msvc standards compliant...
add_compile_options(/permissive-)
macro(get_WIN32_WINNT version)
if(WIN32 AND CMAKE_SYSTEM_VERSION)
set(ver ${CMAKE_SYSTEM_VERSION})
string(REPLACE "." "" ver ${ver})
string(REGEX REPLACE "([0-9])" "0\\1" ver ${ver})
set(${version} "0x${ver}")
endif()
endmacro()
get_WIN32_WINNT(ver)
add_definitions(-D_WIN32_WINNT=${ver})
endif()
add_library(libconfig INTERFACE)
add_library(libconfig::libconfig ALIAS libconfig)
target_include_directories(libconfig INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# adding header sources just helps IDEs
target_sources(libconfig INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>$<INSTALL_INTERFACE:include>/cfg.hpp
)
set_target_properties(libconfig PROPERTIES PUBLIC_HEADER include/cfg.hpp)
# installation
set(version_config "${CMAKE_CURRENT_BINARY_DIR}/libconfigConfigVersion.cmake")
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
write_basic_package_version_file("${version_config}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(TARGETS libconfig
EXPORT libconfigConfig
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
DIRECTORY include/cfg
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT Devel
)
export(TARGETS libconfig NAMESPACE libconfig:: FILE libconfigTargets.cmake)
if(WIN32 AND NOT CYGWIN)
set(CONFIG_LOC CMake)
else()
set(CONFIG_LOC "${CMAKE_INSTALL_LIBDIR}/cmake/libconfig")
endif()
configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/libconfigConfig.cmake.in
${PROJECT_SOURCE_DIR}/cmake/libconfigConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libconfig
PATH_VARS INCLUDE_INSTALL_DIR
)
install(EXPORT libconfigConfig
FILE libconfigTargets.cmake
NAMESPACE libconfig::
DESTINATION ${CONFIG_LOC})
install(
FILES cmake/libconfigConfig.cmake "${version_config}"
DESTINATION ${CONFIG_LOC})
if(ENABLE_TESTING)
enable_testing()
add_executable(libconfig-unit-test ${PROJECT_SOURCE_DIR}/test/unit-test.cpp)
target_link_libraries(libconfig-unit-test libconfig::libconfig)
if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
target_compile_options(libconfig-unit-test PRIVATE /EHsc)
endif()
add_test(NAME libconfig-unit-test
COMMAND $<TARGET_FILE:libconfig-unit-test> -- ${PROJECT_SOURCE_DIR}/test)
endif()
# libconfig
A library for parsing command line arguments and making them available throughout a program.
## Synopsis
```c++
#include <cfg.hpp>
int VERBOSE = 0;
int main(int argc, char * const argv[])
{
// config is a singleton class
auto &config = cfg::config::instance();
// Tell config what options to accept
// This can be done more than once, replacing
// the current set of options.
config.init("usage: test [options] input output",
cfg::make_option("verbose,v", "Use verbose output"),
cfg::make_option("help,h", "Show this help"),
cfg::make_option<std::string>("opt1", "foo", "First option"),
cfg::make_option<std::string>("config", "Name of a config file to use"),
cfg::make_option<float>("float-value,f", "Another option")
);
// Do the parsing of argv
config.parse(argc, argv);
// Set verbose based on number of times the
// -v or --verbose flag was passed
VERBOSE = config.count("verbose");
// Check for the help flag
if (config.has("help"))
{
// print out the options to the screen
std::cout << config << std::endl;
exit(0);
}
// Optionally read a config file
// Config file is by default called myapp.conf
// but can be overridden with the --config parameter
// Files will be located in current dictory and /etc
if (config.has("config"))
config.parse_config_file("config", "myapp.conf",
{ fs::current_path().string(), "/etc/" }
);
// Operands are parameters that are not options
// E.g. filenames to process
if (config.operands().size() != 2)
{
std::cerr << config << std::endl;
exit(1);
}
std::filesystem::path input = config.operands().front();
std::filesystem::path output = config.operands().back();
// Get values from options with a value
std::option1 = config.get<std::string>("opt1");
float option2 = 3.14;
if (config.has("float-value"))
option2 = config.get<float>("float-value");
... etc
}
```
Version 1.1.1
- Better support for older GCC compilers
Version 1.2.0
- New, tuples base implementation
- Add 'usage' parameter to init
Version 1.1.0
- Parse config files
Version 1.0.2
- Fix get_terminal_width. Should be inline of course.
Version 1.0.1
- printing options, word-wrapped
Version 1.0.0
- initial release
\ No newline at end of file
####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was libconfigConfig.cmake.in ########
get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
macro(set_and_check _var _file)
set(${_var} "${_file}")
if(NOT EXISTS "${_file}")
message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
endif()
endmacro()
macro(check_required_components _NAME)
foreach(comp ${${_NAME}_FIND_COMPONENTS})
if(NOT ${_NAME}_${comp}_FOUND)
if(${_NAME}_FIND_REQUIRED_${comp})
set(${_NAME}_FOUND FALSE)
endif()
endif()
endforeach()
endmacro()
####################################################################################
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/libconfigTargets.cmake")
check_required_components(libconfig)
@PACKAGE_INIT@
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/libconfigTargets.cmake")
check_required_components(libconfig)
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2022 Maarten L. Hekkelman
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <climits>
#include <cstdint>
#if __has_include(<sys/ioctl.h>)
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#elif defined(_MSC_VER)
#include <windows.h>
#endif
namespace cfg
{
#if defined(_MSC_VER)
/// @brief Get the width in columns of the current terminal
/// @return number of columns of the terminal
inline uint32_t get_terminal_width()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
::GetConsoleScreenBufferInfo(::GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
return csbi.srWindow.Right - csbi.srWindow.Left + 1;
}
#elif __has_include(<sys/ioctl.h>)
/// @brief Get the width in columns of the current terminal
/// @return number of columns of the terminal
inline uint32_t get_terminal_width()
{
uint32_t result = 80;
if (::isatty(STDOUT_FILENO))
{
struct winsize w;
::ioctl(0, TIOCGWINSZ, &w);
result = w.ws_col;
}
return result;
}
#else
#warning "Could not find the terminal width, falling back to default"
inline uint32_t get_terminal_width()
{
return 80;
}
#endif
} // namespace cfg
\ No newline at end of file
# A simple test config file
aap = 2
noot = 3
\ No newline at end of file
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <iostream> #include <iostream>
#include <cif++/pdb/io.hpp> #include <cif++/pdb/io.hpp>
#include <date/date.h>
#include "dssp_wrapper.hpp" #include "dssp_wrapper.hpp"
#include "revision.hpp" #include "revision.hpp"
...@@ -150,14 +149,26 @@ std::string ResidueToDSSPLine(const dssp::DSSP::residue_info &info) ...@@ -150,14 +149,26 @@ std::string ResidueToDSSPLine(const dssp::DSSP::residue_info &info)
void writeDSSP(const dssp::DSSP &dssp, std::ostream &os) void writeDSSP(const dssp::DSSP &dssp, std::ostream &os)
{ {
using namespace date;
using namespace std::chrono; using namespace std::chrono;
auto stats = dssp.get_statistics(); auto stats = dssp.get_statistics();
auto today = system_clock::now(); auto today = system_clock::now();
os << "==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ==== DATE=" << format("%F", today) << " ." << std::endl #if __cpp_lib_chrono >= 201907L
std::string date = format("%F", today);
#else
std::time_t nowt = std::chrono::system_clock::to_time_t(today);
std::tm nowtm;
localtime_r(&nowt, &nowtm);
char date_buffer[32];
auto n = strftime(date_buffer, sizeof(date_buffer), "%F", &nowtm);
std::string_view date{ date_buffer, n };
#endif
os << "==== Secondary Structure Definition by the program DSSP, NKI version 4.0 ==== DATE=" << date << " ." << std::endl
<< "REFERENCE W. KABSCH AND C.SANDER, BIOPOLYMERS 22 (1983) 2577-2637 ." << std::endl << "REFERENCE W. KABSCH AND C.SANDER, BIOPOLYMERS 22 (1983) 2577-2637 ." << std::endl
<< dssp.get_pdb_header_line(dssp::DSSP::pdb_record_type::HEADER) << '.' << std::endl << dssp.get_pdb_header_line(dssp::DSSP::pdb_record_type::HEADER) << '.' << std::endl
<< dssp.get_pdb_header_line(dssp::DSSP::pdb_record_type::COMPND) << '.' << std::endl << dssp.get_pdb_header_line(dssp::DSSP::pdb_record_type::COMPND) << '.' << std::endl
......
...@@ -34,9 +34,7 @@ ...@@ -34,9 +34,7 @@
#include <iostream> #include <iostream>
#include <cfg.hpp> #include <cfg.hpp>
#include <gxrio.hpp> #include <cif++.hpp>
#include <cif++/pdb/io.hpp>
#include "DSSP.hpp" #include "DSSP.hpp"
...@@ -133,7 +131,7 @@ int d_main(int argc, const char *argv[]) ...@@ -133,7 +131,7 @@ int d_main(int argc, const char *argv[])
if (config.has("mmcif-dictionary")) if (config.has("mmcif-dictionary"))
cif::add_file_resource("mmcif_pdbx.dic", config.get<std::string>("mmcif-dictionary")); cif::add_file_resource("mmcif_pdbx.dic", config.get<std::string>("mmcif-dictionary"));
gxrio::ifstream in(config.operands().front()); cif::gzio::ifstream in(config.operands().front());
if (not in.is_open()) if (not in.is_open())
{ {
std::cerr << "Could not open file" << std::endl; std::cerr << "Could not open file" << std::endl;
...@@ -178,7 +176,7 @@ int d_main(int argc, const char *argv[]) ...@@ -178,7 +176,7 @@ int d_main(int argc, const char *argv[])
if (not output.empty()) if (not output.empty())
{ {
gxrio::ofstream out(output); cif::gzio::ofstream out(output);
if (not out.is_open()) if (not out.is_open())
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment