[CMake] [New Module] FindHDF5.cmake

Will Dicharry wdicharry at stellarscience.com
Wed Aug 19 18:10:13 EDT 2009


Hi All,

Sorry for the month of delay, but I've addressed Mike Jackson's concerns 
below and I think I'm close to having the HDF5 find module ready for 
submission.

I've tested it on a number of Unix and Linux systems, including desktops 
and clusters, but it would be helpful if someone with access to Windows 
or Mac systems could give it a try there and let me know what needs to 
be fixed.

There are two modules attached to this message: The FindHDF5.cmake 
module and an AdjustLibraryVariables.cmake module, which is essentially 
a copy of what the FindQt4 module does.  It seems useful enough to 
incorporate into the CMake Modules, and I can maintain it if you need a 
maintainer.

How I addressed Mike Jackson's concerns is addressed in the module 
documentation at the top of the file, please let me know if anyone has 
any other concerns.

I'd love to hear any feedback that anyone may have.  Once I have some 
feedback from Windows and Mac users, I'd like to get this put into the 
CMake distribution if possible.

Thanks,
--Will

James C. Sutherland wrote:
> Out of curiosity, was a module ever submitted for this?  I would love to 
> have a copy ;-)
> 
> Specifically, I am interested in detecting statically linked libraries 
> and the c++ library and header(s).  I also would like to see a list of 
> libraries like the "z" library for compression.
> 
> Utility executables like h5diff are also really useful for regression 
> testing, so returning handles to those would be really great as well.
> 
> Thanks for your work on this!
> 
> James
> 
> 
> On Jul 10, 2009, at 11:01 AM, Michael Jackson wrote:
> 
>> reponses in line..
>>
>>
>> On Jul 10, 2009, at 12:33 PM, Will Dicharry wrote:
>>
>>> Michael Jackson wrote:
>>>>
>>>>
>>>> On Jul 10, 2009, at 11:13 AM, Brad King wrote:
>>>>
>>>>> Will Dicharry wrote:
>>>>>> Mike Jackson wrote:
>>>>>>> Can you post your module or attach it to a bug/feature request? I 
>>>>>>> also
>>>>>>> have a FindHDF5 module and I would like to compare the two.
>>>>>>
>>>>>> Sorry about that, I meant to attach the module to the first 
>>>>>> email.  It
>>>>>> is attached to this one.
>>>>>
>>>>> After you two have combined your versions and reached consensus,
>>>>> please post again and Cc me.  Then I'll send instructions to get
>>>>> CVS commit access.  I see no reason not to have co-maintainers
>>>>> for a module.
>>>>>
>>>>> Thanks,
>>>>> -Brad
>>>>
>>>> I'll let Will be the maintainer. My module ends up being a bit more 
>>>> specific to my own version of HDF5, ie, I am just looking for the 
>>>> libraries (c, c++, and High Level) but not really looking for the 
>>>> HDF5 compiler scripts.
>>>>
>>>> Couple of observations about the module:
>>>>
>>>> Does it find the HDF5 C++ library?
>>>
>>> No, but I'll add that in by invoking the HDF5 C++ wrapper compiler 
>>> and searching the output.
>>
>> Great.
>>>
>>>>
>>>> Can it figure out if the HDF5 library is a static or dynamic 
>>>> library? (I configure a header file that has that information inside 
>>>> it which can then be tested for).
>>>
>>> No, I'll look into how to determine that.  Suggestions welcome.
>>
>> Well, I don't think there is an easy way to do it besides looking at 
>> the fully name of the library file, but even then that can give you 
>> bad results. In my CMake build system for HDF5 I add a few more 
>> #define elements into the H5Config.h file that has the necessary parts 
>> to be able to determine how HDF5 was compiled- static or dynamic.
>>
>>>
>>>>
>>>> Is it properly finding dependent libraries when needed, like szip or 
>>>> zip ( I don't as I do NOT compile HDF5 with that support)?
>>>
>>> Yes, I need it to work across a number of platforms, many of which do 
>>> compile in szip support.  I search for all libraries linked by the 
>>> wrapper compiler and add them to the HDF5_LIBRARIES list.
>>
>> You may also want to include variables such as HDF5_SZIP_LIBRARY and 
>> HDF5_ZIP_LIBRARY. You also might want to include some CMake code to 
>> generate the following variables:
>>
>> HDF5_LIBRARY_DEBUG
>> HDF5_LIBRARY_RELEASE
>> HDF5_LIBRARY
>>
>> For each library found. I think the normal hdf5 distribution will 
>> append a 'd' to the name of the hdf5 library when built in Debug mode. 
>> My own build system uses '_d' on windows and _debug on gcc. The 
>> necessary cmake code will "do the right thing" if one of the libraries 
>> are not found.
>>
>> ############################################
>> #
>> # Check the existence of the libraries.
>> #
>> ############################################
>> # This macro was taken directly from the FindQt4.cmake file that is 
>> included
>> # with the CMake distribution. This is NOT my work. All work was done 
>> by the
>> # original authors of the FindQt4.cmake file. Only minor modifications 
>> were
>> # made to remove references to Qt and make this file more generally 
>> applicable
>> #########################################################################
>>
>> MACRO (_MXA_ADJUST_LIB_VARS basename)
>>  IF (${basename}_INCLUDE_DIR)
>>
>>  # if only the release version was found, set the debug variable also 
>> to the release version
>>  IF (${basename}_LIBRARY_RELEASE AND NOT ${basename}_LIBRARY_DEBUG)
>>    SET(${basename}_LIBRARY_DEBUG ${${basename}_LIBRARY_RELEASE})
>>    SET(${basename}_LIBRARY       ${${basename}_LIBRARY_RELEASE})
>>    SET(${basename}_LIBRARIES     ${${basename}_LIBRARY_RELEASE})
>>  ENDIF (${basename}_LIBRARY_RELEASE AND NOT ${basename}_LIBRARY_DEBUG)
>>
>>  # if only the debug version was found, set the release variable also 
>> to the debug version
>>  IF (${basename}_LIBRARY_DEBUG AND NOT ${basename}_LIBRARY_RELEASE)
>>    SET(${basename}_LIBRARY_RELEASE ${${basename}_LIBRARY_DEBUG})
>>    SET(${basename}_LIBRARY         ${${basename}_LIBRARY_DEBUG})
>>    SET(${basename}_LIBRARIES       ${${basename}_LIBRARY_DEBUG})
>>  ENDIF (${basename}_LIBRARY_DEBUG AND NOT ${basename}_LIBRARY_RELEASE)
>>  IF (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE)
>>    # if the generator supports configuration types then set
>>    # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a 
>> value
>>    IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
>>      SET(${basename}_LIBRARY       optimized 
>> ${${basename}_LIBRARY_RELEASE} debug ${${basename}_LIBRARY_DEBUG})
>>    ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
>>      # if there are no configuration types and CMAKE_BUILD_TYPE has no 
>> value
>>      # then just use the release libraries
>>      SET(${basename}_LIBRARY       ${${basename}_LIBRARY_RELEASE} )
>>    ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
>>    SET(${basename}_LIBRARIES       optimized 
>> ${${basename}_LIBRARY_RELEASE} debug ${${basename}_LIBRARY_DEBUG})
>>  ENDIF (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE)
>>
>>  SET(${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH "The 
>> ${basename} library")
>>
>>  IF (${basename}_LIBRARY)
>>    SET(${basename}_FOUND 1)
>>  ENDIF (${basename}_LIBRARY)
>>
>> ENDIF (${basename}_INCLUDE_DIR )
>>
>>  # Make variables changeble to the advanced user
>>  MARK_AS_ADVANCED(${basename}_LIBRARY ${basename}_LIBRARY_RELEASE 
>> ${basename}_LIBRARY_DEBUG ${basename}_INCLUDE_DIR )
>> ENDMACRO (_MXA_ADJUST_LIB_VARS)
>>
>>
>>>
>>>> Make use of some sort of environment variable as a possible solution 
>>>> to finding the root of where HDF5 is installed, I personally use the 
>>>> environment variable "HDF5_INSTALL" for use in my script.
>>>
>>> No.  I'd personally prefer to rely on setting something similar in 
>>> the cache rather than using an environment variable, but I'm open to 
>>> changing my opinion.
>>
>> Yes. Simply because if you gather 20 people who compile HDF5 you will 
>> probably get some, if not all, who decide they want HDF5 installed 
>> somewhere else: /opt, /sw, /usr, /usr/local, /Users/$HOME/.. , 
>> /Users/Shared/Toolkits, /Users/Shared/OpenSource, C:/hdf5, 
>> C:/Developer/GCC, C:/Program Files/hdf5 (replace the drive letter with 
>> any other drive letter on windows).
>>
>> Having to run cmake and cmake not being able to find HDF5 EVERY TIME 
>> is a PITA. I used to have to deal with this. A simple environment 
>> variable solves this problem. If you want a concrete case, just look 
>> at Boost. Used by lots of people, installed everywhere imaginable. 
>> Even _with_ setting Boost_ROOT CMake _still_ sometimes has problems 
>> finding boost (Of course the crazy library naming doesn't help). Qt - 
>> Same thing: Either provide QtDir or the qmake executable. Ignoring the 
>> use of an environment variable is ignoring a dead easy way to help 
>> your users use CMake effectively. So.. Yes.
>>
>>
>>>
>>>> I imagine what I _should_ be doing is creating a HDF5Config.cmake 
>>>> file and UseHDF5.cmake file for my own HDF5 distribution (which is 
>>>> based on HDF5 version 1.6.9 and uses CMake as its build system).
>>>>
>>>> Just my comments. If you want to see what I've come up with let me 
>>>> know. My git repo is public:
>>>>
>>>> http://www.bluequartz.net/cgi-bin/gitweb/gitweb.cgi?p=MXADataModel.git;a=blob_plain;f=Resources/CMake/MXAFindHDF5.cmake;hb=HEAD 
>>>>
>>>>
>>>
>>> I'll take a look so I can try to make the module as useful as 
>>> possible.  Thanks for the suggestions!
>>>
>>> --Will
>>>
>>>> _________________________________________________________
>>>> Mike Jackson                  mike.jackson at bluequartz.net
>>>> BlueQuartz Software                    www.bluequartz.net
>>>> Principal Software Engineer                  Dayton, Ohio
>>
>> I know my system works great on OS X, Windows, and Linux when built as 
>> a serial library. What I _don't_ know is how well it works every where 
>> else (BSD, Clusters, Solaris, AIX, Crays) which is why I never tried 
>> to submit it as a module.
>>
>> Mike
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at 
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at: 
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


-- 
Will Dicharry
Software Developer
Stellar Science Ltd Co
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: AdjustLibraryVariables.cmake
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090819/eb7b368c/attachment-0001.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: FindHDF5.cmake
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090819/eb7b368c/attachment-0001.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3344 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090819/eb7b368c/attachment-0001.bin>


More information about the CMake mailing list