[med-svn] [Git][med-team/dssp][upstream] New upstream version 4.5.5

Maarten L. Hekkelman (@mhekkel-guest) gitlab at salsa.debian.org
Sun Aug 31 12:31:24 BST 2025



Maarten L. Hekkelman pushed to branch upstream at Debian Med / dssp


Commits:
a97d1798 by Maarten L. Hekkelman at 2025-08-31T12:53:32+02:00
New upstream version 4.5.5
- - - - -


25 changed files:

- − .github/workflows/build-documentation.yml
- .github/workflows/cmake-multi-platform.yml
- .gitignore
- CMakeLists.txt
- Dockerfile
- README.md
- changelog
- + cmake/CPM.cmake
- doc/mkdssp.md
- libdssp/CMakeLists.txt
- libdssp/cmake/dsspConfig.cmake.in → libdssp/cmake/dssp-config.cmake.in
- libdssp/include/dssp.hpp
- libdssp/mmcif_pdbx/dssp-extension.dic
- libdssp/src/dssp-io.cpp
- libdssp/src/dssp-io.hpp
- libdssp/src/dssp.cpp
- + python-module/CMakeLists.txt
- + python-module/dssp-python-plugin.cpp
- + python-module/test-mkdssp.py
- src/mkdssp.cpp
- test/1cbs-dssp.cif
- test/CMakeLists.txt
- + test/pdb1cbs.ent.gz
- + test/test-python.py
- test/unit-test-dssp.cpp


Changes:

=====================================
.github/workflows/build-documentation.yml deleted
=====================================
@@ -1,65 +0,0 @@
-# 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: publish docs
-
-on:
-  push:
-    branches: [ "trunk" ]
-
-permissions:
-  contents: read
-  pages: write
-  id-token: write
-
-concurrency:
-  group: "pages"
-  cancel-in-progress: false
-
-jobs:
-  docs:
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout at v1
-
-    - 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"
-
-    - name: Install dependencies Ubuntu
-      run: sudo apt-get update && sudo apt-get install cmake doxygen
-
-    - uses: actions/setup-python at v4
-      with:
-        python-version: '3.9'
-        cache: 'pip' # caching pip dependencies
-    - run: pip install -r docs/requirements.txt
-
-    - name: Configure CMake
-      run: cmake -S . -B build -DBUILD_DOCUMENTATION=ON -DBUILD_TESTING=OFF
-
-    - name: Run Sphinx
-      run: |
-        cmake --build build --target Sphinx-mcfp
-        ls -l ${{ steps.strings.outputs.build-output-dir }}
-        ls -l ${{ steps.strings.outputs.build-output-dir }}/docs/sphinx
-
-    - name: Upload artifact
-      uses: actions/upload-pages-artifact at v2
-      with:
-        path: ${{ steps.strings.outputs.build-output-dir }}/docs/sphinx
-
-  deploy:
-    environment:
-      name: github-pages
-      url: ${{ steps.deployment.outputs.page_url }}
-
-    runs-on: ubuntu-latest
-    needs: docs
-
-    steps:
-      - name: Deploy to GitHub Pages
-        id: deployment
-        uses: actions/deploy-pages at v2


=====================================
.github/workflows/cmake-multi-platform.yml
=====================================
@@ -15,6 +15,7 @@ jobs:
 
       matrix:
         os: [ubuntu-latest, windows-latest, macos-latest]
+        python-version: [ 3.13 ]
         include:
           - os: windows-latest
             cpp_compiler: cl
@@ -34,7 +35,12 @@ jobs:
     - name: Install Catch2 Ubuntu
       if: matrix.os == 'ubuntu-latest'
       run: >
-        sudo apt-get update && sudo apt-get install catch2
+        sudo apt-get update && sudo apt-get install catch2 libpython3-all-dev libboost1.83-all-dev
+
+    - name: setup python
+      uses: actions/setup-python at v5
+      with:
+        python-version: ${{ matrix.python-version }}
 
     - name: Install Catch2 macOS
       if: matrix.os == 'macos-latest'
@@ -52,6 +58,7 @@ jobs:
         -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
         -DCMAKE_BUILD_TYPE=Release
         -DBUILD_TESTING=ON
+        -DBUILD_PYTHON_MODULE=ON
         -S ${{ github.workspace }}
         
     - name: Build
@@ -59,7 +66,7 @@ jobs:
 
     - name: Test
       working-directory: ${{ steps.strings.outputs.build-output-dir }}
-      run: ctest --build-config Release --output-on-failure -R dssp
+      run: ctest --build-config Release --output-on-failure
       env:
         LIBCIFPP_DATA_DIR: ${{ steps.strings.outputs.build-output-dir }}/_deps/cifpp-src/rsrc
 


