hdf5 icon indicating copy to clipboard operation
hdf5 copied to clipboard

HDF5 Build with Shared Libraries in MSYS2 Causing CMake Errors

Open ahnaf-tahmid-chowdhury opened this issue 1 year ago • 8 comments

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)

ahnaf-tahmid-chowdhury avatar Dec 12 '24 07:12 ahnaf-tahmid-chowdhury

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?

byrnHDF avatar Dec 12 '24 13:12 byrnHDF

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.

ahnaf-tahmid-chowdhury avatar Dec 12 '24 13:12 ahnaf-tahmid-chowdhury

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?

byrnHDF avatar Dec 12 '24 14:12 byrnHDF

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

ahnaf-tahmid-chowdhury avatar Dec 13 '24 05:12 ahnaf-tahmid-chowdhury

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

byrnHDF avatar Dec 13 '24 13:12 byrnHDF

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 avatar Dec 13 '24 17:12 byrnHDF

See #5182 for SZIP/libaec fixes against develop

byrnHDF avatar Dec 18 '24 13:12 byrnHDF

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.

byrnHDF avatar Jan 06 '25 14:01 byrnHDF

Can this issue be closed?

brtnfld avatar Mar 06 '25 18:03 brtnfld