-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Link correctly with zlib when using hdf5 config #152
Conversation
Thanks. That seems to fix the zlib linking issue. Beside this issue I also noticed with the Conan recipe that HDF5 is only correctly found with latest CMake 3.18. It failed to find HDF5 with CMake 3.7 and any later other version I tested up to 3.17. Would it help to distribute the latest FindHDF5.cmake module along with matio or is it an issue with the recipe when configuring the CMake options? |
I tried CMake 3.15 to find the HDF5 1.12 libraries (downloaded and built like AppVeyor does) and it works fine. I made sure it did not use I know nothing about Conan, but are you supposed to set |
I get
if I set neither |
According to https://docs.conan.io/en/latest/integrations/build_system/cmake/find_packages.html |
I looked at some Conan recipes at https://github.com/conan-io/conan-center-index/tree/master/recipes, and none of them specify this. They do have a include(conanbuildinfo.cmake)
conan_basic_setup(TARGETS) Do you add this? |
Ah, no. That was one reason, it failed. One other reason was the Conan options handling. Now, it works with CMake 3.11 (and later), even without defining
|
Can you try changing it back to the original set_target_properties(HDF5::HDF5 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${HDF5_LIBRARIES}"
) We have the keep |
--- a/cmake/thirdParties.cmake
+++ b/cmake/thirdParties.cmake
@@ -73,9 +73,10 @@ if(HDF5_FOUND)
endif()
else()
# results from CMake FindHDF5
- target_include_directories(HDF5::HDF5 INTERFACE "${HDF5_INCLUDE_DIRS}")
- target_link_libraries(HDF5::HDF5 INTERFACE "${HDF5_LIBRARIES}")
- target_compile_definitions(HDF5::HDF5 INTERFACE "${HDF5_DEFINITIONS}")
+ set_target_properties(HDF5::HDF5 PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIRS}"
+ INTERFACE_LINK_LIBRARIES "${HDF5_LIBRARIES}"
+ )
endif()
endif() Yes, changing it back, resolved the Find-HDF5-Shared issue. Also, the For Find-HDF5-Static I get
in CMake 3.7, no matter if above patch applied or not or |
This is likely due to another Conan misconfiguration since I thought I already had the static one working. Will only check tomorrow. |
You have to keep I don't know what is going on with CMake 3.7. I'll try it with the libs from the hdf5 installer later. See if it fails with those as well, or if it is Conan related. |
Hm, I am all in favour to simply require CMake 3.11, where building both with static and shared hdf5 dependency succeeds. |
Update error message to match error message of CMake.
I tried CMake 3.7 with the HDF5 package from their website. Shared build fails because I propose to include the CMake 3.18 version of I updated the readme to also mention calling cmake with There is one other issues which I like to mention but will not address in this PR. HDF5 can also have a szip dependency (their website builds do), and FindHDF5 does not include this library in static builds. |
One more thing I noticed when using |
Sounds like a bug to me. @scivision @sethrj Is this a known issue? |
Thank you for your constant efforts to get this fixed while having too many degrees of freedom. License would not be problematic at all. But I actually wonder if it is worth the effort to distribute recent FindHDF5.cmake? I have no strong opinion. Ubuntu bionic is with CMake 3.10, thus it might be good to add it, instead of forcing CMake 3.11. On the other side it is a large portion of third-party code we need to maintain (see for example the cache issue you discovered). |
It might work since 3.9 or 3.10 if I look at https://github.com/Kitware/CMake/commits/master/Modules/FindHDF5.cmake, but I haven't tested those versions. You confirmed 3.11 works, so I use the built-in version for that and later versions. I'm in favour of keeping it simple. So maybe just mention in the readme that older CMake versions might not be able to find all HDF5 libraries, and using |
I didn't understand the question, but the latest (3.19 dev) FindHDF5 correctly includes transitive szip/zlib dependencies for shared/static hdf5, and the script does backport to at cmake 3.11. |
@sethrj @MaartenBent Thanks for the feedback. I propose
|
…der CMake versions" This reverts commit 6a6cd56.
Some FindHDF5 and hdf5-config versions do not define this automatically.
I vendor (copy) the FindHDF5.cmake from CMake GitLab into my projects and edit slightly. Because even that FindHDF5 doesn't cover all my corner cases. |
I have not yet had the privilege of using your project, but I do have some experience with the benefits and tradeoffs of bumping up the minimum CMake version. That might be for a separate Issue so as not to clutter here. Looking at your Travis-CI it looks like you're wanting to support older versions of Linux, MacOS etc. |
Some of those commits are useful, I only reverted 6a6cd56. Should I also remove the special case of finding a static zlib library, and just rely in the results from |
Hm, I trust your experience here since I cannot judge. Whatever makes configuration and code maintenance easier... |
I'll remove it then. If this special case is needed, it almost certainly needs something to find the static szip library as well. CMake does not have a FindSZIP, only using |
This hopefully concludes adding CMake support. Let me know if there is anything else (CMake related) to do. |
https://github.com/geospace-code/h5fortran/blob/master/cmake/Modules/FindSZIP.cmake |
Don't implement all the find functions ourselves, rely on hdf5-config instead.
Thanks. If using the config files provided by hdf5 proves to be insufficient, this will be useful. |
I now see that it also works with CMake 3.10 (both static/shared hdf5), but fails for 3.9. Can you confirm? If yes, we also could recommend 3.10 (being on bionic). Note, that I always set |
b93b2ea
to
763dd33
Compare
I can't test it today, but I suspect this is the relevant fix Kitware/CMake@6f131f4. It has tag v3.10.0-rc1, which suggests it is in CMake 3.10. |
OK, will do and merge. |
HAVE_ZLIB
has never set when hdf5-config provides the zlib targets. Also mapZLIB::ZLIB
to the correct target.