Repository navigation
fix: export hdf5sz3 target and resolve dependencies for find_package consumers - #126
Conversation
- Add install(EXPORT HDF5SZ3) to install the hdf5sz3 CMake target - Update SZ3Config.cmake.in to include HDF5SZ3 export with HDF5 and conditional MPI dependency resolution - Enables #include <H5Z_SZ3.hpp> to work when using find_package(SZ3) and linking SZ3::hdf5sz3
There was a problem hiding this comment.
Pull request overview
This PR attempts to fix dependency resolution for the hdf5sz3 target in downstream projects using find_package(SZ3). It adds conditional MPI dependency resolution based on whether HDF5 was built with parallel support, complementing the existing HDF5 dependency resolution added to handle the hdf5sz3 target export from PR #125.
Changes:
- Added conditional MPI dependency resolution in SZ3Config.cmake.in, checking if HDF5 is parallel before requiring MPI with CXX component
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| include("${CMAKE_CURRENT_LIST_DIR}/SZ3Targets.cmake") | ||
| if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/HDF5SZ3.cmake") | ||
| find_package(HDF5 COMPONENTS C REQUIRED) | ||
| if(@HDF5_IS_PARALLEL@) |
There was a problem hiding this comment.
The variable HDF5_IS_PARALLEL is not available in the parent scope when configure_package_config_file is called in CMakeLists.txt:122. The find_package(HDF5) call that sets HDF5_IS_PARALLEL only occurs in tools/H5Z-SZ3/CMakeLists.txt:7, which is a subdirectory scope that doesn't propagate variables to the parent. This means @HDF5_IS_PARALLEL@ will be empty or undefined in the generated SZ3Config.cmake file, causing the conditional check to fail or behave incorrectly. To fix this, you need to either: (1) call find_package(HDF5) in the parent CMakeLists.txt before configure_package_config_file when BUILD_H5Z_FILTER is ON, or (2) explicitly propagate HDF5_IS_PARALLEL to parent scope in tools/H5Z-SZ3/CMakeLists.txt using set(HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} PARENT_SCOPE).
| if(@HDF5_IS_PARALLEL@) | |
| if(HDF5_IS_PARALLEL) |
Brings in upstream changes that don't touch docs/: * HDF5 target export improvements (#125, #126, #128) - SZ3::hdf5sz3 target now exposed in build + export trees - Cleanups in tools/H5Z-SZ3, mdz, sz3c CMakeLists * NixOS support: new default.nix (#129) * Lorenzo predictor pointer-arith UB fix (#121) - LorenzoPredictor.hpp + QuantOptimization.hpp: d[-i] -> *(d - i) to avoid size_t unsigned wrap-around .gitignore: union merge (master adds sz3_install / sz3_build / test; fz keeps tmp / .cache / docs/site/html / .claude). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
This PR updates SZ3Config.cmake.in to properly export the hdf5sz3 target and resolve its dependencies for downstream projects using find_package(SZ3).
Changes
Problem
After PR #125, the hdf5sz3 target is exported to the install tree, but SZ3Config.cmake did not include the export file or resolve its transitive dependencies (HDF5::HDF5, MPI::MPI_CXX). This caused configuration errors for downstream projects.
Verified
Both import methods tested with #include <H5Z_SZ3.hpp>: