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

HDF5 dependency cannot be excluded #11707

Open
efferre79 opened this issue Jan 23, 2025 · 2 comments
Open

HDF5 dependency cannot be excluded #11707

efferre79 opened this issue Jan 23, 2025 · 2 comments

Comments

@efferre79
Copy link

What is the bug?

When configuring the source I can use the cmake define -DGDAL_USE_HDF5=OFF to disable HDF5 support. What happens is that HDF5 is still detected due to the following code in cmake/helpers/CheckDependentLibraries.cmake:

if(HAVE_KEA)
    # CXX is only needed for KEA driver
    gdal_check_package(HDF5 "Enable HDF5" COMPONENTS "C" "CXX" CAN_DISABLE VERSION 1.10)
else()
    gdal_check_package(HDF5 "Enable HDF5" COMPONENTS "C" CAN_DISABLE VERSION 1.10)
endif()

KEA driver depends on HDF5 but if both KEA and HDF5 are disabled, the configure system still looks for HDF5 libraries. I think that something like the following will fix the issue:

if(HAVE_KEA)
    # CXX is only needed for KEA driver
    gdal_check_package(HDF5 "Enable HDF5" COMPONENTS "C" "CXX" CAN_DISABLE VERSION 1.10)
else()
    if(GDAL_USE_HDF5)
        gdal_check_package(HDF5 "Enable HDF5" COMPONENTS "C" CAN_DISABLE VERSION 1.10)
    endif()
endif()

Steps to reproduce the issue

just run cmake with -DGDAL_USE_HDF5=no and -DGDAL_USE_KEA=OFF on a system with hdf5 installed

I get

...

-- Found HDF5: /usr/lib64/libhdf5.so;/usr/lib64/libsz.so;/usr/lib64/libz.so;/usr/lib64/libdl.a;/usr/lib64/libm.so (found version "1.14.4-3") found components: C

...

 * HDF5
   Enable HDF5

...

in the output log.

Versions and provenance

Gentoo Linux

$ gdalinfo --version
GDAL 3.9.1, released 2024/06/22

Additional context

No response

@rouault
Copy link
Member

rouault commented Jan 23, 2025

That's probably more a UI / documentation issue than a bug (but not sure where/how clarifying it). Turning off the use of a package doesn't turn off its detection. That's on purpose for reasons I don't remember right now. But the end effect is that drivers that depend on the packages, namely HDF5 and KEA, are not enabled themselves:

-- The following OPTIONAL packages have been found:
[....]
 * HDF5
   Enable HDF5
[....]
-- The following features have been disabled:
[...]
 * gdal_HDF5, Hierarchical Data Format Release 5 (HDF5)
 * gdal_KEA, Kea
[....]

@efferre79
Copy link
Author

I see. Thanks for pointing it out. Typically disabling some feature disables also its detection, IMHO it makes sense to cite in the docs. I will leave open there this issue and let you decide if you want to convert into a documentation issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants