Dear experts…
In cmake/hdf5-targets.cmake of the 2.0.0 library, Threads::Threads seems to be linked to hdf5::hdf5-static and hdf5::hdf5_fortran-static regardless of the setting on wheather to use threading or not, but is it really needed?
Kazuyoshi
Hi @furutaka.kazuyoshi,
HDF5 currently still always calls find_package(Threads) and adds it to the linked libraries if found, which is probably why it appears here in the targets file. There has been some internal discussion around reworking our CMake logic to only link in a threading package when actually used, but no progress has been made on that so far. If your HDF5 installation wasn’t built with thread safety enabled, there shouldn’t be any need for Threads::Threads to be linked in; this is simply a quirk of our current CMake logic.
I have another related problem with 2.0.0 and the threads. I want to compile HDF5 for use with the NAG Fortran compiler, and I have to comment out the threads part from the CMake lists to be able to compile HDF5 2.0. This was never the case with versions < 2. Taking away the threads makes it work.
I can dig out the exact error later (don’t have it here), but the problem is that the CMake scripts assume that the flags that are found valid for C/C++ automatically also are valid for Fortran. Which is fine when you use GCC and GFortran for instance, but not when using NAG Fortran. NAG does not understand the threads flag and will not compile the code.
The irony is of course that no Fortran code in HDF5 need any threads flags what so ever - since they are just shallow wrappers that translate a few tiny objects besides passing pointers.
1 Like