Skip to content

Commit

Permalink
Fix downloading CCD file
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Nov 28, 2023
1 parent cb39174 commit eabda8f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: multi platform test

on:
Expand All @@ -13,15 +11,8 @@ jobs:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
Expand All @@ -36,7 +27,6 @@ jobs:
- uses: actions/checkout@v3

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
Expand All @@ -59,12 +49,9 @@ jobs:
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Release

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config Release --output-on-failure

42 changes: 26 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,26 @@ if(CIFPP_DOWNLOAD_CCD)
# download the components.cif file from CCD
set(COMPONENTS_CIF ${PROJECT_SOURCE_DIR}/data/components.cif)

if(EXISTS ${COMPONENTS_CIF})
file(SIZE ${COMPONENTS_CIF} CCD_FILE_SIZE)
if (CCD_FILE_SIZE EQUAL 0)
message(STATUS "Removing empty ${COMPONENTS_CIF} file")
file(REMOVE "${COMPONENTS_CIF}")
endif()
endif()

if(NOT EXISTS ${COMPONENTS_CIF})
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/data)
file(MAKE_DIRECTORY ${PROJECT_SOURCE_DIR}/data/)
endif()

file(DOWNLOAD https://ftp.wwpdb.org/pub/pdb/data/monomers/components.cif ${COMPONENTS_CIF} SHOW_PROGRESS)
message(STATUS "Trying to download the file https://files.wwpdb.org/pub/pdb/data/monomers/components.cif")
file(DOWNLOAD "https://files.wwpdb.org/pub/pdb/data/monomers/components.cif" "${COMPONENTS_CIF}" SHOW_PROGRESS STATUS CCD_FETCH_STATUS)

list(POP_FRONT CCD_FETCH_STATUS CCD_FETCH_STATUS_CODE)
if(NOT CCD_FETCH_STATUS_CODE EQUAL 0)
message(FATAL_ERROR "Error trying to download CCD file: ${CCD_FETCH_STATUS}")
endif()
endif()

add_custom_target(COMPONENTS ALL DEPENDS ${COMPONENTS_CIF})
Expand Down Expand Up @@ -473,22 +487,17 @@ write_basic_package_version_file(

if(BUILD_TESTING)
set(CATCH_BUILD_TESTING OFF)
set(CATCH_INSTALL_DOCS OFF)
set(CATCH_INSTALL_EXTRAS OFF)

find_package(Catch2 3 QUIET)

if(NOT Catch2_FOUND)
Include(FetchContent)
# Use a private version of Catch2 since the one in the OS
# might not have been compiled with C++17 as standard
# resulting in link errors.
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)

FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)

FetchContent_MakeAvailable(Catch2)
endif()
FetchContent_MakeAvailable(Catch2)

list(APPEND CIFPP_tests
unit-v2
Expand Down Expand Up @@ -547,7 +556,6 @@ if(CIFPP_INSTALL_UPDATE_SCRIPT)
)

install(DIRECTORY DESTINATION ${CIFPP_CACHE_DIR})
install(DIRECTORY DESTINATION "${CIFPP_ETC_DIR}/libcifpp/cache-update.d")

# a config file, to make it complete
if(NOT EXISTS "${CIFPP_ETC_DIR}/libcifpp.conf")
Expand All @@ -556,6 +564,8 @@ if(CIFPP_INSTALL_UPDATE_SCRIPT)
]])
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcifpp.conf DESTINATION "${CIFPP_ETC_DIR}")
install(CODE "message(\"A configuration file has been written to ${CIFPP_ETC_DIR}/libcifpp.conf, please edit this file to enable automatic updates\")")

install(DIRECTORY DESTINATION "${CIFPP_ETC_DIR}/libcifpp/cache-update.d")
endif()

target_compile_definitions(cifpp PUBLIC CACHE_DIR="${CIFPP_CACHE_DIR}")
Expand Down

0 comments on commit eabda8f

Please sign in to comment.