Commit 068b315e by Maarten L. Hekkelman

makefile updates

parent 4ca72c7e
...@@ -25,25 +25,13 @@ ...@@ -25,25 +25,13 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
# set the project name # 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") 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) include(CTest)
include(FetchContent)
set(CXX_EXTENSIONS OFF) include(VersionString)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Filesystem REQUIRED)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
...@@ -94,8 +82,7 @@ if(MSVC) ...@@ -94,8 +82,7 @@ if(MSVC)
endif() endif()
# Create a revision file, containing the current git version info # Create a revision file, containing the current git version info
include(VersionString) write_version_header("${CMAKE_CURRENT_SOURCE_DIR}/src")
write_version_header("${PROJECT_SOURCE_DIR}/src")
# Optionally use mrc to create resources # Optionally use mrc to create resources
find_package(Mrc QUIET) find_package(Mrc QUIET)
...@@ -119,28 +106,25 @@ if(NOT PDB_REDO_META) ...@@ -119,28 +106,25 @@ if(NOT PDB_REDO_META)
libmcfp libmcfp
${EXLC} ${EXLC}
GIT_REPOSITORY https://github.com/mhekkel/libmcfp GIT_REPOSITORY https://github.com/mhekkel/libmcfp
GIT_TAG v1.2.4) GIT_TAG v1.3.1)
FetchContent_MakeAvailable(libmcfp) FetchContent_MakeAvailable(libmcfp)
if (NOT cifpp_FOUND)
set(CIFPP_DOWNLOAD_CCD OFF) set(CIFPP_DOWNLOAD_CCD OFF)
FetchContent_Declare( FetchContent_Declare(
cifpp cifpp
${EXLC} ${EXLC}
GIT_REPOSITORY https://github.com/pdb-redo/libcifpp.git GIT_REPOSITORY https://github.com/pdb-redo/libcifpp.git
GIT_TAG 92bd52d GIT_TAG v7.0.3
) )
FetchContent_MakeAvailable(cifpp) FetchContent_MakeAvailable(cifpp)
endif()
endif() endif()
add_subdirectory(libdssp) 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) target_link_libraries(mkdssp PRIVATE libmcfp::libmcfp dssp::dssp)
...@@ -148,12 +132,12 @@ if(USE_RSRC) ...@@ -148,12 +132,12 @@ if(USE_RSRC)
mrc_target_resources(mkdssp mrc_target_resources(mkdssp
${CIFPP_SHARE_DIR}/mmcif_pdbx.dic ${CIFPP_SHARE_DIR}/mmcif_pdbx.dic
${CIFPP_SHARE_DIR}/mmcif_ddl.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() endif()
# Install rules # Install rules
install(TARGETS ${PROJECT_NAME} install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${BIN_INSTALL_DIR} RUNTIME DESTINATION bin
) )
if(BUILD_DOCUMENTATION) if(BUILD_DOCUMENTATION)
...@@ -162,7 +146,7 @@ endif() ...@@ -162,7 +146,7 @@ endif()
if(UNIX) if(UNIX)
install(FILES doc/mkdssp.1 install(FILES doc/mkdssp.1
DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1) DESTINATION share/man/man1)
endif() endif()
if(EXISTS "${CCP4}/html") if(EXISTS "${CCP4}/html")
......
...@@ -20,18 +20,14 @@ DSSP does **not** predict secondary structure. ...@@ -20,18 +20,14 @@ DSSP does **not** predict secondary structure.
Requirements Requirements
------------ ------------
The tools are based on [libcif++](https://github.com/PDB-REDO/libcifpp) A good, modern compiler is needed to build the mkdssp program since it uses
and the code is written in modern C++ so you need a compiler capable many new C++20 features.
of handling C++17 code.
You also need [libmcfp](https://github.com/mhekkel/libmcfp.git)
Building Building
-------- --------
Make sure you install [libcif++](https://github.com/PDB-REDO/libcifpp) and [libmcfp](https://github.com/mhekkel/libmcfp.git) first before building. The new makefile for dssp will take care of downloading and building all requirements
automatically. So in theory, building is as simple as:
After that, building should be as easy as typing:
```console ```console
git clone https://github.com/PDB-REDO/dssp.git git clone https://github.com/PDB-REDO/dssp.git
...@@ -46,32 +42,3 @@ Usage ...@@ -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). 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... # We do not want to write an export file for all our symbols...
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
...@@ -24,7 +26,7 @@ target_compile_features(dssp PUBLIC cxx_std_17) ...@@ -24,7 +26,7 @@ target_compile_features(dssp PUBLIC cxx_std_17)
target_include_directories(dssp target_include_directories(dssp
PUBLIC PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/../src>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/../src>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" "$<INSTALL_INTERFACE:include>"
) )
# Install rules # Install rules
...@@ -60,34 +62,22 @@ install(FILES ...@@ -60,34 +62,22 @@ install(FILES
COMPONENT Devel COMPONENT Devel
) )
# set(dssp_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}) set(dssp_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR})
# set_target_properties(dssp PROPERTIES set_target_properties(dssp PROPERTIES
# VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
# SOVERSION ${dssp_MAJOR_VERSION} SOVERSION ${dssp_MAJOR_VERSION}
# INTERFACE_dssp_MAJOR_VERSION ${dssp_MAJOR_VERSION}) INTERFACE_dssp_MAJOR_VERSION ${dssp_MAJOR_VERSION})
# set_property(TARGET dssp APPEND PROPERTY set_property(TARGET dssp APPEND PROPERTY
# COMPATIBLE_INTERFACE_STRING dssp_MAJOR_VERSION COMPATIBLE_INTERFACE_STRING dssp_MAJOR_VERSION
# ) )
# write_basic_package_version_file( write_basic_package_version_file(
# "${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfigVersion.cmake"
# VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
# COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
# ) )
# # pkgconfig support # set(CIFPP_DATA_DIR "${CMAKE_INSTALL_FULL_DATADIR}/libcifpp")
# 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")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mmcif_pdbx/dssp-extension.dic" 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