Skip to content

ptfkit for C and C++

The native ptfkit distribution provides:

  • header-only C11 functions through the ptfkit::c CMake target;
  • optional C++23 modules through the ptfkit::cpp CMake target.

Install from a release archive

Versioned native CMake packages are attached to each GitHub Release. For a release vX.Y.Z, download ptfkit-native-X.Y.Z.tar.gz, extract the archive, and add its root directory to CMAKE_PREFIX_PATH. The package is ready for find_package and does not need a separate build or install step. A matching .sha256 file is provided for optional checksum verification.

The archives are generated by the release workflow and carry GitHub build-provenance attestations.

Build and install from source

CMake 3.21 or newer is required for the C package. C++ modules require CMake 3.28 or newer and a compiler with C++23 module support.

cmake -S . -B build -GNinja -DBUILD_TESTING=OFF
cmake --build build
cmake --install build --prefix /path/to/prefix

The C++ module target is enabled by default when the active CMake version supports it. It can be controlled explicitly with -DPTFKIT_BUILD_CPP_MODULES=ON or OFF. The C and C++ targets are independent: ptfkit::c is C11-only, while ptfkit::cpp provides only C++ modules.

CMake package

find_package(ptfkit CONFIG REQUIRED)

add_executable(example example.c)
target_link_libraries(example PRIVATE ptfkit::c)

For C++ modules, scan the importing target and link against ptfkit::cpp. The installed package provides both targets, so consumers use the same find_package call.

find_package(ptfkit CONFIG REQUIRED)

add_executable(example example.cpp)
set_target_properties(example PROPERTIES CXX_SCAN_FOR_MODULES ON)
target_link_libraries(example PRIVATE ptfkit::cpp)

C usage

#include <ptfkit/jabro1992.h>

double k_sat = calc_ptf_jabro1992(20.0, 30.0, 1.3);

C++ usage

import ptfkit.jabro1992;

double k_sat = ptfkit::jabro1992::calc_ptf_jabro1992(20.0, 30.0, 1.3);

Documentation

The applicability of each PTF depends on the dataset, territory, measurement methods, and variable ranges reported by its source publication.