Commit 068b315e by Maarten L. Hekkelman

makefile updates

parent 4ca72c7e
......@@ -25,25 +25,13 @@
cmake_minimum_required(VERSION 3.15)
# set the project name
project(mkdssp VERSION 4.4.4 LANGUAGES CXX)
project(mkdssp VERSION 4.4.6 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CMakePackageConfigHelpers)
include(FetchContent)
include(FindFilesystem)
include(GenerateExportHeader)
include(CTest)
set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Filesystem REQUIRED)
include(FetchContent)
include(VersionString)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
......@@ -94,8 +82,7 @@ if(MSVC)
endif()
# Create a revision file, containing the current git version info
include(VersionString)
write_version_header("${PROJECT_SOURCE_DIR}/src")
write_version_header("${CMAKE_CURRENT_SOURCE_DIR}/src")
# Optionally use mrc to create resources
find_package(Mrc QUIET)
......@@ -119,28 +106,25 @@ if(NOT PDB_REDO_META)
libmcfp
${EXLC}
GIT_REPOSITORY https://github.com/mhekkel/libmcfp
GIT_TAG v1.2.4)
GIT_TAG v1.3.1)
FetchContent_MakeAvailable(libmcfp)
if (NOT cifpp_FOUND)
set(CIFPP_DOWNLOAD_CCD OFF)
FetchContent_Declare(
cifpp
${EXLC}
GIT_REPOSITORY https://github.com/pdb-redo/libcifpp.git
GIT_TAG 92bd52d
)
set(CIFPP_DOWNLOAD_CCD OFF)
FetchContent_MakeAvailable(cifpp)
endif()
FetchContent_Declare(
cifpp
${EXLC}
GIT_REPOSITORY https://github.com/pdb-redo/libcifpp.git
GIT_TAG v7.0.3
)
FetchContent_MakeAvailable(cifpp)
endif()
add_subdirectory(libdssp)
add_executable(mkdssp ${PROJECT_SOURCE_DIR}/src/mkdssp.cpp)
add_executable(mkdssp ${CMAKE_CURRENT_SOURCE_DIR}/src/mkdssp.cpp)
target_link_libraries(mkdssp PRIVATE libmcfp::libmcfp dssp::dssp)
......@@ -148,12 +132,12 @@ if(USE_RSRC)
mrc_target_resources(mkdssp
${CIFPP_SHARE_DIR}/mmcif_pdbx.dic
${CIFPP_SHARE_DIR}/mmcif_ddl.dic
${PROJECT_SOURCE_DIR}/libdssp/mmcif_pdbx/dssp-extension.dic)
${CMAKE_CURRENT_SOURCE_DIR}/libdssp/mmcif_pdbx/dssp-extension.dic)
endif()
# Install rules
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
RUNTIME DESTINATION bin
)
if(BUILD_DOCUMENTATION)
......@@ -162,7 +146,7 @@ endif()
if(UNIX)
install(FILES doc/mkdssp.1
DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1)
DESTINATION share/man/man1)
endif()
if(EXISTS "${CCP4}/html")
......
......@@ -20,18 +20,14 @@ DSSP does **not** predict secondary structure.
Requirements
------------
The tools are based on [libcif++](https://github.com/PDB-REDO/libcifpp)
and the code is written in modern C++ so you need a compiler capable
of handling C++17 code.
You also need [libmcfp](https://github.com/mhekkel/libmcfp.git)
A good, modern compiler is needed to build the mkdssp program since it uses
many new C++20 features.
Building
--------
Make sure you install [libcif++](https://github.com/PDB-REDO/libcifpp) and [libmcfp](https://github.com/mhekkel/libmcfp.git) first before building.
After that, building should be as easy as typing:
The new makefile for dssp will take care of downloading and building all requirements
automatically. So in theory, building is as simple as:
```console
git clone https://github.com/PDB-REDO/dssp.git
......@@ -46,32 +42,3 @@ Usage
-----
See [manual page](doc/mkdssp.md) for more info. Or even better, see the [DSSP website](https://pdb-redo.eu/dssp).
Docker
------
Build the image yourself:
```console
git clone https://github.com/PDB-REDO/dssp.git
cd dssp
sudo docker build -t dssp .
```
Or pull from Docker Hub:
```console
sudo docker pull stephenturner/dssp && docker tag stephenturner/dssp dssp
```
Usage:
```console
sudo docker run --rm dssp
```
To run dssp on the file `/srv/data/pdb/pdb/cb/pdb1cbs.ent.gz`:
```console
sudo docker run --rm -it -v /srv/data/pdb/pdb:/tmp/pdb dssp /tmp/pdb/cb/pdb1cbs.ent.gz
```
# Simplistic reimplementation of https://github.com/vector-of-bool/CMakeCM/blob/master/modules/FindFilesystem.cmake
if(TARGET std::filesystem)
return()
endif()
cmake_minimum_required(VERSION 3.10)
include(CMakePushCheckState)
include(CheckIncludeFileCXX)
include(CheckCXXSourceCompiles)
cmake_push_check_state()
set(CMAKE_CXX_STANDARD 17)
check_include_file_cxx("filesystem" _CXX_FILESYSTEM_HAVE_HEADER)
mark_as_advanced(_CXX_FILESYSTEM_HAVE_HEADER)
set(code [[
#include <cstdlib>
#include <filesystem>
int main() {
auto cwd = std::filesystem::current_path();
return EXIT_SUCCESS;
}
]])
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL 8.4.0)
# >> https://stackoverflow.com/questions/63902528/program-crashes-when-filesystempath-is-destroyed
set(CXX_FILESYSTEM_NO_LINK_NEEDED 0)
else()
# Check a simple filesystem program without any linker flags
check_cxx_source_compiles("${code}" CXX_FILESYSTEM_NO_LINK_NEEDED)
endif()
if(CXX_FILESYSTEM_NO_LINK_NEEDED)
set(_found 1)
else()
set(prev_libraries ${CMAKE_REQUIRED_LIBRARIES})
# Add the libstdc++ flag
set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lstdc++fs)
check_cxx_source_compiles("${code}" CXX_FILESYSTEM_STDCPPFS_NEEDED)
set(_found ${CXX_FILESYSTEM_STDCPPFS_NEEDED})
if(NOT CXX_FILESYSTEM_STDCPPFS_NEEDED)
# Try the libc++ flag
set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lc++fs)
check_cxx_source_compiles("${code}" CXX_FILESYSTEM_CPPFS_NEEDED)
set(_found ${CXX_FILESYSTEM_CPPFS_NEEDED})
endif()
endif()
if(_found)
add_library(std::filesystem INTERFACE IMPORTED)
set_property(TARGET std::filesystem APPEND PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_17)
if(CXX_FILESYSTEM_NO_LINK_NEEDED)
# Nothing to add...
elseif(CXX_FILESYSTEM_STDCPPFS_NEEDED)
set_target_properties(std::filesystem PROPERTIES IMPORTED_LIBNAME stdc++fs)
elseif(CXX_FILESYSTEM_CPPFS_NEEDED)
set_target_properties(std::filesystem PROPERTIES IMPORTED_LIBNAME c++fs)
endif()
endif()
cmake_pop_check_state()
set(Filesystem_FOUND ${_found} CACHE BOOL "TRUE if we can run a program using std::filesystem" FORCE)
if(Filesystem_FIND_REQUIRED AND NOT Filesystem_FOUND)
message(FATAL_ERROR "Cannot run simple program using std::filesystem")
endif()
include(CMakePackageConfigHelpers)
# We do not want to write an export file for all our symbols...
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
......@@ -24,7 +26,7 @@ target_compile_features(dssp PUBLIC cxx_std_17)
target_include_directories(dssp
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/../src>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
"$<INSTALL_INTERFACE:include>"
)
# Install rules
......@@ -60,34 +62,22 @@ install(FILES
COMPONENT Devel
)
# set(dssp_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR})
# set_target_properties(dssp PROPERTIES
# VERSION ${PROJECT_VERSION}
# SOVERSION ${dssp_MAJOR_VERSION}
# INTERFACE_dssp_MAJOR_VERSION ${dssp_MAJOR_VERSION})
# set_property(TARGET dssp APPEND PROPERTY
# COMPATIBLE_INTERFACE_STRING dssp_MAJOR_VERSION
# )
# write_basic_package_version_file(
# "${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfigVersion.cmake"
# VERSION ${PROJECT_VERSION}
# COMPATIBILITY AnyNewerVersion
# )
# # pkgconfig support
# set(prefix ${CMAKE_INSTALL_PREFIX})
# set(exec_prefix ${CMAKE_INSTALL_PREFIX})
# set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
# set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libdssp.pc.in
# ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc.in @ONLY)
# file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc
# INPUT ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc.in)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libdssp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
set(CIFPP_DATA_DIR "${CMAKE_INSTALL_FULL_DATADIR}/libcifpp")
set(dssp_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR})
set_target_properties(dssp PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${dssp_MAJOR_VERSION}
INTERFACE_dssp_MAJOR_VERSION ${dssp_MAJOR_VERSION})
set_property(TARGET dssp APPEND PROPERTY
COMPATIBLE_INTERFACE_STRING dssp_MAJOR_VERSION
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# set(CIFPP_DATA_DIR "${CMAKE_INSTALL_FULL_DATADIR}/libcifpp")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mmcif_pdbx/dssp-extension.dic"
DESTINATION ${CIFPP_DATA_DIR})
DESTINATION share/libcifpp)
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