Skip to content

Enhance CMake configuration to automatically detect and use system-installed libaec as an SZIP provider #6129

@brtnfld

Description

@brtnfld

Description:

Overview
The HDF5 CMake build system currently defaults to looking specifically for SZIP libraries when HDF5_ENABLE_SZIP_SUPPORT is enabled. However, on most modern Linux distributions (Debian, Ubuntu, Fedora, Arch), the libaec library is the standard, widely available open-source drop-in replacement for SZIP.

Currently, configuring HDF5 to use a system-installed libaec is not straightforward. It often fails to detect libaec automatically, requiring users to manually define SZIP_INCLUDE_DIR and SZIP_LIBRARY paths, to symlink libaec to libsz to trick the build system, or to compile the compression software.

Motivation

  • User Experience: Users installing HDF5 dependencies via standard package managers (e.g., apt install libaec-dev) expect CMake to find these libraries without manual intervention.
  • Licensing & Availability: libaec is BSD-licensed and is the preferred SZIP implementation in the open-source community. HDF5 should treat it as a first-class citizen.
  • Build Automation: Simplifying this detection reduces the complexity of CI/CD pipelines and Docker builds that rely on system packages.

Current Behavior
When a user runs:

cmake -DHDF5_ENABLE_SZIP_SUPPORT=ON -DHDF5_ENABLE_SZIP_ENCODING=ON ..

The build system attempts to find SZIP. If szip is not strictly named or located in standard FindSZIP lookups (often looking for szlib.h or libsz.so), the configuration fails or requires the user to manually path to libaec artifacts.

Desired Behavior
When HDF5_ENABLE_SZIP_SUPPORT is ON, the CMake logic should:

  1. Check for SZIP.
  2. If SZIP is not found, automatically fall back to checking for libaec (using libaec-config.cmake or pkg-config).
  3. If libaec is found, automatically alias the targets or set the internal H5_SZIP_* variables to point to the libaec includes and libraries.
  4. Handle the difference in library names transparently (i.e., linking against libaec instead of libsz if that is what was found).

Environment

  • OS: Linux (Ubuntu, Fedora, etc.)
  • Build System: CMake
  • Library: libaec (v1.0+) installed via system package manager.

Reproduction Steps

  1. On a clean Linux container (e.g., Ubuntu 22.04), install build essentials and libaec: apt-get install build-essential cmake libaec-dev.
  2. Download HDF5 source.
  3. Attempt to configure with SZIP support: cmake -S . -B build -DHDF5_ENABLE_SZIP_SUPPORT=ON.
  4. Observation: CMake fails to find SZIP, despite libaec (the compatible replacement) being present in the system path.

Metadata

Metadata

Assignees

Projects

Status

In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions