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

On macOS, using CMake, the OS-provided zlib is not found. Worse, it seems not possible to point to it. #5155

Open
seanm opened this issue Nov 27, 2024 · 8 comments
Assignees
Labels
Component - Build CMake, Autotools Priority - 1. High 🔼 These are important issues that should be resolved in the next release Type - Bug / Bugfix Please report security issues to [email protected] instead of creating an issue on GitHub
Milestone

Comments

@seanm
Copy link
Contributor

seanm commented Nov 27, 2024

Describe the bug
On macOS, using CMake, the OS-provided zlib is not found. Worse, it seems not possible to point to it.

HDF5 provides a ZLIB_DIR setting, but it's described as "The directory containing a CMake configuration file for ZLIB." macOS does not provide any CMake configuration file for ZLIB, and in fact CMake is not even zlib's usual build system, so it's odd to look for that at all.

Other libraries I use, such as VTK and ITK, provide CMake variables like:

  • ZLIB_INCLUDE_DIR
  • ZLIB_LIBRARY_DEBUG
  • ZLIB_LIBRARY_RELEASE

Which you can just point directly to the zlib include directory, and library files. This is most flexible, and then you don't care how zlib was built.

These tickets seem related, but maybe not identical: #4614 #4904

Expected behavior
macOS provides zlib, therefore I'd expect it to be detected by default, or at least be able to point to it.

Platform (please complete the following information)

  • HDF5 version: git master
  • OS and version: macOS 14
  • Compiler and version: Xcode 16
  • Build system (e.g. CMake, Autotools) and version: CMake
@hyoklee
Copy link
Member

hyoklee commented Nov 30, 2024

Hi, @seanm !

Thank you for your report but I cannot duplicate your concern.

-- Found ZLIB: /Applications/Xcode_16.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.1.sdk/usr/lib/libz.tbd (found version "1.2.12")
-- H5_ZLIB_HEADER=zlib.h
-- H5_ZLIB_HEADER=zlib.h
-- H5_ZLIB_HEADER=zlib.h
-- H5_ZLIB_HEADER=zlib.h
-- H5_ZLIB_HEADER=zlib.h

Please see the complete action log and workflow.

All (incl. deflate) tests passed.

@seanm
Copy link
Contributor Author

seanm commented Dec 1, 2024

@hyoklee thanks for your reply. In my case, it finds a zlib that some other software installed. It finds ZLIB_DIR as /usr/local/minc/share/cmake/ZLIB. That's not so bad, but I can't find a way to point it elsewhere. What do I set ZLIB_DIR to point to the macOS-provided zlib?

@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 2, 2024

In release_docs/INSTALL_CMake.txt , section "IV. Further considerations" and section "V. Options for Building HDF5 Libraries with the CMake Command Line" show the CMake options to use.

        * H5_SZIP_INCLUDE_DIR:PATH=<path to szip includes directory>
        * H5_SZIP_LIBRARY:FILEPATH=<path to szip/library file>
        * H5_ZLIB_INCLUDE_DIR:PATH=<path to zlib includes directory>
        * H5_ZLIB_LIBRARY:FILEPATH=<path to zlib/library file>

@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 2, 2024

We may have been overzealous with our prefix (H5_) changes and you may need to remove the prefix.

@chennes
Copy link

chennes commented Dec 2, 2024

This is not macOS specific -- the same problem occurs on Windows if using a self-compiled ZLIB. ZLIB itself does not provide a cMake configuration file when installed so that isn't a Mac thing, it's just a ZLIB thing. It does provide a pkgconf configuration file, but HDF5 is not attempting to use that. To get it working I had to manually set the paths to the include dir and the direct path to the library file itself, via:
`-D ZLIB_INCLUDE_DIR={self.install_dir}/include -D ZLIB_LIBRARY={self.install_dir}/lib/zlib.lib" (note that the H5 prefix specified in the documentation is indeed incorrect, and should not be included).

@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 2, 2024

Thank you - I will fix the documentation.

@seanm
Copy link
Contributor Author

seanm commented Dec 2, 2024

In release_docs/INSTALL_CMake.txt , section "IV. Further considerations" and section "V. Options for Building HDF5 Libraries with the CMake Command Line" show the CMake options to use.

        * H5_SZIP_INCLUDE_DIR:PATH=<path to szip includes directory>
        * H5_SZIP_LIBRARY:FILEPATH=<path to szip/library file>
        * H5_ZLIB_INCLUDE_DIR:PATH=<path to zlib includes directory>
        * H5_ZLIB_LIBRARY:FILEPATH=<path to zlib/library file>

I see no such options in cmake: Image

@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 2, 2024

I think those vars are for the find_library process.
There is a mention of this:
You can specify the search order using one or more of NO_DEFAULT_PATH, NO_CMAKE_ENVIRONMENT_PATH , NO_CMAKE_PATH, NO_SYSTEM_ENVIRONMENT_PATH, NO_CMAKE_SYSTEM_PATH, CMAKE_FIND_ROOT_PATH_BOTH, ONLY_CMAKE_FIND_ROOT_PATH, or NO_CMAKE_FIND_ROOT_PATH.

CMAKE will search under $CMAKE_PREFIX_PATH/include for headers and $CMAKE_PREFIX_PATH/libs for libraries.

From CMAKE documentation:
For each path in the CMAKE_PREFIX_PATH list, CMake will check "PATH/include" and "PATH" when FIND_PATH() is called, "PATH/bin" and "PATH" when FIND_PROGRAM() is called, and "PATH/lib and "PATH" when FIND_LIBRARY() is called.

@derobins derobins added Priority - 1. High 🔼 These are important issues that should be resolved in the next release Component - Build CMake, Autotools Type - Bug / Bugfix Please report security issues to [email protected] instead of creating an issue on GitHub labels Dec 2, 2024
@derobins derobins added this to the 2.0.0 milestone Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Build CMake, Autotools Priority - 1. High 🔼 These are important issues that should be resolved in the next release Type - Bug / Bugfix Please report security issues to [email protected] instead of creating an issue on GitHub
Projects
None yet
Development

No branches or pull requests

5 participants