=====================================
.gitignore
=====================================
@@ -5,3 +5,4 @@ build/
 **/*.dssp
 src/revision.hpp
 libdssp/src/revision.hpp
+python-module/mkdssp.so


=====================================
CMakeLists.txt
=====================================
@@ -25,13 +25,20 @@
 cmake_minimum_required(VERSION 3.23)
 
 # set the project name
-project(mkdssp VERSION 4.4.10 LANGUAGES CXX)
+project(mkdssp VERSION 4.5.5 LANGUAGES CXX)
 
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
 
+include(CPM)
 include(CTest)
 include(VersionString)
 
+# The default build type must be set before project()
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+	set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
+	set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
+endif()
+
 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)
@@ -41,10 +48,12 @@ endif()
 # Optionally build a version to be installed inside CCP4
 option(BUILD_FOR_CCP4 "Build a version to be installed in CCP4" OFF)
 option(BUILD_DOCUMENTATION "Generate the documentation files using pandoc" OFF)
+option(BUILD_PYTHON_MODULE "Build an experimental Python module" OFF)
+option(INSTALL_LIBRARY "Install the libdssp library" 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")
+		message(FATAL_ERROR "dssp: A CCP4 built was requested but CCP4 was not sourced")
 	else()
 		list(APPEND CMAKE_MODULE_PATH "$ENV{CCP4}")
 		list(APPEND CMAKE_PREFIX_PATH "$ENV{CCP4}")
@@ -56,24 +65,34 @@ if(BUILD_FOR_CCP4)
 	endif()
 endif()
 
-if(MSVC)
-	# make msvc standards compliant...
-	add_compile_options(/permissive-)
-	add_link_options(/NODEFAULTLIB:library)
+if(WIN32)
+	if(${CMAKE_SYSTEM_VERSION} GREATER_EQUAL 10) # Windows 10
+		add_definitions(-D _WIN32_WINNT=0x0A00)
+	elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.3) # Windows 8.1
+		add_definitions(-D _WIN32_WINNT=0x0603)
+	elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.2) # Windows 8
+		add_definitions(-D _WIN32_WINNT=0x0602)
+	elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.1) # Windows 7
+		add_definitions(-D _WIN32_WINNT=0x0601)
+	elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.0) # Windows Vista
+		add_definitions(-D _WIN32_WINNT=0x0600)
+	else() # Windows XP (5.1)
+		add_definitions(-D _WIN32_WINNT=0x0501)
+	endif()
 
-	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})
+	# Man, this is 2024 we're living in...
+	add_definitions(-DNOMINMAX)
 
-			set(${version} "0x${ver}")
-		endif()
-	endmacro()
+	# We do not want to write an export file for all our symbols...
+	set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+endif()
 
-	get_WIN32_WINNT(ver)
-	add_definitions(-D_WIN32_WINNT=${ver})
+if(MSVC)
+	# make msvc standards compliant...
+	add_compile_options(/permissive- /bigobj)
+	add_link_options(/NODEFAULTLIB:library)
 
+	# This is dubious...
 	if(BUILD_SHARED_LIBS)
 		set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
 	else()
@@ -85,69 +104,71 @@ endif()
 write_version_header("${CMAKE_CURRENT_SOURCE_DIR}/src")
 
 # Optionally use mrc to create resources
-find_package(Mrc QUIET)
+find_package(mrc QUIET)
 
 if(MRC_FOUND)
 	option(USE_RSRC "Use mrc to create resources" ON)
 else()
-	message(STATUS "Not using resources since mrc was not found")
+	message(STATUS "dssp: Not using resources since mrc was not found")
 endif()
 
 set(CMAKE_THREAD_PREFER_PTHREAD)
 set(THREADS_PREFER_PTHREAD_FLAG)
 find_package(Threads)
-find_package(libmcfp QUIET)
-
-if(NOT (libmcfp_FOUND OR TARGET libmcfp))
-	include(FetchContent)
-
-	if(CMAKE_VERSION GREATER_EQUAL 3.28)
-		set(EXLC "EXCLUDE_FROM_ALL")
-	endif()
-
-	FetchContent_Declare(
-		libmcfp
-		${EXLC}
-		GIT_REPOSITORY https://github.com/mhekkel/libmcfp
-		GIT_TAG v1.3.1)
 
-	FetchContent_MakeAvailable(libmcfp)
+CPMFindPackage(
+	NAME mcfp
+	GIT_REPOSITORY https://github.com/mhekkel/libmcfp
+	GIT_TAG v1.4.2
+	EXCLUDE_FROM_ALL YES)
+
+# CPMFindPackage does not pass on variables set with set_and_check
+# Working around this here
+find_package(cifpp 8.0.1 QUIET)
+
+if(NOT cifpp_FOUND)
+	CPMAddPackage(
+		NAME cifpp
+		GIT_REPOSITORY https://github.com/pdb-redo/libcifpp.git
+		GIT_TAG v8.0.1
+		EXCLUDE_FROM_ALL YES)
 endif()
 
-if(NOT TARGET cifpp AND NOT cifpp_FOUND)
-	include(FetchContent)
-
-	find_package(cifpp 7.0.7 QUIET)
-
-	if(NOT cifpp_FOUND)
-		set(CIFPP_DOWNLOAD_CCD OFF)
-		set(SAVED_BUILD_TESTING "${BUILD_TESTING}")
-		set(BUILD_TESTING OFF)
-
-		FetchContent_Declare(
-			cifpp
-			${EXLC}
-			GIT_REPOSITORY https://github.com/pdb-redo/libcifpp.git
-			GIT_TAG v7.0.7
-		)
-
-		FetchContent_MakeAvailable(cifpp)
-
-		set(BUILD_TESTING ${SAVED_BUILD_TESTING})
-	endif()
+if(TARGET cifpp)
+	get_target_property(CIFPP_SOURCE_DIR cifpp SOURCE_DIR)
+	set(CIFPP_SHARE_DIR share/libcifpp)
+	set(CIFPP_DATA_DIR ${CIFPP_SOURCE_DIR}/rsrc)
+elseif(DEFINED CIFPP_SHARE_DIR)
+	set(CIFPP_DATA_DIR ${CIFPP_SHARE_DIR})
+else()
+	message(FATAL_ERROR "dssp: The CIFPP_SHARE_DIR variable is not found in the cifpp configuration files")
 endif()
 
-add_subdirectory(libdssp)
+if(INSTALL_LIBRARY)
+	add_subdirectory(libdssp)
+else()
+	add_subdirectory(libdssp EXCLUDE_FROM_ALL)
+endif()
 
 add_executable(mkdssp ${CMAKE_CURRENT_SOURCE_DIR}/src/mkdssp.cpp)
 
-target_link_libraries(mkdssp PRIVATE libmcfp::libmcfp dssp::dssp)
+target_link_libraries(mkdssp PRIVATE mcfp::mcfp dssp::dssp)
 
 if(USE_RSRC)
 	mrc_target_resources(mkdssp
-		${CIFPP_SHARE_DIR}/mmcif_pdbx.dic
-		${CIFPP_SHARE_DIR}/mmcif_ddl.dic
+		${CIFPP_DATA_DIR}/mmcif_pdbx.dic
 		${CMAKE_CURRENT_SOURCE_DIR}/libdssp/mmcif_pdbx/dssp-extension.dic)
+else()
+	get_target_property(LIBDSSP_SOURCE_DIR dssp SOURCE_DIR)
+
+	install(FILES
+		${CMAKE_CURRENT_SOURCE_DIR}/libdssp/mmcif_pdbx/dssp-extension.dic
+		DESTINATION ${CIFPP_SHARE_DIR})
+
+	if(TARGET cifpp)
+		install(FILES ${CIFPP_DATA_DIR}/mmcif_pdbx.dic
+			DESTINATION ${CIFPP_SHARE_DIR})
+	endif()
 endif()
 
 # Install rules
@@ -155,23 +176,6 @@ install(TARGETS ${PROJECT_NAME}
 	RUNTIME DESTINATION bin
 )
 
-if(NOT USE_RSRC)
-	# When building cifpp ourselves, we need to find where libcifpp
-	# expects the data files to be located.
-	if(TARGET cifpp)
-		get_target_property(DSSP_DATA_DIR cifpp CIFPP_DATA_DIR)
-		get_target_property(CIFPP_SOURCE_DIR cifpp SOURCE_DIR)
-
-		install(
-			FILES ${CIFPP_SOURCE_DIR}/rsrc/mmcif_pdbx.dic
-			${CIFPP_SOURCE_DIR}/rsrc/mmcif_ddl.dic
-			${CMAKE_CURRENT_SOURCE_DIR}/libdssp/mmcif_pdbx/dssp-extension.dic
-			DESTINATION ${DSSP_DATA_DIR})
-	else()
-
-	endif()
-endif()
-
 if(BUILD_DOCUMENTATION)
 	add_subdirectory(doc)
 endif()
@@ -187,10 +191,15 @@ if(EXISTS "${CCP4}/html")
 endif()
 
 # test
-if(BUILD_TESTING)
+if(BUILD_TESTING AND PROJECT_IS_TOP_LEVEL)
 	add_subdirectory(test)
 endif()
 
+# Python
+if(BUILD_PYTHON_MODULE)
+	add_subdirectory(python-module)
+endif()
+
 include(InstallRequiredSystemLibraries)
 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
 


=====================================
Dockerfile
=====================================
@@ -1,4 +1,4 @@
-FROM ubuntu:22.04
+FROM ubuntu:24.04
 
 ENV TZ="Europe/Amsterdam"
 RUN apt-get update && \
@@ -9,27 +9,6 @@ RUN apt-get update && \
 
 WORKDIR /build
 
-# Build and install libcifpp
-# https://github.com/PDB-REDO/libcifpp
-RUN cd /build && \
-    git clone https://github.com/PDB-REDO/libcifpp.git && \
-    cd libcifpp && \
-    cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \
-		-DBUILD_TESTING=OFF -DCIFPP_DOWNLOAD_CCD=OFF && \
-    cmake --build build -j $(nproc) && \
-    cmake --install build && \
-    echo "libcifpp installed"
-
-# Build and install libmcfp
-# https://github.com/mhekkel/libmcfp
-RUN cd /build && \
-    git clone https://github.com/mhekkel/libmcfp.git && \
-    cd libmcfp && \
-    cmake -S . -B build -DBUILD_TESTING=OFF && \
-    cmake --build build -j $(nproc) && \
-    cmake --install build && \
-    echo "libmcfp installed"
-
 # Build and install dssp
 COPY . /src
 RUN cd /src && \


=====================================
README.md
=====================================
@@ -1,7 +1,7 @@
 [![github CI](https://github.com/pdb-redo/dssp/actions/workflows/cmake-multi-platform.yml/badge.svg)](https://github.com/pdb-redo/dssp/actions)
 [![GitHub License](https://img.shields.io/github/license/pdb-redo/dssp)](https://github.com/pdb-redo/dssp/LICENSE)
 
-DSSP 4.4
+DSSP 4.5
 ========
 
 This is a rewrite of DSSP, now offering full mmCIF support. The difference
@@ -40,6 +40,42 @@ cmake --build build
 cmake --install build
 ```
 
+Python module
+-------------
+
+Since version 4.5.2 it is possible to build a Python module to directy work
+with DSSP info inside your Python scripts. To build and install the Python
+module use the following commands instead:
+
+```console
+git clone https://github.com/PDB-REDO/dssp.git
+cd dssp
+cmake -S . -B build -DBUILD_PYTHON_MODULE=ON
+cmake --build build
+sudo cmake --install build
+```
+
+After that you can use dssp in a python script, like this:
+
+```python
+from mkdssp import dssp
+import os
+import gzip
+
+file_path = os.path.join("..", "test", "1cbs.cif.gz")
+
+with gzip.open(file_path, "rt") as f:
+    file_content = f.read()
+ 
+dssp = dssp(file_content)
+ 
+print("residues: ", dssp.statistics.residues)
+
+for res in dssp:
+    print(res.asym_id, res.seq_id, res.compound_id, res.type)
+
+```
+
 Usage
 -----
 


=====================================
changelog
=====================================
@@ -1,3 +1,33 @@
+Version 4.5.5
+- Clean up old DSSP data before writing new
+- Regression: check for pdbx_poly_seq_scheme and if missing
+  use the repair mode to read the file. (i.e. cif::pdb::read)
+
+Version 4.5.4
+- Update reference information
+- Better fix for locating/installing dictionary files
+
+Version 4.5.3
+- Fix makefile to locate dictionary files
+
+Version 4.5.2
+- Use find_package before fetching libraries, again
+- Added Python module
+
+Version 4.5.1
+- Only use reconstructing load option when needed to
+  save lots of time on large structures
+- Fixes in writing the audit_conform category
+- Fix dictionary location
+
+Version 4.5
+- Based on new libcifpp version 8
+- Fixed Dockerfile
+
+Version 4.4.11
+- Write proper audit_conform records
+- Updated dssp-extension.dic file to include version info
+
 Version 4.4.10
 - Support for installing in environments that do not use resources,
   this time for real.


=====================================
cmake/CPM.cmake
=====================================
@@ -0,0 +1,1291 @@
+# CPM.cmake - CMake's missing package manager
+# ===========================================
+# See https://github.com/cpm-cmake/CPM.cmake for usage and update instructions.
+#
+# MIT License
+# -----------
+#[[
+  Copyright (c) 2019-2023 Lars Melchior and contributors
+
+  Permission is hereby granted, free of charge, to any person obtaining a copy
+  of this software and associated documentation files (the "Software"), to deal
+  in the Software without restriction, including without limitation the rights
+  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+  copies of the Software, and to permit persons to whom the Software is
+  furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included in all
+  copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+  SOFTWARE.
+]]
+
+cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
+
+# Initialize logging prefix
+if(NOT CPM_INDENT)
+  set(CPM_INDENT
+      "CPM:"
+      CACHE INTERNAL ""
+  )
+endif()
+
+if(NOT COMMAND cpm_message)
+  function(cpm_message)
+    message(${ARGV})
+  endfunction()
+endif()
+
+if(DEFINED EXTRACTED_CPM_VERSION)
+  set(CURRENT_CPM_VERSION "${EXTRACTED_CPM_VERSION}${CPM_DEVELOPMENT}")
+else()
+  set(CURRENT_CPM_VERSION 0.40.8)
+endif()
+
+get_filename_component(CPM_CURRENT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
+if(CPM_DIRECTORY)
+  if(NOT CPM_DIRECTORY STREQUAL CPM_CURRENT_DIRECTORY)
+    if(CPM_VERSION VERSION_LESS CURRENT_CPM_VERSION)
+      message(
+        AUTHOR_WARNING
+          "${CPM_INDENT} \
+A dependency is using a more recent CPM version (${CURRENT_CPM_VERSION}) than the current project (${CPM_VERSION}). \
+It is recommended to upgrade CPM to the most recent version. \
+See https://github.com/cpm-cmake/CPM.cmake for more information."
+      )
+    endif()
+    if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
+      include(FetchContent)
+    endif()
+    return()
+  endif()
+
+  get_property(
+    CPM_INITIALIZED GLOBAL ""
+    PROPERTY CPM_INITIALIZED
+    SET
+  )
+  if(CPM_INITIALIZED)
+    return()
+  endif()
+endif()
+
+if(CURRENT_CPM_VERSION MATCHES "development-version")
+  message(
+    WARNING "${CPM_INDENT} Your project is using an unstable development version of CPM.cmake. \
+Please update to a recent release if possible. \
+See https://github.com/cpm-cmake/CPM.cmake for details."
+  )
+endif()
+
+set_property(GLOBAL PROPERTY CPM_INITIALIZED true)
+
+macro(cpm_set_policies)
+  # the policy allows us to change options without caching
+  cmake_policy(SET CMP0077 NEW)
+  set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
+
+  # the policy allows us to change set(CACHE) without caching
+  if(POLICY CMP0126)
+    cmake_policy(SET CMP0126 NEW)
+    set(CMAKE_POLICY_DEFAULT_CMP0126 NEW)
+  endif()
+
+  # The policy uses the download time for timestamp, instead of the timestamp in the archive. This
+  # allows for proper rebuilds when a projects url changes
+  if(POLICY CMP0135)
+    cmake_policy(SET CMP0135 NEW)
+    set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
+  endif()
+
+  # treat relative git repository paths as being relative to the parent project's remote
+  if(POLICY CMP0150)
+    cmake_policy(SET CMP0150 NEW)
+    set(CMAKE_POLICY_DEFAULT_CMP0150 NEW)
+  endif()
+endmacro()
+cpm_set_policies()
+
+option(CPM_USE_LOCAL_PACKAGES "Always try to use `find_package` to get dependencies"
+       $ENV{CPM_USE_LOCAL_PACKAGES}
+)
+option(CPM_LOCAL_PACKAGES_ONLY "Only use `find_package` to get dependencies"
+       $ENV{CPM_LOCAL_PACKAGES_ONLY}
+)
+option(CPM_DOWNLOAD_ALL "Always download dependencies from source" $ENV{CPM_DOWNLOAD_ALL})
+option(CPM_DONT_UPDATE_MODULE_PATH "Don't update the module path to allow using find_package"
+       $ENV{CPM_DONT_UPDATE_MODULE_PATH}
+)
+option(CPM_DONT_CREATE_PACKAGE_LOCK "Don't create a package lock file in the binary path"
+       $ENV{CPM_DONT_CREATE_PACKAGE_LOCK}
+)
+option(CPM_INCLUDE_ALL_IN_PACKAGE_LOCK
+       "Add all packages added through CPM.cmake to the package lock"
+       $ENV{CPM_INCLUDE_ALL_IN_PACKAGE_LOCK}
+)
+option(CPM_USE_NAMED_CACHE_DIRECTORIES
+       "Use additional directory of package name in cache on the most nested level."
+       $ENV{CPM_USE_NAMED_CACHE_DIRECTORIES}
+)
+
+set(CPM_VERSION
+    ${CURRENT_CPM_VERSION}
+    CACHE INTERNAL ""
+)
+set(CPM_DIRECTORY
+    ${CPM_CURRENT_DIRECTORY}
+    CACHE INTERNAL ""
+)
+set(CPM_FILE
+    ${CMAKE_CURRENT_LIST_FILE}
+    CACHE INTERNAL ""
+)
+set(CPM_PACKAGES
+    ""
+    CACHE INTERNAL ""
+)
+set(CPM_DRY_RUN
+    OFF
+    CACHE INTERNAL "Don't download or configure dependencies (for testing)"
+)
+
+if(DEFINED ENV{CPM_SOURCE_CACHE})
+  set(CPM_SOURCE_CACHE_DEFAULT $ENV{CPM_SOURCE_CACHE})
+else()
+  set(CPM_SOURCE_CACHE_DEFAULT OFF)
+endif()
+
+set(CPM_SOURCE_CACHE
+    ${CPM_SOURCE_CACHE_DEFAULT}
+    CACHE PATH "Directory to download CPM dependencies"
+)
+
+if(NOT CPM_DONT_UPDATE_MODULE_PATH AND NOT DEFINED CMAKE_FIND_PACKAGE_REDIRECTS_DIR)
+  set(CPM_MODULE_PATH
+      "${CMAKE_BINARY_DIR}/CPM_modules"
+      CACHE INTERNAL ""
+  )
+  # remove old modules
+  file(REMOVE_RECURSE ${CPM_MODULE_PATH})
+  file(MAKE_DIRECTORY ${CPM_MODULE_PATH})
+  # locally added CPM modules should override global packages
+  set(CMAKE_MODULE_PATH "${CPM_MODULE_PATH};${CMAKE_MODULE_PATH}")
+endif()
+
+if(NOT CPM_DONT_CREATE_PACKAGE_LOCK)
+  set(CPM_PACKAGE_LOCK_FILE
+      "${CMAKE_BINARY_DIR}/cpm-package-lock.cmake"
+      CACHE INTERNAL ""
+  )
+  file(WRITE ${CPM_PACKAGE_LOCK_FILE}
+       "# CPM Package Lock\n# This file should be committed to version control\n\n"
+  )
+endif()
+
+include(FetchContent)
+
+# Try to infer package name from git repository uri (path or url)
+function(cpm_package_name_from_git_uri URI RESULT)
+  if("${URI}" MATCHES "([^/:]+)/?.git/?$")
+    set(${RESULT}
+        ${CMAKE_MATCH_1}
+        PARENT_SCOPE
+    )
+  else()
+    unset(${RESULT} PARENT_SCOPE)
+  endif()
+endfunction()
+
+# Try to infer package name and version from a url
+function(cpm_package_name_and_ver_from_url url outName outVer)
+  if(url MATCHES "[/\\?]([a-zA-Z0-9_\\.-]+)\\.(tar|tar\\.gz|tar\\.bz2|zip|ZIP)(\\?|/|$)")
+    # We matched an archive
+    set(filename "${CMAKE_MATCH_1}")
+
+    if(filename MATCHES "([a-zA-Z0-9_\\.-]+)[_-]v?(([0-9]+\\.)*[0-9]+[a-zA-Z0-9]*)")
+      # We matched <name>-<version> (ie foo-1.2.3)
+      set(${outName}
+          "${CMAKE_MATCH_1}"
+          PARENT_SCOPE
+      )
+      set(${outVer}
+          "${CMAKE_MATCH_2}"
+          PARENT_SCOPE
+      )
+    elseif(filename MATCHES "(([0-9]+\\.)+[0-9]+[a-zA-Z0-9]*)")
+      # We couldn't find a name, but we found a version
+      #
+      # In many cases (which we don't handle here) the url would look something like
+      # `irrelevant/ACTUAL_PACKAGE_NAME/irrelevant/1.2.3.zip`. In such a case we can't possibly
+      # distinguish the package name from the irrelevant bits. Moreover if we try to match the
+      # package name from the filename, we'd get bogus at best.
+      unset(${outName} PARENT_SCOPE)
+      set(${outVer}
+          "${CMAKE_MATCH_1}"
+          PARENT_SCOPE
+      )
+    else()
+      # Boldly assume that the file name is the package name.
+      #
+      # Yes, something like `irrelevant/ACTUAL_NAME/irrelevant/download.zip` will ruin our day, but
+      # such cases should be quite rare. No popular service does this... we think.
+      set(${outName}
+          "${filename}"
+          PARENT_SCOPE
+      )
+      unset(${outVer} PARENT_SCOPE)
+    endif()
+  else()
+    # No ideas yet what to do with non-archives
+    unset(${outName} PARENT_SCOPE)
+    unset(${outVer} PARENT_SCOPE)
+  endif()
+endfunction()
+
+function(cpm_find_package NAME VERSION)
+  string(REPLACE " " ";" EXTRA_ARGS "${ARGN}")
+  find_package(${NAME} ${VERSION} ${EXTRA_ARGS} QUIET)
+  if(${CPM_ARGS_NAME}_FOUND)
+    if(DEFINED ${CPM_ARGS_NAME}_VERSION)
+      set(VERSION ${${CPM_ARGS_NAME}_VERSION})
+    endif()
+    cpm_message(STATUS "${CPM_INDENT} Using local package ${CPM_ARGS_NAME}@${VERSION}")
+    CPMRegisterPackage(${CPM_ARGS_NAME} "${VERSION}")
+    set(CPM_PACKAGE_FOUND
+        YES
+        PARENT_SCOPE
+    )
+  else()
+    set(CPM_PACKAGE_FOUND
+        NO
+        PARENT_SCOPE
+    )
+  endif()
+endfunction()
+
+# Create a custom FindXXX.cmake module for a CPM package This prevents `find_package(NAME)` from
+# finding the system library
+function(cpm_create_module_file Name)
+  if(NOT CPM_DONT_UPDATE_MODULE_PATH)
+    if(DEFINED CMAKE_FIND_PACKAGE_REDIRECTS_DIR)
+      # Redirect find_package calls to the CPM package. This is what FetchContent does when you set
+      # OVERRIDE_FIND_PACKAGE. The CMAKE_FIND_PACKAGE_REDIRECTS_DIR works for find_package in CONFIG
+      # mode, unlike the Find${Name}.cmake fallback. CMAKE_FIND_PACKAGE_REDIRECTS_DIR is not defined
+      # in script mode, or in CMake < 3.24.
+      # https://cmake.org/cmake/help/latest/module/FetchContent.html#fetchcontent-find-package-integration-examples
+      string(TOLOWER ${Name} NameLower)
+      file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/${NameLower}-config.cmake
+           "include(\"\${CMAKE_CURRENT_LIST_DIR}/${NameLower}-extra.cmake\" OPTIONAL)\n"
+           "include(\"\${CMAKE_CURRENT_LIST_DIR}/${Name}Extra.cmake\" OPTIONAL)\n"
+      )
+      file(WRITE ${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/${NameLower}-config-version.cmake
+           "set(PACKAGE_VERSION_COMPATIBLE TRUE)\n" "set(PACKAGE_VERSION_EXACT TRUE)\n"
+      )
+    else()
+      file(WRITE ${CPM_MODULE_PATH}/Find${Name}.cmake
+           "include(\"${CPM_FILE}\")\n${ARGN}\nset(${Name}_FOUND TRUE)"
+      )
+    endif()
+  endif()
+endfunction()
+
+# Find a package locally or fallback to CPMAddPackage
+function(CPMFindPackage)
+  set(oneValueArgs NAME VERSION GIT_TAG FIND_PACKAGE_ARGUMENTS)
+
+  cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "" ${ARGN})
+
+  if(NOT DEFINED CPM_ARGS_VERSION)
+    if(DEFINED CPM_ARGS_GIT_TAG)
+      cpm_get_version_from_git_tag("${CPM_ARGS_GIT_TAG}" CPM_ARGS_VERSION)
+    endif()
+  endif()
+
+  set(downloadPackage ${CPM_DOWNLOAD_ALL})
+  if(DEFINED CPM_DOWNLOAD_${CPM_ARGS_NAME})
+    set(downloadPackage ${CPM_DOWNLOAD_${CPM_ARGS_NAME}})
+  elseif(DEFINED ENV{CPM_DOWNLOAD_${CPM_ARGS_NAME}})
+    set(downloadPackage $ENV{CPM_DOWNLOAD_${CPM_ARGS_NAME}})
+  endif()
+  if(downloadPackage)
+    CPMAddPackage(${ARGN})
+    cpm_export_variables(${CPM_ARGS_NAME})
+    return()
+  endif()
+
+  cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS})
+
+  if(NOT CPM_PACKAGE_FOUND)
+    CPMAddPackage(${ARGN})
+    cpm_export_variables(${CPM_ARGS_NAME})
+  endif()
+
+endfunction()
+
+# checks if a package has been added before
+function(cpm_check_if_package_already_added CPM_ARGS_NAME CPM_ARGS_VERSION)
+  if("${CPM_ARGS_NAME}" IN_LIST CPM_PACKAGES)
+    CPMGetPackageVersion(${CPM_ARGS_NAME} CPM_PACKAGE_VERSION)
+    if("${CPM_PACKAGE_VERSION}" VERSION_LESS "${CPM_ARGS_VERSION}")
+      message(
+        WARNING
+          "${CPM_INDENT} Requires a newer version of ${CPM_ARGS_NAME} (${CPM_ARGS_VERSION}) than currently included (${CPM_PACKAGE_VERSION})."
+      )
+    endif()
+    cpm_get_fetch_properties(${CPM_ARGS_NAME})
+    set(${CPM_ARGS_NAME}_ADDED NO)
+    set(CPM_PACKAGE_ALREADY_ADDED
+        YES
+        PARENT_SCOPE
+    )
+    cpm_export_variables(${CPM_ARGS_NAME})
+  else()
+    set(CPM_PACKAGE_ALREADY_ADDED
+        NO
+        PARENT_SCOPE
+    )
+  endif()
+endfunction()
+
+# Parse the argument of CPMAddPackage in case a single one was provided and convert it to a list of
+# arguments which can then be parsed idiomatically. For example gh:foo/bar at 1.2.3 will be converted
+# to: GITHUB_REPOSITORY;foo/bar;VERSION;1.2.3
+function(cpm_parse_add_package_single_arg arg outArgs)
+  # Look for a scheme
+  if("${arg}" MATCHES "^([a-zA-Z]+):(.+)$")
+    string(TOLOWER "${CMAKE_MATCH_1}" scheme)
+    set(uri "${CMAKE_MATCH_2}")
+
+    # Check for CPM-specific schemes
+    if(scheme STREQUAL "gh")
+      set(out "GITHUB_REPOSITORY;${uri}")
+      set(packageType "git")
+    elseif(scheme STREQUAL "gl")
+      set(out "GITLAB_REPOSITORY;${uri}")
+      set(packageType "git")
+    elseif(scheme STREQUAL "bb")
+      set(out "BITBUCKET_REPOSITORY;${uri}")
+      set(packageType "git")
+      # A CPM-specific scheme was not found. Looks like this is a generic URL so try to determine
+      # type
+    elseif(arg MATCHES ".git/?(@|#|$)")
+      set(out "GIT_REPOSITORY;${arg}")
+      set(packageType "git")
+    else()
+      # Fall back to a URL
+      set(out "URL;${arg}")
+      set(packageType "archive")
+
+      # We could also check for SVN since FetchContent supports it, but SVN is so rare these days.
+      # We just won't bother with the additional complexity it will induce in this function. SVN is
+      # done by multi-arg
+    endif()
+  else()
+    if(arg MATCHES ".git/?(@|#|$)")
+      set(out "GIT_REPOSITORY;${arg}")
+      set(packageType "git")
+    else()
+      # Give up
+      message(FATAL_ERROR "${CPM_INDENT} Can't determine package type of '${arg}'")
+    endif()
+  endif()
+
+  # For all packages we interpret @... as version. Only replace the last occurrence. Thus URIs
+  # containing '@' can be used
+  string(REGEX REPLACE "@([^@]+)$" ";VERSION;\\1" out "${out}")
+
+  # Parse the rest according to package type
+  if(packageType STREQUAL "git")
+    # For git repos we interpret #... as a tag or branch or commit hash
+    string(REGEX REPLACE "#([^#]+)$" ";GIT_TAG;\\1" out "${out}")
+  elseif(packageType STREQUAL "archive")
+    # For archives we interpret #... as a URL hash.
+    string(REGEX REPLACE "#([^#]+)$" ";URL_HASH;\\1" out "${out}")
+    # We don't try to parse the version if it's not provided explicitly. cpm_get_version_from_url
+    # should do this at a later point
+  else()
+    # We should never get here. This is an assertion and hitting it means there's a problem with the
+    # code above. A packageType was set, but not handled by this if-else.
+    message(FATAL_ERROR "${CPM_INDENT} Unsupported package type '${packageType}' of '${arg}'")
+  endif()
+
+  set(${outArgs}
+      ${out}
+      PARENT_SCOPE
+  )
+endfunction()
+
+# Check that the working directory for a git repo is clean
+function(cpm_check_git_working_dir_is_clean repoPath gitTag isClean)
+
+  find_package(Git REQUIRED)
+
+  if(NOT GIT_EXECUTABLE)
+    # No git executable, assume directory is clean
+    set(${isClean}
+        TRUE
+        PARENT_SCOPE
+    )
+    return()
+  endif()
+
+  # check for uncommitted changes
+  execute_process(
+    COMMAND ${GIT_EXECUTABLE} status --porcelain
+    RESULT_VARIABLE resultGitStatus
+    OUTPUT_VARIABLE repoStatus
+    OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
+    WORKING_DIRECTORY ${repoPath}
+  )
+  if(resultGitStatus)
+    # not supposed to happen, assume clean anyway
+    message(WARNING "${CPM_INDENT} Calling git status on folder ${repoPath} failed")
+    set(${isClean}
+        TRUE
+        PARENT_SCOPE
+    )
+    return()
+  endif()
+
+  if(NOT "${repoStatus}" STREQUAL "")
+    set(${isClean}
+        FALSE
+        PARENT_SCOPE
+    )
+    return()
+  endif()
+
+  # check for committed changes
+  execute_process(
+    COMMAND ${GIT_EXECUTABLE} diff -s --exit-code ${gitTag}
+    RESULT_VARIABLE resultGitDiff
+    OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_QUIET
+    WORKING_DIRECTORY ${repoPath}
+  )
+
+  if(${resultGitDiff} EQUAL 0)
+    set(${isClean}
+        TRUE
+        PARENT_SCOPE
+    )
+  else()
+    set(${isClean}
+        FALSE
+        PARENT_SCOPE
+    )
+  endif()
+
+endfunction()
+
+# Add PATCH_COMMAND to CPM_ARGS_UNPARSED_ARGUMENTS. This method consumes a list of files in ARGN
+# then generates a `PATCH_COMMAND` appropriate for `ExternalProject_Add()`. This command is appended
+# to the parent scope's `CPM_ARGS_UNPARSED_ARGUMENTS`.
+function(cpm_add_patches)
+  # Return if no patch files are supplied.
+  if(NOT ARGN)
+    return()
+  endif()
+
+  # Find the patch program.
+  find_program(PATCH_EXECUTABLE patch)
+  if(CMAKE_HOST_WIN32 AND NOT PATCH_EXECUTABLE)
+    # The Windows git executable is distributed with patch.exe. Find the path to the executable, if
+    # it exists, then search `../usr/bin` and `../../usr/bin` for patch.exe.
+    find_package(Git QUIET)
+    if(GIT_EXECUTABLE)
+      get_filename_component(extra_search_path ${GIT_EXECUTABLE} DIRECTORY)
+      get_filename_component(extra_search_path_1up ${extra_search_path} DIRECTORY)
+      get_filename_component(extra_search_path_2up ${extra_search_path_1up} DIRECTORY)
+      find_program(
+        PATCH_EXECUTABLE patch HINTS "${extra_search_path_1up}/usr/bin"
+                                     "${extra_search_path_2up}/usr/bin"
+      )
+    endif()
+  endif()
+  if(NOT PATCH_EXECUTABLE)
+    message(FATAL_ERROR "Couldn't find `patch` executable to use with PATCHES keyword.")
+  endif()
+
+  # Create a temporary
+  set(temp_list ${CPM_ARGS_UNPARSED_ARGUMENTS})
+
+  # Ensure each file exists (or error out) and add it to the list.
+  set(first_item True)
+  foreach(PATCH_FILE ${ARGN})
+    # Make sure the patch file exists, if we can't find it, try again in the current directory.
+    if(NOT EXISTS "${PATCH_FILE}")
+      if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/${PATCH_FILE}")
+        message(FATAL_ERROR "Couldn't find patch file: '${PATCH_FILE}'")
+      endif()
+      set(PATCH_FILE "${CMAKE_CURRENT_LIST_DIR}/${PATCH_FILE}")
+    endif()
+
+    # Convert to absolute path for use with patch file command.
+    get_filename_component(PATCH_FILE "${PATCH_FILE}" ABSOLUTE)
+
+    # The first patch entry must be preceded by "PATCH_COMMAND" while the following items are
+    # preceded by "&&".
+    if(first_item)
+      set(first_item False)
+      list(APPEND temp_list "PATCH_COMMAND")
+    else()
+      list(APPEND temp_list "&&")
+    endif()
+    # Add the patch command to the list
+    list(APPEND temp_list "${PATCH_EXECUTABLE}" "-p1" "<" "${PATCH_FILE}")
+  endforeach()
+
+  # Move temp out into parent scope.
+  set(CPM_ARGS_UNPARSED_ARGUMENTS
+      ${temp_list}
+      PARENT_SCOPE
+  )
+
+endfunction()
+
+# method to overwrite internal FetchContent properties, to allow using CPM.cmake to overload
+# FetchContent calls. As these are internal cmake properties, this method should be used carefully
+# and may need modification in future CMake versions. Source:
+# https://github.com/Kitware/CMake/blob/dc3d0b5a0a7d26d43d6cfeb511e224533b5d188f/Modules/FetchContent.cmake#L1152
+function(cpm_override_fetchcontent contentName)
+  cmake_parse_arguments(PARSE_ARGV 1 arg "" "SOURCE_DIR;BINARY_DIR" "")
+  if(NOT "${arg_UNPARSED_ARGUMENTS}" STREQUAL "")
+    message(FATAL_ERROR "${CPM_INDENT} Unsupported arguments: ${arg_UNPARSED_ARGUMENTS}")
+  endif()
+
+  string(TOLOWER ${contentName} contentNameLower)
+  set(prefix "_FetchContent_${contentNameLower}")
+
+  set(propertyName "${prefix}_sourceDir")
+  define_property(
+    GLOBAL
+    PROPERTY ${propertyName}
+    BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
+    FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
+  )
+  set_property(GLOBAL PROPERTY ${propertyName} "${arg_SOURCE_DIR}")
+
+  set(propertyName "${prefix}_binaryDir")
+  define_property(
+    GLOBAL
+    PROPERTY ${propertyName}
+    BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
+    FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
+  )
+  set_property(GLOBAL PROPERTY ${propertyName} "${arg_BINARY_DIR}")
+
+  set(propertyName "${prefix}_populated")
+  define_property(
+    GLOBAL
+    PROPERTY ${propertyName}
+    BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
+    FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
+  )
+  set_property(GLOBAL PROPERTY ${propertyName} TRUE)
+endfunction()
+
+# Download and add a package from source
+function(CPMAddPackage)
+  cpm_set_policies()
+
+  list(LENGTH ARGN argnLength)
+  if(argnLength EQUAL 1)
+    cpm_parse_add_package_single_arg("${ARGN}" ARGN)
+
+    # The shorthand syntax implies EXCLUDE_FROM_ALL and SYSTEM
+    set(ARGN "${ARGN};EXCLUDE_FROM_ALL;YES;SYSTEM;YES;")
+  endif()
+
+  set(oneValueArgs
+      NAME
+      FORCE
+      VERSION
+      GIT_TAG
+      DOWNLOAD_ONLY
+      GITHUB_REPOSITORY
+      GITLAB_REPOSITORY
+      BITBUCKET_REPOSITORY
+      GIT_REPOSITORY
+      SOURCE_DIR
+      FIND_PACKAGE_ARGUMENTS
+      NO_CACHE
+      SYSTEM
+      GIT_SHALLOW
+      EXCLUDE_FROM_ALL
+      SOURCE_SUBDIR
+      CUSTOM_CACHE_KEY
+  )
+
+  set(multiValueArgs URL OPTIONS DOWNLOAD_COMMAND PATCHES)
+
+  cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
+
+  # Set default values for arguments
+
+  if(NOT DEFINED CPM_ARGS_VERSION)
+    if(DEFINED CPM_ARGS_GIT_TAG)
+      cpm_get_version_from_git_tag("${CPM_ARGS_GIT_TAG}" CPM_ARGS_VERSION)
+    endif()
+  endif()
+
+  if(CPM_ARGS_DOWNLOAD_ONLY)
+    set(DOWNLOAD_ONLY ${CPM_ARGS_DOWNLOAD_ONLY})
+  else()
+    set(DOWNLOAD_ONLY NO)
+  endif()
+
+  if(DEFINED CPM_ARGS_GITHUB_REPOSITORY)
+    set(CPM_ARGS_GIT_REPOSITORY "https://github.com/${CPM_ARGS_GITHUB_REPOSITORY}.git")
+  elseif(DEFINED CPM_ARGS_GITLAB_REPOSITORY)
+    set(CPM_ARGS_GIT_REPOSITORY "https://gitlab.com/${CPM_ARGS_GITLAB_REPOSITORY}.git")
+  elseif(DEFINED CPM_ARGS_BITBUCKET_REPOSITORY)
+    set(CPM_ARGS_GIT_REPOSITORY "https://bitbucket.org/${CPM_ARGS_BITBUCKET_REPOSITORY}.git")
+  endif()
+
+  if(DEFINED CPM_ARGS_GIT_REPOSITORY)
+    list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_REPOSITORY ${CPM_ARGS_GIT_REPOSITORY})
+    if(NOT DEFINED CPM_ARGS_GIT_TAG)
+      set(CPM_ARGS_GIT_TAG v${CPM_ARGS_VERSION})
+    endif()
+
+    # If a name wasn't provided, try to infer it from the git repo
+    if(NOT DEFINED CPM_ARGS_NAME)
+      cpm_package_name_from_git_uri(${CPM_ARGS_GIT_REPOSITORY} CPM_ARGS_NAME)
+    endif()
+  endif()
+
+  set(CPM_SKIP_FETCH FALSE)
+
+  if(DEFINED CPM_ARGS_GIT_TAG)
+    list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_TAG ${CPM_ARGS_GIT_TAG})
+    # If GIT_SHALLOW is explicitly specified, honor the value.
+    if(DEFINED CPM_ARGS_GIT_SHALLOW)
+      list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_SHALLOW ${CPM_ARGS_GIT_SHALLOW})
+    endif()
+  endif()
+
+  if(DEFINED CPM_ARGS_URL)
+    # If a name or version aren't provided, try to infer them from the URL
+    list(GET CPM_ARGS_URL 0 firstUrl)
+    cpm_package_name_and_ver_from_url(${firstUrl} nameFromUrl verFromUrl)
+    # If we fail to obtain name and version from the first URL, we could try other URLs if any.
+    # However multiple URLs are expected to be quite rare, so for now we won't bother.
+
+    # If the caller provided their own name and version, they trump the inferred ones.
+    if(NOT DEFINED CPM_ARGS_NAME)
+      set(CPM_ARGS_NAME ${nameFromUrl})
+    endif()
+    if(NOT DEFINED CPM_ARGS_VERSION)
+      set(CPM_ARGS_VERSION ${verFromUrl})
+    endif()
+
+    list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS URL "${CPM_ARGS_URL}")
+  endif()
+
+  # Check for required arguments
+
+  if(NOT DEFINED CPM_ARGS_NAME)
+    message(
+      FATAL_ERROR
+        "${CPM_INDENT} 'NAME' was not provided and couldn't be automatically inferred for package added with arguments: '${ARGN}'"
+    )
+  endif()
+
+  # Check if package has been added before
+  cpm_check_if_package_already_added(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}")
+  if(CPM_PACKAGE_ALREADY_ADDED)
+    cpm_export_variables(${CPM_ARGS_NAME})
+    return()
+  endif()
+
+  # Check for manual overrides
+  if(NOT CPM_ARGS_FORCE AND NOT "${CPM_${CPM_ARGS_NAME}_SOURCE}" STREQUAL "")
+    set(PACKAGE_SOURCE ${CPM_${CPM_ARGS_NAME}_SOURCE})
+    set(CPM_${CPM_ARGS_NAME}_SOURCE "")
+    CPMAddPackage(
+      NAME "${CPM_ARGS_NAME}"
+      SOURCE_DIR "${PACKAGE_SOURCE}"
+      EXCLUDE_FROM_ALL "${CPM_ARGS_EXCLUDE_FROM_ALL}"
+      SYSTEM "${CPM_ARGS_SYSTEM}"
+      PATCHES "${CPM_ARGS_PATCHES}"
+      OPTIONS "${CPM_ARGS_OPTIONS}"
+      SOURCE_SUBDIR "${CPM_ARGS_SOURCE_SUBDIR}"
+      DOWNLOAD_ONLY "${DOWNLOAD_ONLY}"
+      FORCE True
+    )
+    cpm_export_variables(${CPM_ARGS_NAME})
+    return()
+  endif()
+
+  # Check for available declaration
+  if(NOT CPM_ARGS_FORCE AND NOT "${CPM_DECLARATION_${CPM_ARGS_NAME}}" STREQUAL "")
+    set(declaration ${CPM_DECLARATION_${CPM_ARGS_NAME}})
+    set(CPM_DECLARATION_${CPM_ARGS_NAME} "")
+    CPMAddPackage(${declaration})
+    cpm_export_variables(${CPM_ARGS_NAME})
+    # checking again to ensure version and option compatibility
+    cpm_check_if_package_already_added(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}")
+    return()
+  endif()
+
+  if(NOT CPM_ARGS_FORCE)
+    if(CPM_USE_LOCAL_PACKAGES OR CPM_LOCAL_PACKAGES_ONLY)
+      cpm_find_package(${CPM_ARGS_NAME} "${CPM_ARGS_VERSION}" ${CPM_ARGS_FIND_PACKAGE_ARGUMENTS})
+
+      if(CPM_PACKAGE_FOUND)
+        cpm_export_variables(${CPM_ARGS_NAME})
+        return()
+      endif()
+
+      if(CPM_LOCAL_PACKAGES_ONLY)
+        message(
+          SEND_ERROR
+            "${CPM_INDENT} ${CPM_ARGS_NAME} not found via find_package(${CPM_ARGS_NAME} ${CPM_ARGS_VERSION})"
+        )
+      endif()
+    endif()
+  endif()
+
+  CPMRegisterPackage("${CPM_ARGS_NAME}" "${CPM_ARGS_VERSION}")
+
+  if(DEFINED CPM_ARGS_GIT_TAG)
+    set(PACKAGE_INFO "${CPM_ARGS_GIT_TAG}")
+  elseif(DEFINED CPM_ARGS_SOURCE_DIR)
+    set(PACKAGE_INFO "${CPM_ARGS_SOURCE_DIR}")
+  else()
+    set(PACKAGE_INFO "${CPM_ARGS_VERSION}")
+  endif()
+
+  if(DEFINED FETCHCONTENT_BASE_DIR)
+    # respect user's FETCHCONTENT_BASE_DIR if set
+    set(CPM_FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR})
+  else()
+    set(CPM_FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/_deps)
+  endif()
+
+  cpm_add_patches(${CPM_ARGS_PATCHES})
+
+  if(DEFINED CPM_ARGS_DOWNLOAD_COMMAND)
+    list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS DOWNLOAD_COMMAND ${CPM_ARGS_DOWNLOAD_COMMAND})
+  elseif(DEFINED CPM_ARGS_SOURCE_DIR)
+    list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS SOURCE_DIR ${CPM_ARGS_SOURCE_DIR})
+    if(NOT IS_ABSOLUTE ${CPM_ARGS_SOURCE_DIR})
+      # Expand `CPM_ARGS_SOURCE_DIR` relative path. This is important because EXISTS doesn't work
+      # for relative paths.
+      get_filename_component(
+        source_directory ${CPM_ARGS_SOURCE_DIR} REALPATH BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}
+      )
+    else()
+      set(source_directory ${CPM_ARGS_SOURCE_DIR})
+    endif()
+    if(NOT EXISTS ${source_directory})
+      string(TOLOWER ${CPM_ARGS_NAME} lower_case_name)
+      # remove timestamps so CMake will re-download the dependency
+      file(REMOVE_RECURSE "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild")
+    endif()
+  elseif(CPM_SOURCE_CACHE AND NOT CPM_ARGS_NO_CACHE)
+    string(TOLOWER ${CPM_ARGS_NAME} lower_case_name)
+    set(origin_parameters ${CPM_ARGS_UNPARSED_ARGUMENTS})
+    list(SORT origin_parameters)
+    if(CPM_ARGS_CUSTOM_CACHE_KEY)
+      # Application set a custom unique directory name
+      set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${CPM_ARGS_CUSTOM_CACHE_KEY})
+    elseif(CPM_USE_NAMED_CACHE_DIRECTORIES)
+      string(SHA1 origin_hash "${origin_parameters};NEW_CACHE_STRUCTURE_TAG")
+      set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${origin_hash}/${CPM_ARGS_NAME})
+    else()
+      string(SHA1 origin_hash "${origin_parameters}")
+      set(download_directory ${CPM_SOURCE_CACHE}/${lower_case_name}/${origin_hash})
+    endif()
+    # Expand `download_directory` relative path. This is important because EXISTS doesn't work for
+    # relative paths.
+    get_filename_component(download_directory ${download_directory} ABSOLUTE)
+    list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS SOURCE_DIR ${download_directory})
+
+    if(CPM_SOURCE_CACHE)
+      file(LOCK ${download_directory}/../cmake.lock)
+    endif()
+
+    if(EXISTS ${download_directory})
+      if(CPM_SOURCE_CACHE)
+        file(LOCK ${download_directory}/../cmake.lock RELEASE)
+      endif()
+
+      cpm_store_fetch_properties(
+        ${CPM_ARGS_NAME} "${download_directory}"
+        "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-build"
+      )
+      cpm_get_fetch_properties("${CPM_ARGS_NAME}")
+
+      if(DEFINED CPM_ARGS_GIT_TAG AND NOT (PATCH_COMMAND IN_LIST CPM_ARGS_UNPARSED_ARGUMENTS))
+        # warn if cache has been changed since checkout
+        cpm_check_git_working_dir_is_clean(${download_directory} ${CPM_ARGS_GIT_TAG} IS_CLEAN)
+        if(NOT ${IS_CLEAN})
+          message(
+            WARNING "${CPM_INDENT} Cache for ${CPM_ARGS_NAME} (${download_directory}) is dirty"
+          )
+        endif()
+      endif()
+
+      cpm_add_subdirectory(
+        "${CPM_ARGS_NAME}"
+        "${DOWNLOAD_ONLY}"
+        "${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}"
+        "${${CPM_ARGS_NAME}_BINARY_DIR}"
+        "${CPM_ARGS_EXCLUDE_FROM_ALL}"
+        "${CPM_ARGS_SYSTEM}"
+        "${CPM_ARGS_OPTIONS}"
+      )
+      set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}")
+
+      # As the source dir is already cached/populated, we override the call to FetchContent.
+      set(CPM_SKIP_FETCH TRUE)
+      cpm_override_fetchcontent(
+        "${lower_case_name}" SOURCE_DIR "${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}"
+        BINARY_DIR "${${CPM_ARGS_NAME}_BINARY_DIR}"
+      )
+
+    else()
+      # Enable shallow clone when GIT_TAG is not a commit hash. Our guess may not be accurate, but
+      # it should guarantee no commit hash get mis-detected.
+      if(NOT DEFINED CPM_ARGS_GIT_SHALLOW)
+        cpm_is_git_tag_commit_hash("${CPM_ARGS_GIT_TAG}" IS_HASH)
+        if(NOT ${IS_HASH})
+          list(APPEND CPM_ARGS_UNPARSED_ARGUMENTS GIT_SHALLOW TRUE)
+        endif()
+      endif()
+
+      # remove timestamps so CMake will re-download the dependency
+      file(REMOVE_RECURSE ${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild)
+      set(PACKAGE_INFO "${PACKAGE_INFO} to ${download_directory}")
+    endif()
+  endif()
+
+  if(NOT "${DOWNLOAD_ONLY}")
+    cpm_create_module_file(${CPM_ARGS_NAME} "CPMAddPackage(\"${ARGN}\")")
+  endif()
+
+  if(CPM_PACKAGE_LOCK_ENABLED)
+    if((CPM_ARGS_VERSION AND NOT CPM_ARGS_SOURCE_DIR) OR CPM_INCLUDE_ALL_IN_PACKAGE_LOCK)
+      cpm_add_to_package_lock(${CPM_ARGS_NAME} "${ARGN}")
+    elseif(CPM_ARGS_SOURCE_DIR)
+      cpm_add_comment_to_package_lock(${CPM_ARGS_NAME} "local directory")
+    else()
+      cpm_add_comment_to_package_lock(${CPM_ARGS_NAME} "${ARGN}")
+    endif()
+  endif()
+
+  cpm_message(
+    STATUS "${CPM_INDENT} Adding package ${CPM_ARGS_NAME}@${CPM_ARGS_VERSION} (${PACKAGE_INFO})"
+  )
+
+  if(NOT CPM_SKIP_FETCH)
+    # CMake 3.28 added EXCLUDE, SYSTEM (3.25), and SOURCE_SUBDIR (3.18) to FetchContent_Declare.
+    # Calling FetchContent_MakeAvailable will then internally forward these options to
+    # add_subdirectory. Up until these changes, we had to call FetchContent_Populate and
+    # add_subdirectory separately, which is no longer necessary and has been deprecated as of 3.30.
+    # A Bug in CMake prevents us to use the non-deprecated functions until 3.30.3.
+    set(fetchContentDeclareExtraArgs "")
+    if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.30.3")
+      if(${CPM_ARGS_EXCLUDE_FROM_ALL})
+        list(APPEND fetchContentDeclareExtraArgs EXCLUDE_FROM_ALL)
+      endif()
+      if(${CPM_ARGS_SYSTEM})
+        list(APPEND fetchContentDeclareExtraArgs SYSTEM)
+      endif()
+      if(DEFINED CPM_ARGS_SOURCE_SUBDIR)
+        list(APPEND fetchContentDeclareExtraArgs SOURCE_SUBDIR ${CPM_ARGS_SOURCE_SUBDIR})
+      endif()
+      # For CMake version <3.28 OPTIONS are parsed in cpm_add_subdirectory
+      if(CPM_ARGS_OPTIONS AND NOT DOWNLOAD_ONLY)
+        foreach(OPTION ${CPM_ARGS_OPTIONS})
+          cpm_parse_option("${OPTION}")
+          set(${OPTION_KEY} "${OPTION_VALUE}")
+        endforeach()
+      endif()
+    endif()
+    cpm_declare_fetch(
+      "${CPM_ARGS_NAME}" ${fetchContentDeclareExtraArgs} "${CPM_ARGS_UNPARSED_ARGUMENTS}"
+    )
+
+    cpm_fetch_package("${CPM_ARGS_NAME}" ${DOWNLOAD_ONLY} populated ${CPM_ARGS_UNPARSED_ARGUMENTS})
+    if(CPM_SOURCE_CACHE AND download_directory)
+      file(LOCK ${download_directory}/../cmake.lock RELEASE)
+    endif()
+    if(${populated} AND ${CMAKE_VERSION} VERSION_LESS "3.30.3")
+      cpm_add_subdirectory(
+        "${CPM_ARGS_NAME}"
+        "${DOWNLOAD_ONLY}"
+        "${${CPM_ARGS_NAME}_SOURCE_DIR}/${CPM_ARGS_SOURCE_SUBDIR}"
+        "${${CPM_ARGS_NAME}_BINARY_DIR}"
+        "${CPM_ARGS_EXCLUDE_FROM_ALL}"
+        "${CPM_ARGS_SYSTEM}"
+        "${CPM_ARGS_OPTIONS}"
+      )
+    endif()
+    cpm_get_fetch_properties("${CPM_ARGS_NAME}")
+  endif()
+
+  set(${CPM_ARGS_NAME}_ADDED YES)
+  cpm_export_variables("${CPM_ARGS_NAME}")
+endfunction()
+
+# Fetch a previously declared package
+macro(CPMGetPackage Name)
+  if(DEFINED "CPM_DECLARATION_${Name}")
+    CPMAddPackage(NAME ${Name})
+  else()
+    message(SEND_ERROR "${CPM_INDENT} Cannot retrieve package ${Name}: no declaration available")
+  endif()
+endmacro()
+
+# export variables available to the caller to the parent scope expects ${CPM_ARGS_NAME} to be set
+macro(cpm_export_variables name)
+  set(${name}_SOURCE_DIR
+      "${${name}_SOURCE_DIR}"
+      PARENT_SCOPE
+  )
+  set(${name}_BINARY_DIR
+      "${${name}_BINARY_DIR}"
+      PARENT_SCOPE
+  )
+  set(${name}_ADDED
+      "${${name}_ADDED}"
+      PARENT_SCOPE
+  )
+  set(CPM_LAST_PACKAGE_NAME
+      "${name}"
+      PARENT_SCOPE
+  )
+endmacro()
+
+# declares a package, so that any call to CPMAddPackage for the package name will use these
+# arguments instead. Previous declarations will not be overridden.
+macro(CPMDeclarePackage Name)
+  if(NOT DEFINED "CPM_DECLARATION_${Name}")
+    set("CPM_DECLARATION_${Name}" "${ARGN}")
+  endif()
+endmacro()
+
+function(cpm_add_to_package_lock Name)
+  if(NOT CPM_DONT_CREATE_PACKAGE_LOCK)
+    cpm_prettify_package_arguments(PRETTY_ARGN false ${ARGN})
+    file(APPEND ${CPM_PACKAGE_LOCK_FILE} "# ${Name}\nCPMDeclarePackage(${Name}\n${PRETTY_ARGN})\n")
+  endif()
+endfunction()
+
+function(cpm_add_comment_to_package_lock Name)
+  if(NOT CPM_DONT_CREATE_PACKAGE_LOCK)
+    cpm_prettify_package_arguments(PRETTY_ARGN true ${ARGN})
+    file(APPEND ${CPM_PACKAGE_LOCK_FILE}
+         "# ${Name} (unversioned)\n# CPMDeclarePackage(${Name}\n${PRETTY_ARGN}#)\n"
+    )
+  endif()
+endfunction()
+
+# includes the package lock file if it exists and creates a target `cpm-update-package-lock` to
+# update it
+macro(CPMUsePackageLock file)
+  if(NOT CPM_DONT_CREATE_PACKAGE_LOCK)
+    get_filename_component(CPM_ABSOLUTE_PACKAGE_LOCK_PATH ${file} ABSOLUTE)
+    if(EXISTS ${CPM_ABSOLUTE_PACKAGE_LOCK_PATH})
+      include(${CPM_ABSOLUTE_PACKAGE_LOCK_PATH})
+    endif()
+    if(NOT TARGET cpm-update-package-lock)
+      add_custom_target(
+        cpm-update-package-lock COMMAND ${CMAKE_COMMAND} -E copy ${CPM_PACKAGE_LOCK_FILE}
+                                        ${CPM_ABSOLUTE_PACKAGE_LOCK_PATH}
+      )
+    endif()
+    set(CPM_PACKAGE_LOCK_ENABLED true)
+  endif()
+endmacro()
+
+# registers a package that has been added to CPM
+function(CPMRegisterPackage PACKAGE VERSION)
+  list(APPEND CPM_PACKAGES ${PACKAGE})
+  set(CPM_PACKAGES
+      ${CPM_PACKAGES}
+      CACHE INTERNAL ""
+  )
+  set("CPM_PACKAGE_${PACKAGE}_VERSION"
+      ${VERSION}
+      CACHE INTERNAL ""
+  )
+endfunction()
+
+# retrieve the current version of the package to ${OUTPUT}
+function(CPMGetPackageVersion PACKAGE OUTPUT)
+  set(${OUTPUT}
+      "${CPM_PACKAGE_${PACKAGE}_VERSION}"
+      PARENT_SCOPE
+  )
+endfunction()
+
+# declares a package in FetchContent_Declare
+function(cpm_declare_fetch PACKAGE)
+  if(${CPM_DRY_RUN})
+    cpm_message(STATUS "${CPM_INDENT} Package not declared (dry run)")
+    return()
+  endif()
+
+  FetchContent_Declare(${PACKAGE} ${ARGN})
+endfunction()
+
+# returns properties for a package previously defined by cpm_declare_fetch
+function(cpm_get_fetch_properties PACKAGE)
+  if(${CPM_DRY_RUN})
+    return()
+  endif()
+
+  set(${PACKAGE}_SOURCE_DIR
+      "${CPM_PACKAGE_${PACKAGE}_SOURCE_DIR}"
+      PARENT_SCOPE
+  )
+  set(${PACKAGE}_BINARY_DIR
+      "${CPM_PACKAGE_${PACKAGE}_BINARY_DIR}"
+      PARENT_SCOPE
+  )
+endfunction()
+
+function(cpm_store_fetch_properties PACKAGE source_dir binary_dir)
+  if(${CPM_DRY_RUN})
+    return()
+  endif()
+
+  set(CPM_PACKAGE_${PACKAGE}_SOURCE_DIR
+      "${source_dir}"
+      CACHE INTERNAL ""
+  )
+  set(CPM_PACKAGE_${PACKAGE}_BINARY_DIR
+      "${binary_dir}"
+      CACHE INTERNAL ""
+  )
+endfunction()
+
+# adds a package as a subdirectory if viable, according to provided options
+function(
+  cpm_add_subdirectory
+  PACKAGE
+  DOWNLOAD_ONLY
+  SOURCE_DIR
+  BINARY_DIR
+  EXCLUDE
+  SYSTEM
+  OPTIONS
+)
+
+  if(NOT DOWNLOAD_ONLY AND EXISTS ${SOURCE_DIR}/CMakeLists.txt)
+    set(addSubdirectoryExtraArgs "")
+    if(EXCLUDE)
+      list(APPEND addSubdirectoryExtraArgs EXCLUDE_FROM_ALL)
+    endif()
+    if("${SYSTEM}" AND "${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.25")
+      # https://cmake.org/cmake/help/latest/prop_dir/SYSTEM.html#prop_dir:SYSTEM
+      list(APPEND addSubdirectoryExtraArgs SYSTEM)
+    endif()
+    if(OPTIONS)
+      foreach(OPTION ${OPTIONS})
+        cpm_parse_option("${OPTION}")
+        set(${OPTION_KEY} "${OPTION_VALUE}")
+      endforeach()
+    endif()
+    set(CPM_OLD_INDENT "${CPM_INDENT}")
+    set(CPM_INDENT "${CPM_INDENT} ${PACKAGE}:")
+    add_subdirectory(${SOURCE_DIR} ${BINARY_DIR} ${addSubdirectoryExtraArgs})
+    set(CPM_INDENT "${CPM_OLD_INDENT}")
+  endif()
+endfunction()
+
+# downloads a previously declared package via FetchContent and exports the variables
+# `${PACKAGE}_SOURCE_DIR` and `${PACKAGE}_BINARY_DIR` to the parent scope
+function(cpm_fetch_package PACKAGE DOWNLOAD_ONLY populated)
+  set(${populated}
+      FALSE
+      PARENT_SCOPE
+  )
+  if(${CPM_DRY_RUN})
+    cpm_message(STATUS "${CPM_INDENT} Package ${PACKAGE} not fetched (dry run)")
+    return()
+  endif()
+
+  FetchContent_GetProperties(${PACKAGE})
+
+  string(TOLOWER "${PACKAGE}" lower_case_name)
+
+  if(NOT ${lower_case_name}_POPULATED)
+    if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.30.3")
+      if(DOWNLOAD_ONLY)
+        # MakeAvailable will call add_subdirectory internally which is not what we want when
+        # DOWNLOAD_ONLY is set. Populate will only download the dependency without adding it to the
+        # build
+        FetchContent_Populate(
+          ${PACKAGE}
+          SOURCE_DIR "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-src"
+          BINARY_DIR "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-build"
+          SUBBUILD_DIR "${CPM_FETCHCONTENT_BASE_DIR}/${lower_case_name}-subbuild"
+          ${ARGN}
+        )
+      else()
+        FetchContent_MakeAvailable(${PACKAGE})
+      endif()
+    else()
+      FetchContent_Populate(${PACKAGE})
+    endif()
+    set(${populated}
+        TRUE
+        PARENT_SCOPE
+    )
+  endif()
+
+  cpm_store_fetch_properties(
+    ${CPM_ARGS_NAME} ${${lower_case_name}_SOURCE_DIR} ${${lower_case_name}_BINARY_DIR}
+  )
+
+  set(${PACKAGE}_SOURCE_DIR
+      ${${lower_case_name}_SOURCE_DIR}
+      PARENT_SCOPE
+  )
+  set(${PACKAGE}_BINARY_DIR
+      ${${lower_case_name}_BINARY_DIR}
+      PARENT_SCOPE
+  )
+endfunction()
+
+# splits a package option
+function(cpm_parse_option OPTION)
+  string(REGEX MATCH "^[^ ]+" OPTION_KEY "${OPTION}")
+  string(LENGTH "${OPTION}" OPTION_LENGTH)
+  string(LENGTH "${OPTION_KEY}" OPTION_KEY_LENGTH)
+  if(OPTION_KEY_LENGTH STREQUAL OPTION_LENGTH)
+    # no value for key provided, assume user wants to set option to "ON"
+    set(OPTION_VALUE "ON")
+  else()
+    math(EXPR OPTION_KEY_LENGTH "${OPTION_KEY_LENGTH}+1")
+    string(SUBSTRING "${OPTION}" "${OPTION_KEY_LENGTH}" "-1" OPTION_VALUE)
+  endif()
+  set(OPTION_KEY
+      "${OPTION_KEY}"
+      PARENT_SCOPE
+  )
+  set(OPTION_VALUE
+      "${OPTION_VALUE}"
+      PARENT_SCOPE
+  )
+endfunction()
+
+# guesses the package version from a git tag
+function(cpm_get_version_from_git_tag GIT_TAG RESULT)
+  string(LENGTH ${GIT_TAG} length)
+  if(length EQUAL 40)
+    # GIT_TAG is probably a git hash
+    set(${RESULT}
+        0
+        PARENT_SCOPE
+    )
+  else()
+    string(REGEX MATCH "v?([0123456789.]*).*" _ ${GIT_TAG})
+    set(${RESULT}
+        ${CMAKE_MATCH_1}
+        PARENT_SCOPE
+    )
+  endif()
+endfunction()
+
+# guesses if the git tag is a commit hash or an actual tag or a branch name.
+function(cpm_is_git_tag_commit_hash GIT_TAG RESULT)
+  string(LENGTH "${GIT_TAG}" length)
+  # full hash has 40 characters, and short hash has at least 7 characters.
+  if(length LESS 7 OR length GREATER 40)
+    set(${RESULT}
+        0
+        PARENT_SCOPE
+    )
+  else()
+    if(${GIT_TAG} MATCHES "^[a-fA-F0-9]+$")
+      set(${RESULT}
+          1
+          PARENT_SCOPE
+      )
+    else()
+      set(${RESULT}
+          0
+          PARENT_SCOPE
+      )
+    endif()
+  endif()
+endfunction()
+
+function(cpm_prettify_package_arguments OUT_VAR IS_IN_COMMENT)
+  set(oneValueArgs
+      NAME
+      FORCE
+      VERSION
+      GIT_TAG
+      DOWNLOAD_ONLY
+      GITHUB_REPOSITORY
+      GITLAB_REPOSITORY
+      BITBUCKET_REPOSITORY
+      GIT_REPOSITORY
+      SOURCE_DIR
+      FIND_PACKAGE_ARGUMENTS
+      NO_CACHE
+      SYSTEM
+      GIT_SHALLOW
+      EXCLUDE_FROM_ALL
+      SOURCE_SUBDIR
+  )
+  set(multiValueArgs URL OPTIONS DOWNLOAD_COMMAND)
+  cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+  foreach(oneArgName ${oneValueArgs})
+    if(DEFINED CPM_ARGS_${oneArgName})
+      if(${IS_IN_COMMENT})
+        string(APPEND PRETTY_OUT_VAR "#")
+      endif()
+      if(${oneArgName} STREQUAL "SOURCE_DIR")
+        string(REPLACE ${CMAKE_SOURCE_DIR} "\${CMAKE_SOURCE_DIR}" CPM_ARGS_${oneArgName}
+                       ${CPM_ARGS_${oneArgName}}
+        )
+      endif()
+      string(APPEND PRETTY_OUT_VAR "  ${oneArgName} ${CPM_ARGS_${oneArgName}}\n")
+    endif()
+  endforeach()
+  foreach(multiArgName ${multiValueArgs})
+    if(DEFINED CPM_ARGS_${multiArgName})
+      if(${IS_IN_COMMENT})
+        string(APPEND PRETTY_OUT_VAR "#")
+      endif()
+      string(APPEND PRETTY_OUT_VAR "  ${multiArgName}\n")
+      foreach(singleOption ${CPM_ARGS_${multiArgName}})
+        if(${IS_IN_COMMENT})
+          string(APPEND PRETTY_OUT_VAR "#")
+        endif()
+        string(APPEND PRETTY_OUT_VAR "    \"${singleOption}\"\n")
+      endforeach()
+    endif()
+  endforeach()
+
+  if(NOT "${CPM_ARGS_UNPARSED_ARGUMENTS}" STREQUAL "")
+    if(${IS_IN_COMMENT})
+      string(APPEND PRETTY_OUT_VAR "#")
+    endif()
+    string(APPEND PRETTY_OUT_VAR " ")
+    foreach(CPM_ARGS_UNPARSED_ARGUMENT ${CPM_ARGS_UNPARSED_ARGUMENTS})
+      string(APPEND PRETTY_OUT_VAR " ${CPM_ARGS_UNPARSED_ARGUMENT}")
+    endforeach()
+    string(APPEND PRETTY_OUT_VAR "\n")
+  endif()
+
+  set(${OUT_VAR}
+      ${PRETTY_OUT_VAR}
+      PARENT_SCOPE
+  )
+
+endfunction()


=====================================
doc/mkdssp.md
=====================================
@@ -92,13 +92,7 @@ calculated for H-bonds.\
 
 # BUGS
 
-The mmCIF format currently lacks a lot of information that was available
-in the old format like information about the bridge pairs or the span of
-the various helices recognized. Also the accessibility information is
-left out.
-
-If you think this information should be part of the output, please
-contact the author.
+If mkdssp does not behave as expected, please contact the author.
 
 # AUTHOR
 


=====================================
libdssp/CMakeLists.txt
=====================================
@@ -1,6 +1,6 @@
 # Use the version of the parent list file, if any. May need a fix someday.
 if(NOT CMAKE_PARENT_LIST_FILE)
-	set(PROJECT_VERSION 4.4.8)
+	set(PROJECT_VERSION 4.5.2)
 endif()
 
 project(libdssp VERSION ${PROJECT_VERSION})
@@ -42,7 +42,7 @@ target_include_directories(dssp
 # Install rules
 install(TARGETS dssp
 	EXPORT dssp
-	FILE_SET dssp_header DESTINATION "include")
+	FILE_SET dssp_header DESTINATION include)
 
 if(MSVC AND BUILD_SHARED_LIBS)
 	install(
@@ -52,25 +52,19 @@ if(MSVC AND BUILD_SHARED_LIBS)
 endif()
 
 install(EXPORT dssp
-	FILE "dsspTargets.cmake"
+	FILE "dssp-targets.cmake"
 	NAMESPACE dssp::
 	DESTINATION lib/cmake/dssp
 )
 
-set(CONFIG_TEMPLATE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/dsspConfig.cmake.in)
+set(CONFIG_TEMPLATE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/dssp-config.cmake.in)
 
 configure_package_config_file(
 	${CONFIG_TEMPLATE_FILE}
-	${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfig.cmake
+	${CMAKE_CURRENT_BINARY_DIR}/dssp/dssp-config.cmake
 	INSTALL_DESTINATION lib/cmake/dssp
 )
 
-install(FILES
-	"${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfig.cmake"
-	DESTINATION lib/cmake/dssp
-	COMPONENT Devel
-)
-
 set(dssp_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR})
 set_target_properties(dssp PROPERTIES
 	VERSION ${PROJECT_VERSION}
@@ -82,11 +76,19 @@ set_property(TARGET dssp APPEND PROPERTY
 )
 
 write_basic_package_version_file(
-	"${CMAKE_CURRENT_BINARY_DIR}/dssp/dsspConfigVersion.cmake"
+	"${CMAKE_CURRENT_BINARY_DIR}/dssp/dssp-config-version.cmake"
 	VERSION ${PROJECT_VERSION}
 	COMPATIBILITY AnyNewerVersion
 )
 
+install(FILES
+	"${CMAKE_CURRENT_BINARY_DIR}/dssp/dssp-config.cmake"
+	"${CMAKE_CURRENT_BINARY_DIR}/dssp/dssp-config-version.cmake"
+	DESTINATION lib/cmake/dssp
+	COMPONENT Devel
+)
+
+
 # set(CIFPP_DATA_DIR "${CMAKE_INSTALL_FULL_DATADIR}/libcifpp")
 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mmcif_pdbx/dssp-extension.dic"
         DESTINATION share/libcifpp)


=====================================
libdssp/cmake/dsspConfig.cmake.in → libdssp/cmake/dssp-config.cmake.in
=====================================
@@ -3,6 +3,6 @@
 include(CMakeFindDependencyMacro)
 find_dependency(cifpp REQUIRED)
 
-INCLUDE("${CMAKE_CURRENT_LIST_DIR}/dsspTargets.cmake")
+INCLUDE("${CMAKE_CURRENT_LIST_DIR}/dssp-targets.cmake")
 
 check_required_components(dssp)


=====================================
libdssp/include/dssp.hpp
=====================================
@@ -146,9 +146,18 @@ class dssp
 		bool is_cis() const { return std::abs(omega().value_or(360)) < 30.0f; }
 
 		float chiral_volume() const;
+
 		std::size_t nr_of_chis() const;
 		float chi(std::size_t index) const;
 
+		std::vector<float> chis() const
+		{
+			std::vector<float> result;
+			for (size_t i = 0; i < nr_of_chis(); ++i)
+				result.push_back(chi(i));
+			return result;
+		}
+
 		std::tuple<float, float, float> ca_location() const;
 
 		chain_break_type chain_break() const;
@@ -187,6 +196,8 @@ class dssp
 		/// \brief Returns \result true if there is a bond between two residues
 		friend bool test_bond(residue_info const &a, residue_info const &b);
 
+		residue_info next() const;
+
 	  private:
 		residue_info(residue *res)
 			: m_impl(res)
@@ -250,7 +261,7 @@ class dssp
 	// --------------------------------------------------------------------
 	// Writing out the data, either in legacy format...
 
-	void write_legacy_output(std::ostream& os) const;
+	void write_legacy_output(std::ostream &os) const;
 
 	// ... or as annotation in the cif::datablock
 	void annotate(cif::datablock &db, bool writeOther, bool writeDSSPCategories) const;
@@ -270,4 +281,3 @@ class dssp
   private:
 	struct DSSP_impl *m_impl;
 };
-


=====================================
libdssp/mmcif_pdbx/dssp-extension.dic
=====================================
@@ -1,11 +1,36 @@
-## File: dssp-extension.dic
-## Date: 30-May-2023
-##
-# Items containing Secondary Structure information as written by e.g. DSSP
-#
-#
+# File: dssp-extension.dic
+# Date: 30-May-2023
+
+data_dssp-extension.dic
+
+_datablock.id			dssp-extension.dic
+_datablock.description
+;
+	This data block holds the dictionary for Secondary Structure information as written by e.g. DSSP
+;
 
-data_mmcif_pdbx-def-dssp.dic
+_dictionary.title			dssp-extension.dic
+_dictionary.datablock_id	dssp-extension.dic
+_dictionary.version			1.1.1
+
+loop_
+_dictionary_history.version
+_dictionary_history.update
+_dictionary_history.revision
+1.0	2023-05-30
+;
+	Initial release
+;
+1.1	2025-02-26
+;
+	Changes (mlh)
+	+ Added dictionary blocks
+;
+1.1.1 2025-05-12
+;
+	Changes (mlh)
+	+ Changed mandatory_code of accessible_surface_of_protein to no
+;
 
 ########################################
 ##  Category dssp_struct_bridge_pairs ##
@@ -922,6 +947,10 @@ save__dssp_statistics.entry_id
 	_item.category_id        dssp_statistics
 	_item.mandatory_code     yes
 	_item_type.code          code
+	#
+	_item_linked.child_name   "_dssp_statistics.entry_id"
+	_item_linked.parent_name  "_entry.id"
+	#
 	save_
 
 save__dssp_statistics.nr_of_residues
@@ -980,7 +1009,7 @@ save__dssp_statistics.accessible_surface_of_protein
 ;
 	_item.name               '_dssp_statistics.accessible_surface_of_protein'
 	_item.category_id        dssp_statistics
-	_item.mandatory_code     yes
+	_item.mandatory_code     no
 	_item_type.code          float
 	save_
 
@@ -1025,6 +1054,10 @@ save__dssp_statistics_hbond.entry_id
 	_item.category              dssp_statistics_hbond
 	_item.mandatory_code        yes
 	_item_type.code             code
+	#
+	_item_linked.child_name   "_dssp_statistics_hbond.entry_id"
+	_item_linked.parent_name  "_entry.id"
+	#
 	save_
 
 save__dssp_statistics_hbond.type
@@ -1143,6 +1176,10 @@ save__dssp_statistics_histogram.entry_id
 	_item.category          dssp_statistics_histogram
 	_item.mandatory_code    yes
 	_item_type.code         code
+	#
+	_item_linked.child_name   "_dssp_statistics_histogram.entry_id"
+	_item_linked.parent_name  "_entry.id"
+	#
 	save_
 
 save__dssp_statistics_histogram.type
@@ -1526,6 +1563,10 @@ save__dssp_struct_summary.entry_id
 	_item.category         dssp_struct_summary
 	_item.mandatory_code   yes
 	_item_type.code        code
+	#
+	_item_linked.child_name   "_dssp_struct_summary.entry_id"
+	_item_linked.parent_name  "_entry.id"
+	#
 	save_
 
 save__dssp_struct_summary.label_comp_id


=====================================
libdssp/src/dssp-io.cpp
=====================================
@@ -162,7 +162,7 @@ void writeDSSP(const dssp &dssp, std::ostream &os)
 		version.insert(version.end(), 10 - version.length(), ' ');
 
 	os << "==== Secondary Structure Definition by the program DSSP, NKI version " << version << "                    ==== DATE=" << std::put_time(tm, "%F") << "        ." << std::endl
-	   << "REFERENCE W. KABSCH AND C.SANDER, BIOPOLYMERS 22 (1983) 2577-2637                                                              ." << std::endl
+	   << "REFERENCE M.L. HEKKELMAN ET AL, PROTEIN SCIENCE 34.8 (2025) e70208; W. KABSCH AND C.SANDER, BIOPOLYMERS 22 (1983) 2577-2637    ." << std::endl
 	   << dssp.get_pdb_header_line(dssp::pdb_record_type::HEADER) << '.' << std::endl
 	   << dssp.get_pdb_header_line(dssp::pdb_record_type::COMPND) << '.' << std::endl
 	   << dssp.get_pdb_header_line(dssp::pdb_record_type::SOURCE) << '.' << std::endl
@@ -250,16 +250,14 @@ void writeBridgePairs(cif::datablock &db, const dssp &dssp)
 
 	for (auto &res : dssp)
 	{
-		cif::row_initializer data({
-			{ "id", hb.get_unique_id("") },
+		cif::row_initializer data({ { "id", hb.get_unique_id("") },
 			{ "label_comp_id", res.compound_id() },
 			{ "label_seq_id", res.seq_id() },
 			{ "label_asym_id", res.asym_id() },
 			// { "auth_comp_id", res.compound_id() },
 			{ "auth_seq_id", res.auth_seq_id() },
 			{ "auth_asym_id", res.auth_asym_id() },
-			{ "pdbx_PDB_ins_code", res.pdb_ins_code() }
-		});
+			{ "pdbx_PDB_ins_code", res.pdb_ins_code() } });
 
 		for (int i : { 0, 1 })
 		{
@@ -338,7 +336,7 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
 
 	// create a list of strands, based on the SS info in DSSP. Store sheet number along with the strand.
 
-	std::map<std::tuple<int,int>, res_list> strands;
+	std::map<std::tuple<int, int>, res_list> strands;
 	std::set<int> sheetNrs;
 
 	for (auto &res : dssp)
@@ -346,7 +344,7 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
 		if (res.type() != dssp::structure_type::Strand and res.type() != dssp::structure_type::Betabridge)
 			continue;
 
-		strands[{res.sheet(), res.strand()}].emplace_back(res);
+		strands[{ res.sheet(), res.strand() }].emplace_back(res);
 		sheetNrs.insert(res.sheet());
 	}
 
@@ -359,22 +357,18 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
 	{
 		auto sheetID = cif::cif_id_for_number(sheetNr - 1);
 
-		struct_sheet.emplace({
-			{ "id", sheetID },
+		struct_sheet.emplace({ { "id", sheetID },
 			{ "number_strands",
-				std::count_if(strands.begin(), strands.end(), [nr = sheetNr](std::tuple<std::tuple<int,int>, res_list> const &s)
-				{
+				std::count_if(strands.begin(), strands.end(), [nr = sheetNr](std::tuple<std::tuple<int, int>, res_list> const &s)
+					{
 					const auto &[strandID, strand] = s;
-					return strand.front().sheet() == nr;
-				})
-			}
-		});
+					return strand.front().sheet() == nr; }) } });
 
 		for (auto &&[strandTuple, strand] : strands)
 		{
 			if (strand.front().sheet() != sheetNr)
 				continue;
-			
+
 			std::string strandID = cif::cif_id_for_number(strand.front().strand() - 1);
 
 			std::sort(strand.begin(), strand.end(), [](dssp::residue_info const &a, dssp::residue_info const &b)
@@ -383,8 +377,7 @@ void writeSheets(cif::datablock &db, const dssp &dssp)
 			auto &beg = strand.front();
 			auto &end = strand.back();
 
-			struct_sheet_range.emplace({
-				{ "sheet_id", sheetID },
+			struct_sheet_range.emplace({ { "sheet_id", sheetID },
 				{ "id", strandID },
 				{ "beg_label_comp_id", beg.compound_id() },
 				{ "beg_label_asym_id", beg.asym_id() },
@@ -475,8 +468,7 @@ void writeLadders(cif::datablock &db, const dssp &dssp)
 		const auto &[beg1, beg2] = l.pairs.front();
 		const auto &[end1, end2] = l.pairs.back();
 
-		dssp_struct_ladder.emplace({
-			{ "id", cif::cif_id_for_number(l.ladder) },
+		dssp_struct_ladder.emplace({ { "id", cif::cif_id_for_number(l.ladder) },
 			{ "sheet_id", cif::cif_id_for_number(l.sheet) },
 			{ "range_id_1", cif::cif_id_for_number(beg1.strand() - 1) },
 			{ "range_id_2", cif::cif_id_for_number(beg2.strand() - 1) },
@@ -522,15 +514,18 @@ void writeStatistics(cif::datablock &db, const dssp &dssp)
 
 	auto &dssp_statistics = db["dssp_statistics"];
 
-	auto stats_i = dssp_statistics.emplace({ { "entry_id", db.name() },
+	std::optional<double> surface_accessibility;
+	if (stats.accessible_surface > 0)
+		surface_accessibility = stats.accessible_surface;
+
+	auto stats_i = dssp_statistics.emplace({ //
+		{ "entry_id", db.name() },
 		{ "nr_of_residues", stats.count.residues },
 		{ "nr_of_chains", stats.count.chains },
 		{ "nr_of_ss_bridges_total", stats.count.SS_bridges },
 		{ "nr_of_ss_bridges_intra_chain", stats.count.intra_chain_SS_bridges },
-		{ "nr_of_ss_bridges_inter_chain", stats.count.SS_bridges - stats.count.intra_chain_SS_bridges } });
-	
-	if (stats.accessible_surface > 0)
-		(*stats_i)["accessible_surface_of_protein"] = stats.accessible_surface;
+		{ "nr_of_ss_bridges_inter_chain", stats.count.SS_bridges - stats.count.intra_chain_SS_bridges },
+		{ "accessible_surface_of_protein", surface_accessibility } });
 
 	auto &dssp_struct_hbonds = db["dssp_statistics_hbond"];
 
@@ -612,9 +607,9 @@ void writeSummary(cif::datablock &db, const dssp &dssp)
 	// prime the category with the field labels we need, this is to ensure proper order in writing out the data.
 
 	for (auto label : { "entry_id", "label_comp_id", "label_asym_id", "label_seq_id", "secondary_structure",
-			"ss_bridge", "helix_3_10", "helix_alpha", "helix_pi", "helix_pp", "bend", "chirality", "sheet",
-			"strand", "ladder_1", "ladder_2", "accessibility", "TCO", "kappa", "alpha", "phi", "psi",
-			"x_ca", "y_ca", "z_ca"})
+			 "ss_bridge", "helix_3_10", "helix_alpha", "helix_pi", "helix_pp", "bend", "chirality", "sheet",
+			 "strand", "ladder_1", "ladder_2", "accessibility", "TCO", "kappa", "alpha", "phi", "psi",
+			 "x_ca", "y_ca", "z_ca" })
 		dssp_struct_summary.add_item(label);
 
 	for (auto res : dssp)
@@ -738,25 +733,32 @@ void writeSummary(cif::datablock &db, const dssp &dssp)
 			data.emplace_back("psi", *res.psi(), 1);
 		else
 			data.emplace_back("psi", ".");
-		
+
 		dssp_struct_summary.emplace(std::move(data));
 	}
 }
 
-void annotateDSSP(cif::datablock &db, const dssp &dssp, bool writeOther, bool writeExperimental)
+void annotateDSSP(cif::datablock &db, const dssp &dssp, bool writeOther, bool writeNewFormat)
 {
 	using namespace std::literals;
 
-	if (db.get_validator() != nullptr) {
-		auto &validator = const_cast<cif::validator &>(*db.get_validator());
-		if (validator.get_validator_for_category("dssp_struct_summary") == nullptr)
-		{
-			auto dssp_extension = cif::load_resource("dssp-extension.dic");
-			if (dssp_extension)
-				cif::extend_dictionary(validator, *dssp_extension);
-		}
+	auto &audit_conform = db["audit_conform"];
+
+	if (audit_conform.empty())
+	{
+		auto &cf = cif::validator_factory::instance();
+		cf.get("mmcif_pdbx.dic").fill_audit_conform(audit_conform);
 	}
 
+	audit_conform.erase(cif::key("dict_name") == "dssp-extension.dic");
+	audit_conform.emplace({ //
+		{ "dict_name", "dssp-extension.dic" },
+		{ "dict_version", "1.1.1" },
+		{ "dict_location", "https://pdb-redo.eu/dssp/dssp-extension.dic" } });
+
+	// Re-load the dictionary
+	db.load_dictionary();
+
 	if (dssp.empty())
 	{
 		if (cif::VERBOSE > 0)
@@ -764,7 +766,19 @@ void annotateDSSP(cif::datablock &db, const dssp &dssp, bool writeOther, bool wr
 	}
 	else
 	{
-		if (writeExperimental)
+		for (auto cat : std::initializer_list<const char *>{
+				 "dssp_struct_bridge_pairs",
+				 "dssp_struct_ladder",
+				 "dssp_statistics",
+				 "dssp_statistics_hbond",
+				 "dssp_statistics_histogram",
+				 "dssp_struct_summary"
+			 })
+		{
+			db.erase(std::remove_if(db.begin(), db.end(), [cat] (cif::category &c) { return c.name() == cat; }), db.end());
+		}
+
+		if (writeNewFormat)
 		{
 			writeBridgePairs(db, dssp);
 			writeSheets(db, dssp);
@@ -840,7 +854,7 @@ void annotateDSSP(cif::datablock &db, const dssp &dssp, bool writeOther, bool wr
 					foundTypes[id] = 1;
 				}
 
-				structConf.emplace({
+				structConf.emplace({ //
 					{ "conf_type_id", id },
 					{ "id", id + std::to_string(foundTypes[id]++) },
 					// { "pdbx_PDB_helix_id", vS(12, 14) },
@@ -858,8 +872,7 @@ void annotateDSSP(cif::datablock &db, const dssp &dssp, bool writeOther, bool wr
 					{ "beg_auth_seq_id", rb.auth_seq_id() },
 					{ "end_auth_comp_id", re.compound_id() },
 					{ "end_auth_asym_id", re.auth_asym_id() },
-					{ "end_auth_seq_id", re.auth_seq_id() }
-				});
+					{ "end_auth_seq_id", re.auth_seq_id() } });
 
 				st = t;
 			}
@@ -876,11 +889,10 @@ void annotateDSSP(cif::datablock &db, const dssp &dssp, bool writeOther, bool wr
 	}
 
 	auto &software = db["software"];
-	software.emplace({
+	software.emplace({ //
 		{ "pdbx_ordinal", software.get_unique_id("") },
 		{ "name", "dssp" },
 		{ "version", klibdsspVersionNumber },
 		{ "date", klibdsspRevisionDate },
-		{ "classification", "model annotation" }
-	});
+		{ "classification", "model annotation" } });
 }


=====================================
libdssp/src/dssp-io.hpp
=====================================
@@ -29,4 +29,4 @@
 #include "dssp.hpp"
 
 void writeDSSP(const dssp& dssp, std::ostream& os);
-void annotateDSSP(cif::datablock &db, const dssp& dssp, bool writeOther, bool writeExperimental);
+void annotateDSSP(cif::datablock &db, const dssp& dssp, bool writeOther, bool writeNewFormat);


=====================================
libdssp/src/dssp.cpp
=====================================
@@ -36,7 +36,7 @@
 #include <thread>
 
 #ifdef near
-#undef near
+# undef near
 #endif
 
 using residue = dssp::residue;
@@ -552,7 +552,7 @@ struct dssp::residue
 	HBond mHBondDonor[2] = {}, mHBondAcceptor[2] = {};
 	bridge_partner mBetaPartner[2] = {};
 	uint32_t mSheet = 0;
-	uint32_t mStrand = 0;	// Added to ease the writing of mmCIF's struct_sheet and friends
+	uint32_t mStrand = 0;                                                                                                                                // Added to ease the writing of mmCIF's struct_sheet and friends
 	helix_position_type mHelixFlags[4] = { helix_position_type::None, helix_position_type::None, helix_position_type::None, helix_position_type::None }; //
 	bool mBend = false;
 	chain_break_type mChainBreak = chain_break_type::None;
@@ -789,7 +789,7 @@ void CalculateHBondEnergies(std::vector<residue> &inResidues, std::vector<std::t
 		CalculateHBondEnergy(ri, rj);
 		if (j != i + 1)
 			CalculateHBondEnergy(rj, ri);
-		
+
 		if (progress)
 			progress->consumed(1);
 	}
@@ -1116,10 +1116,10 @@ void CalculateBetaSheets(std::vector<residue> &inResidues, statistics &stats, st
 		{
 			if (res.mSheet != iSheet)
 				continue;
-			
+
 			if (lastNr + 1 < res.mNumber)
 				++strand;
-			
+
 			res.mStrand = strand;
 			lastNr = res.mNumber;
 		}
@@ -1425,17 +1425,16 @@ DSSP_impl::DSSP_impl(const cif::datablock &db, int model_nr, int min_poly_prolin
 	auto &pdbx_poly_seq_scheme = mDB["pdbx_poly_seq_scheme"];
 	auto &atom_site = mDB["atom_site"];
 
-	using key_type = std::tuple<std::string,int>;
+	using key_type = std::tuple<std::string, int>;
 	using index_type = std::map<key_type, size_t>;
 
 	index_type index;
 
 	mResidues.reserve(pdbx_poly_seq_scheme.size());
 
-	for (const auto &[asym_id, seq_id, pdb_strand_id, pdb_seq_num, pdb_ins_code]
-		: pdbx_poly_seq_scheme.rows<std::string,int, std::string, int, std::string>("asym_id", "seq_id", "pdb_strand_id", "pdb_seq_num", "pdb_ins_code"))
+	for (const auto &[asym_id, seq_id, pdb_strand_id, pdb_seq_num, pdb_ins_code] : pdbx_poly_seq_scheme.rows<std::string, int, std::string, int, std::string>("asym_id", "seq_id", "pdb_strand_id", "pdb_seq_num", "pdb_ins_code"))
 	{
-		index[{asym_id, seq_id}] = mResidues.size();
+		index[{ asym_id, seq_id }] = mResidues.size();
 		mResidues.emplace_back(model_nr, pdb_strand_id, pdb_seq_num, pdb_ins_code);
 	}
 
@@ -1445,17 +1444,19 @@ DSSP_impl::DSSP_impl(const cif::datablock &db, int model_nr, int min_poly_prolin
 		int seq_id;
 
 		cif::tie(asym_id, seq_id) = atom.get("label_asym_id", "label_seq_id");
-		auto i = index.find({asym_id, seq_id});
+		auto i = index.find({ asym_id, seq_id });
 		if (i == index.end())
 			continue;
-		
+
 		mResidues[i->second].addAtom(atom);
 	}
 
 	for (auto &residue : mResidues)
 		residue.finish();
-	
-	mResidues.erase(std::remove_if(mResidues.begin(), mResidues.end(), [](const dssp::residue &r) { return not r.mComplete; }), mResidues.end());
+
+	mResidues.erase(std::remove_if(mResidues.begin(), mResidues.end(), [](const dssp::residue &r)
+						{ return not r.mComplete; }),
+		mResidues.end());
 	mStats.count.chains = 1;
 
 	chain_break_type brk = chain_break_type::NewChain;
@@ -1595,7 +1596,7 @@ void DSSP_impl::calculateSecondaryStructure()
 		progress.reset(new cif::progress_bar((mResidues.size() * (mResidues.size() - 1)) / 2, "calculate distances"));
 
 	// Calculate the HBond energies
-	std::vector<std::tuple<uint32_t,uint32_t>> near;
+	std::vector<std::tuple<uint32_t, uint32_t>> near;
 
 	for (uint32_t i = 0; i + 1 < mResidues.size(); ++i)
 	{
@@ -2183,6 +2184,11 @@ std::tuple<dssp::residue_info, double> dssp::residue_info::donor(int i) const
 	return { residue_info(d.res), d.energy };
 }
 
+dssp::residue_info dssp::residue_info::next() const
+{
+	return residue_info(m_impl ? m_impl->mNext : nullptr);
+}
+
 // --------------------------------------------------------------------
 
 dssp::iterator::iterator(residue *res)
@@ -2248,11 +2254,12 @@ dssp::iterator dssp::end() const
 dssp::residue_info dssp::operator[](const key_type &key) const
 {
 	auto i = std::find_if(begin(), end(),
-		[key](const residue_info &res) { return res.asym_id() == std::get<0>(key) and res.seq_id() == std::get<1>(key); });
-	
+		[key](const residue_info &res)
+		{ return res.asym_id() == std::get<0>(key) and res.seq_id() == std::get<1>(key); });
+
 	if (i == end())
 		throw std::out_of_range("Could not find residue with supplied key");
-	
+
 	return *i;
 }
 
@@ -2280,7 +2287,7 @@ std::string dssp::get_pdb_header_line(pdb_record_type pdb_record) const
 
 // --------------------------------------------------------------------
 
-void dssp::write_legacy_output(std::ostream& os) const
+void dssp::write_legacy_output(std::ostream &os) const
 {
 	writeDSSP(*this, os);
 }
@@ -2289,5 +2296,3 @@ void dssp::annotate(cif::datablock &db, bool writeOther, bool writeDSSPCategorie
 {
 	annotateDSSP(db, *this, writeOther, writeDSSPCategories);
 }
-
-


=====================================
python-module/CMakeLists.txt
=====================================
@@ -0,0 +1,79 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2025 NKI/AVL, Netherlands Cancer Institute
+#
+# 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.
+
+include(CPM)
+
+if(CMAKE_VERSION GREATER_EQUAL 3.30)
+	cmake_policy(SET CMP0167 NEW)
+endif()
+
+find_package(Python REQUIRED COMPONENTS Interpreter Development)
+find_package(Boost 1.83 QUIET COMPONENTS python)
+
+if(NOT Boost_FOUND)
+	# boost is a huge project and directly downloading the 'alternate release'
+	# from github is much faster than recursively cloning the repo.
+	CPMAddPackage(
+		NAME Boost
+		VERSION 1.84.0
+		URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz
+		URL_HASH SHA256=2e64e5d79a738d0fa6fb546c6e5c2bd28f88d268a2a080546f74e5ff98f29d0e
+		OPTIONS
+		"BOOST_ENABLE_CMAKE ON"
+		"BOOST_INCLUDE_LIBRARIES python"
+		"BOOST_ENABLE_PYTHON ON"
+		"CMAKE_POSITION_INDEPENDENT_CODE ON"
+	)
+endif()
+
+# ---------
+add_library(mkdssp_module SHARED dssp-python-plugin.cpp)
+
+target_compile_features(mkdssp_module PUBLIC cxx_std_20)
+
+target_include_directories(mkdssp_module PRIVATE ${Python_INCLUDE_DIRS})
+target_link_libraries(mkdssp_module dssp::dssp Boost::python ${Python_LIBRARIES})
+
+set_target_properties(mkdssp_module
+	PROPERTIES
+	PREFIX ""
+	SUFFIX ".so"
+	OUTPUT_NAME mkdssp
+	LINKER_LANGUAGE CXX
+	LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
+)
+
+if(WIN32)
+	# python modules use this on Windows
+	set_target_properties(
+		mkdssp_module
+		PROPERTIES
+		SUFFIX ".pyd"
+		RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+	)
+
+	install(TARGETS mkdssp_module RUNTIME DESTINATION "${Python_SITELIB}")
+else()
+	install(TARGETS mkdssp_module LIBRARY DESTINATION "${Python_SITELIB}")
+endif()
\ No newline at end of file


=====================================
python-module/dssp-python-plugin.cpp
=====================================
@@ -0,0 +1,332 @@
+#include <boost/python.hpp>
+#include <Python.h>
+
+#include <dssp.hpp>
+
+struct statistics_wrapper
+{
+	int get_residues() { return m_stats.count.residues; }
+	int get_chains() { return m_stats.count.chains; }
+	int get_SS_bridges() { return m_stats.count.SS_bridges; }
+	int get_intra_chain_SS_bridges() { return m_stats.count.intra_chain_SS_bridges; }
+	int get_H_bonds() { return m_stats.count.H_bonds; }
+	int get_H_bonds_in_antiparallel_bridges() { return m_stats.count.H_bonds_in_antiparallel_bridges; }
+	int get_H_bonds_in_parallel_bridges() { return m_stats.count.H_bonds_in_parallel_bridges; }
+
+	dssp::statistics m_stats;
+};
+
+enum class ladder_direction_type
+{
+	parallel,
+	antiparallel
+};
+
+struct residue_info_wrapper
+{
+};
+
+class dssp_wrapper
+{
+  public:
+	dssp_wrapper(std::string data, int model_nr = 1, int min_poly_proline_stretch_length = 3, bool calculateSurfaceAccessibility = false)
+	{
+		struct membuf : public std::streambuf
+		{
+			membuf(char *text, size_t length)
+			{
+				this->setg(text, text, text + length);
+			}
+		} buffer(const_cast<char *>(data.data()), data.length());
+
+		std::istream is(&buffer);
+
+		auto f = cif::pdb::read(is);
+		m_dssp.reset(new dssp(f.front(), model_nr, min_poly_proline_stretch_length, calculateSurfaceAccessibility));
+	}
+
+	dssp_wrapper(const dssp_wrapper &) = default;
+	dssp_wrapper &operator=(const dssp_wrapper &) = default;
+
+	statistics_wrapper get_statistics()
+	{
+		statistics_wrapper result{ .m_stats = m_dssp->get_statistics() };
+		return result;
+	}
+
+	struct residue_info_handle
+	{
+		residue_info_handle(dssp::residue_info info)
+			: m_info(info)
+		{
+		}
+
+		operator dssp::residue_info &() { return m_info; }
+
+		dssp::residue_info m_info;
+	};
+
+	class iterator
+	{
+	  public:
+		using iterator_category = std::forward_iterator_tag;
+		using value_type = dssp::residue_info;
+		using difference_type = std::ptrdiff_t;
+		using pointer = value_type *;
+		using reference = residue_info_handle;
+
+		iterator(dssp::residue_info info)
+			: m_current(info)
+		{
+		}
+
+		iterator(const iterator &i) = default;
+		iterator &operator=(const iterator &i) = default;
+
+		reference operator*() { return residue_info_handle(m_current); }
+		pointer operator->() { return &m_current; }
+
+		iterator &operator++()
+		{
+			m_current = m_current.next();
+			return *this;
+		}
+
+		iterator operator++(int)
+		{
+			auto tmp(*this);
+			this->operator++();
+			return tmp;
+		}
+
+		bool operator==(const iterator &rhs) const
+		{
+			return m_current == rhs.m_current;
+		}
+
+	  private:
+		dssp::residue_info m_current;
+	};
+
+	auto begin() { return iterator(*m_dssp->begin()); }
+	auto end() { return iterator({}); }
+
+	auto get(std::string asym_id, int nr)
+	{
+		return m_dssp->operator[]({ asym_id, nr });
+	}
+
+  private:
+	std::shared_ptr<dssp> m_dssp;
+};
+
+// shamelessly copied from a stack overflow comment
+// https://stackoverflow.com/questions/36485840/wrap-boostoptional-using-boostpython
+
+// Custom exceptions
+struct AttributeError : std::exception
+{
+	const char *what() const throw() { return "AttributeError exception"; }
+};
+
+struct TypeError : std::exception
+{
+	const char *what() const throw() { return "TypeError exception"; }
+};
+
+// Set python exceptions
+void translate(const std::exception &e)
+{
+	if (dynamic_cast<const AttributeError *>(&e))
+		PyErr_SetString(PyExc_AttributeError, e.what());
+	if (dynamic_cast<const TypeError *>(&e))
+		PyErr_SetString(PyExc_TypeError, e.what());
+}
+
+struct to_python_optional
+{
+	static PyObject *convert(const std::optional<float> &obj)
+	{
+		if (obj)
+			return boost::python::incref(boost::python::object(*obj).ptr());
+		else
+			return boost::python::incref(boost::python::object().ptr());
+	}
+};
+
+struct to_python_list_of_floats
+{
+	static PyObject *convert(const std::vector<float> &v)
+	{
+		boost::python::list list;
+		for (auto value : v)
+			list.append(value);
+		return boost::python::incref(boost::python::object(list).ptr());
+	}
+};
+
+struct to_python_point
+{
+	static PyObject *convert(const std::tuple<float, float, float> &v)
+	{
+		boost::python::dict p;
+		p["x"] = std::get<0>(v);
+		p["y"] = std::get<1>(v);
+		p["z"] = std::get<2>(v);
+		return boost::python::incref(boost::python::object(p).ptr());
+	}
+};
+
+struct to_python_partner
+{
+	static PyObject *convert(const std::tuple<dssp::residue_info, double> &v)
+	{
+		boost::python::type_info iv = boost::python::type_id<dssp::residue_info>();
+		const boost::python::converter::registration* cv = boost::python::converter::registry::query(iv);
+		assert(cv != nullptr);
+		if (cv == nullptr)
+			throw std::runtime_error("Missing registration");
+
+		if (auto &[ri, e] = v; ri)
+		{
+			auto c = cv->to_python(&ri);
+			return boost::python::incref(boost::python::make_tuple(boost::python::handle<>(c), e).ptr());
+		}
+		else
+			return boost::python::incref(boost::python::make_tuple(boost::python::object(), 0).ptr());
+	}
+};
+
+struct to_python_bridge_partner
+{
+	static PyObject *convert(const std::tuple<dssp::residue_info, int, bool> &v)
+	{
+		if (auto &[ri, nr, parallel] = v; ri)
+		{
+			boost::python::type_info iv = boost::python::type_id<dssp::residue_info>();
+			const boost::python::converter::registration* cv = boost::python::converter::registry::query(iv);
+			assert(cv != nullptr);
+	
+			boost::python::type_info dv = boost::python::type_id<ladder_direction_type>();
+			const boost::python::converter::registration* ev = boost::python::converter::registry::query(dv);
+			assert(ev != nullptr);
+
+			auto c = cv->to_python(&ri);
+
+			ladder_direction_type direction = parallel ? ladder_direction_type::parallel : ladder_direction_type::antiparallel;
+			auto e = ev->to_python(&direction);
+
+			return boost::python::incref(boost::python::make_tuple(
+				boost::python::handle<>(c), nr, boost::python::handle<>(e)).ptr());
+		}
+		else
+			return boost::python::incref(boost::python::make_tuple(boost::python::object(), 0, boost::python::object()).ptr());
+	}
+};
+
+bool test_bond_between_residues(PyObject *a, PyObject *b)
+{
+	const auto &a_ri = boost::python::extract<dssp::residue_info&>(a);
+	const auto &b_ri = boost::python::extract<dssp::residue_info&>(b);
+
+	return test_bond(a_ri, b_ri);
+}
+
+BOOST_PYTHON_MODULE(mkdssp)
+{
+	using namespace boost::python;
+
+	register_exception_translator<AttributeError>(&translate);
+	register_exception_translator<TypeError>(&translate);
+
+	to_python_converter<std::optional<float>, to_python_optional>();
+	to_python_converter<std::vector<float>, to_python_list_of_floats>();
+	to_python_converter<std::tuple<float, float, float>, to_python_point>();
+	to_python_converter<std::tuple<dssp::residue_info, double>, to_python_partner>();
+	to_python_converter<std::tuple<dssp::residue_info, int, bool>, to_python_bridge_partner>();
+
+	enum_<dssp::structure_type>("structure_type")
+		.value("Loop", dssp::structure_type::Loop)
+		.value("Alphahelix", dssp::structure_type::Alphahelix)
+		.value("Betabridge", dssp::structure_type::Betabridge)
+		.value("Strand", dssp::structure_type::Strand)
+		.value("Helix_3", dssp::structure_type::Helix_3)
+		.value("Helix_5", dssp::structure_type::Helix_5)
+		.value("Helix_PPII", dssp::structure_type::Helix_PPII)
+		.value("Turn", dssp::structure_type::Turn)
+		.value("Bend", dssp::structure_type::Bend);
+
+	enum_<dssp::helix_type>("helix_type")
+		.value("_3_10", dssp::helix_type::_3_10)
+		.value("alpha", dssp::helix_type::alpha)
+		.value("pi", dssp::helix_type::pi)
+		.value("pp", dssp::helix_type::pp);
+
+	enum_<dssp::helix_position_type>("helix_position_type")
+		.value("NoHelix", dssp::helix_position_type::None)
+		.value("Start", dssp::helix_position_type::Start)
+		.value("End", dssp::helix_position_type::End)
+		.value("StartAndEnd", dssp::helix_position_type::StartAndEnd)
+		.value("Middle", dssp::helix_position_type::Middle);
+
+	enum_<ladder_direction_type>("ladder_direction_type")
+		.value("parallel", ladder_direction_type::parallel)
+		.value("anti_parallel", ladder_direction_type::antiparallel);
+
+	enum_<dssp::chain_break_type>("chain_break_type")
+		.value("NoGap", dssp::chain_break_type::None)
+		.value("NewChain", dssp::chain_break_type::NewChain)
+		.value("Gap", dssp::chain_break_type::Gap);
+
+	class_<statistics_wrapper>("statistic_counts")
+		.add_property("residues", &statistics_wrapper::get_residues)
+		.add_property("chains", &statistics_wrapper::get_chains)
+		.add_property("SS_bridges", &statistics_wrapper::get_SS_bridges)
+		.add_property("intra_chain_SS_bridges", &statistics_wrapper::get_intra_chain_SS_bridges)
+		.add_property("H_bonds", &statistics_wrapper::get_H_bonds)
+		.add_property("H_bonds_in_antiparallel_bridges", &statistics_wrapper::get_H_bonds_in_antiparallel_bridges)
+		.add_property("H_bonds_in_parallel_bridges", &statistics_wrapper::get_H_bonds_in_parallel_bridges);
+
+	class_<dssp::residue_info>("residue_info")
+		.add_property("asym_id", &dssp::residue_info::asym_id)
+		.add_property("seq_id", &dssp::residue_info::seq_id)
+		.add_property("alt_id", &dssp::residue_info::alt_id)
+		.add_property("compound_id", &dssp::residue_info::compound_id)
+		.add_property("compound_letter", &dssp::residue_info::compound_letter)
+		.add_property("auth_asym_id", &dssp::residue_info::auth_asym_id)
+		.add_property("auth_seq_id", &dssp::residue_info::auth_seq_id)
+		.add_property("pdb_strand_id", &dssp::residue_info::pdb_strand_id)
+		.add_property("pdb_seq_num", &dssp::residue_info::pdb_seq_num)
+		.add_property("pdb_ins_code", &dssp::residue_info::pdb_ins_code)
+		.add_property("alpha", &dssp::residue_info::alpha)
+		.add_property("kappa", &dssp::residue_info::kappa)
+		.add_property("phi", &dssp::residue_info::phi)
+		.add_property("psi", &dssp::residue_info::psi)
+		.add_property("tco", &dssp::residue_info::tco)
+		.add_property("omega", &dssp::residue_info::omega)
+		.add_property("is_pre_pro", &dssp::residue_info::is_pre_pro)
+		.add_property("is_cis", &dssp::residue_info::is_cis)
+		.add_property("chiral_volume", &dssp::residue_info::chiral_volume)
+		.add_property("chi", &dssp::residue_info::chis)
+		.add_property("ca_location", &dssp::residue_info::ca_location)
+		.add_property("chain_break", &dssp::residue_info::chain_break)
+		.add_property("nr", &dssp::residue_info::nr)
+		.add_property("type", &dssp::residue_info::type)
+		.add_property("ssBridgeNr", &dssp::residue_info::ssBridgeNr)
+		.def("helix", &dssp::residue_info::helix, args("helix_type"), "Return the position of this residue in a helix with type helix_type")
+		.add_property("is_alpha_helix_end_before_start", &dssp::residue_info::is_alpha_helix_end_before_start)
+		.add_property("bend", &dssp::residue_info::bend)
+		.add_property("accessibility", &dssp::residue_info::accessibility)
+		.def("bridge_partner", &dssp::residue_info::bridge_partner, args("indexnr"), "Return a tuple containing the residue, number and direction for the bridge partner with index indexnr")
+		.add_property("sheet", &dssp::residue_info::sheet)
+		.add_property("strand", &dssp::residue_info::strand)
+		.def("acceptor", &dssp::residue_info::acceptor, args("indexnr"), "Return a tuple containing the residue and bond energy for the acceptor with index indexnr")
+		.def("donor", &dssp::residue_info::donor, args("indexnr"), "Return a tuple containing the residue and bond energy for the donor with index indexnr");
+
+	class_<dssp_wrapper, boost::noncopyable>("dssp", init<std::string, optional<int, int, bool>>())
+		.add_property("statistics", &dssp_wrapper::get_statistics)
+		.def("__iter__", iterator<dssp_wrapper>())
+		.def("get", &dssp_wrapper::get, args("asym_id", "seq_id"), "Return the residue info object for the residue with specified asym_id and seq_id");
+
+	def("TestBond", test_bond_between_residues, args("a", "b"), "Returns true if residues a and b are bonded according to DSSP");
+}
\ No newline at end of file


=====================================
python-module/test-mkdssp.py
=====================================
@@ -0,0 +1,83 @@
+from mkdssp import dssp, helix_type, TestBond
+import os
+import gzip
+
+file_path = os.path.join("..", "test", "1cbs.cif.gz")
+
+with gzip.open(file_path, "rt") as f:
+	file_content = f.read()
+ 
+dssp = dssp(file_content)
+ 
+print("residues: ", dssp.statistics.residues)
+print("chains: ", dssp.statistics.chains)
+print("SS_bridges: ", dssp.statistics.SS_bridges)
+print("intra_chain_SS_bridges: ", dssp.statistics.intra_chain_SS_bridges)
+print("H_bonds: ", dssp.statistics.H_bonds)
+print("H_bonds_in_antiparallel_bridges: ", dssp.statistics.H_bonds_in_antiparallel_bridges)
+print("H_bonds_in_parallel_bridges: ", dssp.statistics.H_bonds_in_parallel_bridges)
+
+count = 0
+for res in dssp:
+	count += 1
+	print(res.asym_id, res.seq_id, res.compound_id)
+	print("alt_id", res.alt_id)
+	print("compound_letter", res.compound_letter)
+	print("auth_asym_id", res.auth_asym_id)
+	print("auth_seq_id", res.auth_seq_id)
+	print("pdb_strand_id", res.pdb_strand_id)
+	print("pdb_seq_num", res.pdb_seq_num)
+	print("pdb_ins_code", res.pdb_ins_code)
+	print("alpha", res.alpha)
+	print("kappa", res.kappa)
+	print("phi", res.phi)
+	print("psi", res.psi)
+	print("tco", res.tco)
+	print("omega", res.omega)
+	print("is_pre_pro", res.is_pre_pro)
+	print("is_cis", res.is_cis)
+	print("chiral_volume", res.chiral_volume)
+	print("chi", res.chi)
+	print("ca_location", res.ca_location)
+	print("chain_break", res.chain_break)
+	print("nr", res.nr)
+	print("type", res.type)
+	print("ssBridgeNr", res.ssBridgeNr)
+	print("helix(_3_10)", res.helix(helix_type._3_10))
+	print("helix(alpha)", res.helix(helix_type.alpha))
+	print("helix(pi)", res.helix(helix_type.pi))
+	print("helix(pp)", res.helix(helix_type.pp))
+	print("is_alpha_helix_end_before_start", res.is_alpha_helix_end_before_start)
+	print("bend", res.bend)
+	print("sheet", res.sheet)
+	print("strand", res.strand)
+
+	for i in range(0, 1):
+		(ri, nr, dir) = res.bridge_partner(i)
+		if ri != None:
+			print("bridge partner ", i, ri.asym_id, ri.seq_id, ri.compound_id, nr, dir)
+
+	for i in range(0, 1):
+		(ri, e) = res.acceptor(i)
+		if ri != None:
+			print("acceptor ", i, ri.asym_id, ri.seq_id, ri.compound_id, e)
+			print("test bond: ", TestBond(res, ri))
+   	
+	for i in range(0, 1):
+		(ri, e) = res.donor(i)
+		if ri != None:
+			print("donor ", i, ri.asym_id, ri.seq_id, ri.compound_id, e)
+			print("test bond: ", TestBond(res, ri))
+
+	print("accessibility", res.accessibility)
+	break
+
+
+print("count: ", count)
+
+a = dssp.get('A', 137)
+b = dssp.get('A', 6)
+
+print ("a & b", a, b)
+
+assert(TestBond(a, b))


=====================================
src/mkdssp.cpp
=====================================
@@ -25,7 +25,7 @@
  */
 
 #if __has_include("config.hpp")
