fix: propagate HDF5_IS_PARALLEL to parent scope for SZ3Config#127
fix: propagate HDF5_IS_PARALLEL to parent scope for SZ3Config#127
Conversation
Ensures @HDF5_IS_PARALLEL@ is correctly substituted in SZ3Config.cmake.in when configure_package_config_file runs in the parent CMakeLists.txt scope.
There was a problem hiding this comment.
Pull request overview
This PR fixes a scope issue identified in PR #126 where HDF5_IS_PARALLEL was not available in the parent scope when configure_package_config_file processes SZ3Config.cmake.in. The variable is set by find_package(HDF5) in the tools/H5Z-SZ3 subdirectory but needed in the parent scope for template substitution.
Changes:
- Propagate
HDF5_IS_PARALLELfrom subdirectory scope to parent scope usingPARENT_SCOPE
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| target_link_libraries(hdf5sz3 | ||
| PUBLIC MPI::MPI_CXX) | ||
| endif () | ||
| set(HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} PARENT_SCOPE) |
There was a problem hiding this comment.
When BUILD_H5Z_FILTER is OFF (the default), this subdirectory is not included (main CMakeLists.txt line 95-98), so HDF5_IS_PARALLEL remains undefined. The configure_package_config_file call (main CMakeLists.txt line 122) will substitute @HDF5_IS_PARALLEL@ with an empty string in SZ3Config.cmake.in line 6, resulting in invalid CMake syntax if(). This will cause errors for downstream projects using find_package(SZ3) when SZ3 is built with the default configuration.
Consider initializing HDF5_IS_PARALLEL to FALSE in the main CMakeLists.txt before line 95 (the BUILD_H5Z_FILTER conditional), ensuring it has a valid value even when the H5Z-SZ3 subdirectory is not included.
Summary
Fixes Copilot review comment on PR #126:
HDF5_IS_PARALLELwas not available in the parent scope whenconfigure_package_config_fileprocessesSZ3Config.cmake.in.Changes
tools/H5Z-SZ3/CMakeLists.txt: Addedset(HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} PARENT_SCOPE)to propagate the variable set byfind_package(HDF5)to the parent scope.Verified
Both import methods tested: