Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use only one find_package call for zlib. #5280

Merged
merged 16 commits into from
Feb 14, 2025
Merged

Conversation

byrnHDF
Copy link
Contributor

@byrnHDF byrnHDF commented Jan 27, 2025

Addresses #5155, and related #4614 #4904

zlib system installs tend to not have CMake config files and therefore require that a plain vanilla find_package call be used. This uses the find module for zlib. For more control over what gets found, an option to use config mode of find package is added. Which allows the use of static libs and better target properties. Also native zlib-ng, which usually has config files, would be better served with the config mode.

@byrnHDF byrnHDF added Priority - 2. Medium ⏹ It would be nice to have this in the next release Component - Build CMake, Autotools Type - Improvement Improvements that don't add a new feature or functionality labels Jan 27, 2025
@byrnHDF byrnHDF self-assigned this Jan 27, 2025
bmribler
bmribler previously approved these changes Jan 28, 2025
brtnfld
brtnfld previously approved these changes Jan 28, 2025
@byrnHDF byrnHDF dismissed stale reviews from brtnfld and bmribler via f54d538 January 29, 2025 14:40
lrknox
lrknox previously approved these changes Jan 29, 2025
Copy link
Collaborator

@lrknox lrknox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 code suggestions - indentation and missing "be". Currently testing cmake configure commands; ok so far.

@lrknox
Copy link
Collaborator

lrknox commented Jan 29, 2025

Tested minimal cmake configure commands, e.g. cmake -G "Unix Makefiles" -DHDF5_ENABLE_ZLIB_SUPPORT=ON ../hdf5, on jelly, ec2-ubuntu24.04, and macmini-m1. In a spack environment and outside the spack environment on jelly and macmini-m1. In the spack environment the previous zlib build in spack is added; outside it picks up the one beneath /usr.

On Windows 11 I tested with a VCPkg installed zlib, szip(libaec), and curl and ssl for ros3. I added CMake ROOT variables for these since they were not system installs. I ran builds and tests with no errors/failures on all the machines.

lrknox
lrknox previously approved these changes Jan 29, 2025
lrknox
lrknox previously approved these changes Feb 7, 2025
message (VERBOSE "Filter HDF5_ZLIB package name:${PACKAGE_NAME}")
if (HDF5_MODULE_MODE_ZLIB)
# Expect that the default shared library is expected with FindZLIB.cmake
find_package (ZLIB MODULE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
find_package (ZLIB MODULE)
find_package (ZLIB MODULE REQUIRED)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #5306 created

else ()
set(ZLIB_SEARCH_TYPE shared)
endif ()
find_package (ZLIB NAMES ${PACKAGE_NAME} CONFIG OPTIONAL_COMPONENTS ${ZLIB_SEARCH_TYPE})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
find_package (ZLIB NAMES ${PACKAGE_NAME} CONFIG OPTIONAL_COMPONENTS ${ZLIB_SEARCH_TYPE})
find_package (ZLIB NAMES ${PACKAGE_NAME} CONFIG REQUIRED OPTIONAL_COMPONENTS ${ZLIB_SEARCH_TYPE})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #5306 created

@haampie
Copy link
Contributor

haampie commented Feb 8, 2025

Can you use find_package(... REQUIRED)? That improves error messages on failure. Also removes the need for branching on whether zlib is found.

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Feb 10, 2025

Can you use find_package(... REQUIRED)? That improves error messages on failure. Also removes the need for branching on whether zlib is found.

I understand the reasoning, however, there is still a group of devs, which are not convinced that a FATAL_ERROR should happen for not finding a compression library - also, if zlib is built in-line then that process also would need to be changed.
Therefore at this moment, maybe it is best to make a simpler change and then work on a followup that implements REQUIRED processing.

@haampie
Copy link
Contributor

haampie commented Feb 10, 2025

which are not convinced that a FATAL_ERROR

Right now it's already a fatal error:

if (HDF5_ENABLE_ZLIB_SUPPORT)
  ... find_package calls
  if (H5_ZLIB_FOUND)
    ...
  else ()
    set (HDF5_ENABLE_ZLIB_SUPPORT OFF CACHE BOOL "" FORCE)
    message (FATAL_ERROR " ZLib support in HDF5 was enabled but not found")
  endif ()
endif ()

message (FATAL_ERROR stops cmake.

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Feb 10, 2025

which are not convinced that a FATAL_ERROR

Right now it's already a fatal error:
Yes, for develop, and it should stay that way. Just trying to get this implemented in smaller steps. Let's create an issue to fix the inline build code to behave the same as find_package REQUIRED and eliminate extra code?

@byrnHDF
Copy link
Contributor Author

byrnHDF commented Feb 10, 2025

Issue #5306 created to deal with the REQUIRED argument of find_package.

lrknox
lrknox previously approved these changes Feb 11, 2025
Copy link
Collaborator

@lrknox lrknox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

homebrew-installed libaec and szip were found with command "cmake -DHDF5_ENABLE_SZIP_SUPPORT -DHDF5_ENABLE_ZLIB_SUPPORT ../byrn-hdf5", which contained changes for PRs #5280 and #5298. ctest ran deflate and szip tests; all tests passed. This was on an older mac 10.13, the only one where I have privileges for system installs.

@byrnHDF byrnHDF merged commit 2f4f690 into HDFGroup:develop Feb 14, 2025
77 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Build CMake, Autotools Priority - 2. Medium ⏹ It would be nice to have this in the next release Type - Improvement Improvements that don't add a new feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants