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 Build with Shared Libraries in MSYS2 Causing CMake Errors #5175

Open
ahnaf-tahmid-chowdhury opened this issue Dec 12, 2024 · 8 comments
Assignees
Labels
Component - Build CMake, Autotools

Comments

@ahnaf-tahmid-chowdhury
Copy link

Description

I successfully built and installed HDF5 from source with shared libraries enabled. However, when I attempt to use HDF5 in another CMake project and call find_package(HDF5), CMake fails with errors related to missing IMPORTED_LOCATION or IMPORTED_IMPLIB properties for hdf5-shared and hdf5_hl-shared.

Error Output

CMake Error at C:/msys64/clang64/share/cmake/Modules/FindHDF5.cmake:562 (get_target_property):
  IMPORTED_LOCATION or IMPORTED_IMPLIB not set for imported target
  "hdf5-shared" configuration "_imported_conf-NOTFOUND".
Call Stack (most recent call first):
  CMakeLists.txt:349 (find_package)


CMake Error at C:/msys64/clang64/share/cmake/Modules/FindHDF5.cmake:564 (get_target_property):
  IMPORTED_LOCATION or IMPORTED_IMPLIB not set for imported target
  "hdf5-shared".
Call Stack (most recent call first):
  CMakeLists.txt:349 (find_package)


CMake Error at C:/msys64/clang64/share/cmake/Modules/FindHDF5.cmake:576 (get_target_property):
  IMPORTED_LOCATION or IMPORTED_IMPLIB not set for imported target
  "hdf5_hl-shared" configuration "_imported_conf-NOTFOUND".
Call Stack (most recent call first):
  CMakeLists.txt:349 (find_package)


CMake Error at C:/msys64/clang64/share/cmake/Modules/FindHDF5.cmake:578 (get_target_property):
  IMPORTED_LOCATION or IMPORTED_IMPLIB not set for imported target
  "hdf5_hl-shared".
Call Stack (most recent call first):
  CMakeLists.txt:349 (find_package)


CMake Error at C:/msys64/clang64/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find HDF5 (missing: HDF5_LIBRARIES C HL) (found version "2.0.0")
Call Stack (most recent call first):
  C:/msys64/clang64/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  C:/msys64/clang64/share/cmake/Modules/FindHDF5.cmake:1027 (find_package_handle_standard_args)
  CMakeLists.txt:349 (find_package)

Expected Behavior

The find_package(HDF5) command should locate the installed HDF5 shared libraries, set up imported targets, and provide the necessary include directories and library paths.

Environment

  • Operating System: Windows (MSYS2/CLANG64/MINGW64)
  • HDF5 Version: 2.0.0 (built from source)
  • CMake Version: 3.31.2
  • Compiler: Clang/GCC
  • Build Type: Shared Libraries (-DBUILD_SHARED_LIBS=ON)
@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 12, 2024

The HDF5 that is supposed to be found - was it built with CMake (has hd5-config*.cmake files in CMake folder) or not.
Did you provide a HDF5_ROOT ENV var location?

@ahnaf-tahmid-chowdhury
Copy link
Author

Yes, and it works when I set HDF5_NO_FIND_PACKAGE_CONFIG_FILE=ON. So, I think hd5-config*.cmake is unable to set the targets properly.

@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 12, 2024

Strange that a CMake built install only works with MODULE find and not CONFIG version.
If you could provide a few more details about the HDF5 specific parts of the build command:
HDF5_ROOT is set to the root location and not the CMake subdir.
OR add message (STATUS ...) lines in the hdf5-config file to trace execution and settings?

@hyoklee hyoklee added the Component - Build CMake, Autotools label Dec 12, 2024
@ahnaf-tahmid-chowdhury
Copy link
Author

Here is the workflow file where I've used HDF5:
windows_build_test.yml.

@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 13, 2024

We have one that builds but not one that tests the install.

@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 13, 2024

WOW - there is a lot going on with CMake - HDF5- libaec and find_package!

First, a good to know CMake option is -DCMAKE_FIND_DEBUG_MODE:BOOL=ON which shows the process and files that CMake used to get the package info.

Setting ENV{SZIP_ROOT} is all that is needed to find the package. (HDF5 does require -DSZIP_USE_EXTERNAL:BOOL=OFF and -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING="NO")

The next problem is that libaec doesn't set SZIP_LIBRARIES just SZIP_LIBRARY and libaec_LIBRARY.

I am running into some other issues outside of the find_package.

@byrnHDF
Copy link
Contributor

byrnHDF commented Dec 18, 2024

See #5182 for SZIP/libaec fixes against develop

@byrnHDF
Copy link
Contributor

byrnHDF commented Jan 6, 2025

Just a note that the CMake provided FindHDF5.cmake module expects an autotools built HDF5, to find a CMake built HDF5 use find_package with the CONFIG option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Build CMake, Autotools
Projects
None yet
Development

No branches or pull requests

3 participants