-#include "config.hpp"
+# include "config.hpp"
 #endif
 
 #include <exception>
@@ -33,8 +33,8 @@
 #include <fstream>
 #include <iostream>
 
-#include <mcfp/mcfp.hpp>
 #include <cif++.hpp>
+#include <mcfp/mcfp.hpp>
 
 #include "dssp.hpp"
 #include "revision.hpp"
@@ -114,16 +114,42 @@ int d_main(int argc, const char *argv[])
 
 	// private mmcif_pdbx dictionary?
 	if (config.has("mmcif-dictionary"))
-		cif::add_file_resource("mmcif_pdbx.dic", config.get<std::string>("mmcif-dictionary"));
+	{
+		fs::path mmcif_dict = config.get<std::string>("mmcif-dictionary");
 
-	cif::gzio::ifstream in(config.operands().front());
-	if (not in.is_open())
+		cif::add_file_resource("mmcif_pdbx.dic", mmcif_dict);
+
+		// Try to be smart, maybe dssp-extension.dic is at that location as well?
+		auto dir = fs::canonical(mmcif_dict.parent_path());
+		if (auto dssp_dict = cif::load_resource("dssp-extension.dic"); dssp_dict == nullptr and fs::exists(dir / "dssp-extension.dic"))
+			cif::add_data_directory(dir);
+	}
+
+	cif::file f;
+
+	try
 	{
-		std::cerr << "Could not open file" << std::endl;
-		exit(1);
+		auto &cf = cif::validator_factory::instance();
+
+		cif::gzio::ifstream in(config.operands().front());
+		if (not in.is_open())
+		{
+			std::cerr << "Could not open file" << std::endl;
+			exit(1);
+		}
+
+		f.load(in);
+		f.front().set_validator(&cf.get("mmcif_pdbx.dic"));
+
+		if (f.empty() or f.front().get("pdbx_poly_seq_scheme") == nullptr)
+			throw std::runtime_error("Missing pdbx_poly_seq_scheme, will attempt to recover...");
 	}
+	catch (const std::exception &e)
+	{
+		std::cerr << e.what() << '\n';
 
-	cif::file f = cif::pdb::read(in);
+		f = cif::pdb::read(config.operands().front());
+	}
 
 	// --------------------------------------------------------------------
 
@@ -160,7 +186,7 @@ int d_main(int argc, const char *argv[])
 	{
 		// See if the data will fit at all
 		auto &db = f.front();
-		for (const auto &[chain_id, seq_nr] : db["pdbx_poly_seq_scheme"].rows<std::string,int>("pdb_strand_id", "pdb_seq_num"))
+		for (const auto &[chain_id, seq_nr] : db["pdbx_poly_seq_scheme"].rows<std::string, int>("pdb_strand_id", "pdb_seq_num"))
 		{
 			if (chain_id.length() > 1 or seq_nr > 99999)
 			{


=====================================
test/1cbs-dssp.cif
=====================================
The diff for this file was not included because it is too large.

=====================================
test/CMakeLists.txt
=====================================
@@ -1,28 +1,11 @@
-if(NOT(Catch2_FOUND OR TARGET Catch2))
-	find_package(Catch2 QUIET)
-
-	if(NOT Catch2_FOUND)
-		include(FetchContent)
-
-		FetchContent_Declare(
-			Catch2
-			GIT_REPOSITORY https://github.com/catchorg/Catch2.git
-			GIT_TAG v2.13.9)
-
-		FetchContent_MakeAvailable(Catch2)
-
-		set(Catch2_VERSION "2.13.9")
-	endif()
-endif()
+CPMFindPackage(
+	NAME Catch2 3
+	GIT_REPOSITORY https://github.com/catchorg/Catch2.git
+	GIT_TAG v3.8.0
+	EXCLUDE_FROM_ALL YES)
 
 add_executable(unit-test-dssp ${CMAKE_CURRENT_SOURCE_DIR}/unit-test-dssp.cpp ${PROJECT_SOURCE_DIR}/libdssp/src/dssp-io.cpp)
 
-if(USE_RSRC)
-	mrc_target_resources(unit-test-dssp
-		${CIFPP_SHARE_DIR}/mmcif_pdbx.dic ${CIFPP_SHARE_DIR}/mmcif_ddl.dic
-		${CMAKE_CURRENT_SOURCE_DIR}/../libdssp/mmcif_pdbx/dssp-extension.dic)
-endif()
-
 target_include_directories(unit-test-dssp PRIVATE
 	${CMAKE_CURRENT_SOURCE_DIR}/src
 	${CMAKE_CURRENT_SOURCE_DIR}/include
@@ -35,12 +18,15 @@ if(MSVC)
 	target_compile_options(unit-test-dssp PRIVATE /EHsc)
 endif()
 
-if("${Catch2_VERSION}" VERSION_GREATER_EQUAL 3.0.0)
-	target_compile_definitions(unit-test-dssp PUBLIC CATCH22=0)
-else()
-	target_compile_definitions(unit-test-dssp PUBLIC CATCH22=1)
-endif()
-
 add_test(NAME unit-test-dssp COMMAND $<TARGET_FILE:unit-test-dssp>
 	--data-dir ${CMAKE_CURRENT_SOURCE_DIR}
-	--rsrc-dir ${CMAKE_CURRENT_BINARY_DIR}/_deps/cifpp-src/rsrc)
+	--rsrc-dir ${CMAKE_CURRENT_SOURCE_DIR}/../libdssp/mmcif_pdbx/)
+
+if(BUILD_PYTHON_MODULE)
+	find_package(Python REQUIRED Interpreter)
+
+	add_test(NAME python_module COMMAND ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/test-python.py")
+	set_tests_properties(python_module PROPERTIES
+		ENVIRONMENT "PYTHONPATH=$<TARGET_FILE_DIR:mkdssp_module>"
+		WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
+endif()
\ No newline at end of file


=====================================
test/pdb1cbs.ent.gz
=====================================
Binary files /dev/null and b/test/pdb1cbs.ent.gz differ


=====================================
test/test-python.py
=====================================
@@ -0,0 +1,68 @@
+from mkdssp import dssp, TestBond, helix_type, chain_break_type, helix_type, helix_position_type, structure_type
+import gzip
+import unittest
+
+class TestDssp(unittest.TestCase):
+    def setUp(self):
+        with gzip.open("1cbs.cif.gz", "rt") as f:
+            file_content = f.read()
+
+        self.dssp = dssp(file_content)
+    
+    def test_dssp(self):
+        stats = self.dssp.statistics
+        self.assertEqual(stats.residues, 137)
+        
+    def test_count(self):
+        count = 0
+        for r in self.dssp:
+            count += 1
+        self.assertEqual(count, 137)
+
+    def test_bond(self):
+        a = self.dssp.get('A', 137)
+        b = self.dssp.get('A', 6)
+        self.assertTrue(TestBond(a, b))
+    
+    def test_one_residue(self):
+        r = self.dssp.get("A", 15)
+
+        self.assertEqual(r.asym_id, "A")
+        self.assertEqual(r.seq_id, 15)
+        
+        self.assertEqual(r.compound_letter, "F")
+        self.assertEqual(r.auth_asym_id, "A")
+        self.assertEqual(r.auth_seq_id, 15)
+        self.assertEqual(r.pdb_strand_id, "A")
+        self.assertEqual(r.pdb_seq_num, 15)
+        self.assertEqual(r.pdb_ins_code, '')
+        self.assertAlmostEqual(r.alpha, 44.76425552368164)
+        self.assertAlmostEqual(r.kappa, 73.85977935791016)
+        self.assertAlmostEqual(r.phi, -66.86814880371094)
+        self.assertAlmostEqual(r.psi, -48.56082534790039)
+        self.assertAlmostEqual(r.tco, 0.9395495057106018)
+        self.assertAlmostEqual(r.omega, 179.16152954101562)
+        self.assertEqual(r.is_pre_pro, False)
+        self.assertEqual(r.is_cis, False)
+        self.assertEqual(r.chiral_volume, 0.0)
+        # self.assertAlmostEqual(r.chi, [-170.86489868164062, 59.921932220458984])
+        # self.assertAlmostEqual(r.ca_location, {'x': 22.385000228881836, 'y': 17.197999954223633, 'z': 17.680999755859375})
+        self.assertEqual(r.chain_break, chain_break_type.NoGap)
+        self.assertEqual(r.nr, 15)
+        self.assertEqual(r.type, structure_type.Alphahelix)
+        self.assertEqual(r.ssBridgeNr, 0)
+        self.assertEqual(r.helix(helix_type._3_10), helix_position_type.NoHelix)
+        self.assertEqual(r.helix(helix_type.alpha), helix_position_type.Start)
+        self.assertEqual(r.helix(helix_type.pi), helix_position_type.NoHelix)
+        self.assertEqual(r.helix(helix_type.pp), helix_position_type.NoHelix)
+        self.assertEqual(r.is_alpha_helix_end_before_start, False)
+        self.assertEqual(r.bend, True)
+        self.assertEqual(r.sheet, 0)
+        self.assertEqual(r.strand, 0)
+
+        (acceptor, energy) = r.acceptor(0)
+        self.assertEqual(acceptor.seq_id, 17)
+        self.assertAlmostEqual(energy, -0.2)
+        
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file


=====================================
test/unit-test-dssp.cpp
=====================================
@@ -28,11 +28,7 @@
 
 #define CATCH_CONFIG_RUNNER
 
-#if CATCH22
-# include <catch2/catch.hpp>
-#else
-# include <catch2/catch_all.hpp>
-#endif
+#include <catch2/catch_all.hpp>
 
 #include "../libdssp/src/dssp-io.hpp"
 #include "../src/revision.hpp"
@@ -67,12 +63,7 @@ int main(int argc, char *argv[])
 	Catch::Session session; // There must be exactly one instance
 
 	// Build a new parser on top of Catch2's
-#if CATCH22
-	using namespace Catch::clara;
-#else
-	// Build a new parser on top of Catch2's
 	using namespace Catch::Clara;
-#endif
 
 	std::filesystem::path rsrc_dir;
 
@@ -103,7 +94,7 @@ TEST_CASE("ut_dssp")
 {
 	using namespace std::literals;
 
-	cif::file f(gTestDir / "1cbs.cif.gz");
+	auto f = cif::pdb::read(gTestDir / "1cbs.cif.gz");
 	REQUIRE(f.is_valid());
 
 	dssp dssp(f.front(), 1, 3, true);
@@ -119,7 +110,7 @@ TEST_CASE("ut_dssp")
 	std::string line_t, line_r;
 	CHECK((std::getline(test, line_t) and std::getline(reference, line_r)));
 
-	char kHeaderLineStart[] = "==== Secondary Structure Definition by the program DSSP, NKI version 4.4.5                         ====";
+	char kHeaderLineStart[] = "==== Secondary Structure Definition by the program DSSP, NKI version 4.5.4                         ====";
 	memcpy(kHeaderLineStart + 69, kVersionNumber, strlen(kVersionNumber));
 
 	CHECK(line_t.compare(0, std::strlen(kHeaderLineStart), kHeaderLineStart) == 0);
@@ -135,9 +126,14 @@ TEST_CASE("ut_dssp")
 			break;
 
 		if (line_t != line_r)
+		{
+			if (cif::starts_with(line_t, "REFERENCE ") and cif::starts_with(line_r, "REFERENCE "))
+				continue;
+
 			std::cerr << line_nr << std::endl
 					  << line_t << std::endl
 					  << line_r << std::endl;
+		}
 
 		if (line_t != line_r)
 		{
@@ -155,14 +151,14 @@ TEST_CASE("ut_mmcif_2")
 	using namespace std::literals;
 	using namespace cif::literals;
 
-	cif::file f(gTestDir / "1cbs.cif.gz");
+	auto f = cif::pdb::read(gTestDir / "1cbs.cif.gz");
 	REQUIRE(f.is_valid());
 
 	dssp dssp(f.front(), 1, 3, true);
 
 	std::stringstream test;
 
-	dssp.annotate(f.front(), true, false);
+	dssp.annotate(f.front(), true, true);
 
 	cif::file rf(gTestDir / "1cbs-dssp.cif");
 
@@ -187,7 +183,7 @@ TEST_CASE("ut_mmcif_2")
 
 TEST_CASE("dssp_1")
 {
-	cif::file f(gTestDir / "1cbs.cif.gz");
+	auto f = cif::pdb::read(gTestDir / "1cbs.cif.gz");
 
 	REQUIRE(f.is_valid());
 
@@ -225,7 +221,7 @@ TEST_CASE("dssp_1")
 
 TEST_CASE("dssp_2")
 {
-	cif::file f(gTestDir / "1cbs.cif.gz");
+	auto f = cif::pdb::read(gTestDir / "1cbs.cif.gz");
 
 	REQUIRE(f.is_valid());
 
@@ -262,7 +258,7 @@ TEST_CASE("dssp_2")
 
 TEST_CASE("dssp_3")
 {
-	cif::file f(gTestDir / "1cbs.cif.gz");
+	auto f = cif::pdb::read(gTestDir / "1cbs.cif.gz");
 
 	REQUIRE(f.is_valid());
 
@@ -271,4 +267,17 @@ TEST_CASE("dssp_3")
 	dssp.annotate(f.front(), true, true);
 
 	// CHECK(f.is_valid());
+}
+
+// --------------------------------------------------------------------
+
+TEST_CASE("dssp_pdb")
+{
+	auto f = cif::pdb::read(gTestDir / "pdb1cbs.ent.gz");
+
+	REQUIRE(f.is_valid());
+
+	dssp dssp(f.front(), 1, 3, true);
+
+	dssp.annotate(f.front(), true, true);
 }
\ No newline at end of file



View it on GitLab: https://salsa.debian.org/med-team/dssp/-/commit/a97d1798e6f21e9acce6b3619019c2321aab1ccf

-- 
View it on GitLab: https://salsa.debian.org/med-team/dssp/-/commit/a97d1798e6f21e9acce6b3619019c2321aab1ccf
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20250831/13a76c73/attachment-0001.htm>


More information about the debian-med-commit mailing list