[CMake] [New Module] FindHDF5.cmake

Will Dicharry wdicharry at stellarscience.com
Mon Aug 31 10:32:48 EDT 2009


James C. Sutherland wrote:
>> I have a question about the static library option.  I did:
>>     set( HDF5_USE_STATIC_LIBRARIES 1 )
>>
>> which should trigger linkage with static libraries, right?  But what I 
>> see in the link line is:
>>
>>> /usr/lib/libz.dylib /usr/lib/libm.dylib 
>>> /jcs/apps/hdf5_serial/lib/libhdf5_cpp.dylib /usr/lib/libz.dylib 
>>> /usr/lib/libm.dylib /jcs/apps/hdf5_serial/lib/libhdf5_cpp.dylib
>>
> Okay - it appears that was due to an out of date cache.  It now tries to 
> link static HDF5 libraries, but is still trying to link dynamic "z" and 
> "m" libraries:
>>
>> /usr/lib/libm.dylib /jcs/apps/hdf5_serial/lib/libhdf5_cpp.a 
>> /usr/lib/libz.dylib /usr/lib/libm.dylib 
>> /jcs/apps/hdf5_serial/lib/libhdf5_cpp.a
> 
>>
> 
> Previously, I was adding these via
>     target_link_libraries( ... z )
> 
> Are these two equivalent?

Hi James,

Thanks for the feedback.  I'm actually surprised it found the static 
libraries for you at all, as it looks like you're on OSX.  The 
USE_STATIC_LIBRARIES switch was placed in there for Unix systems and is 
wrapped in an if( UNIX ) flag in the module itself.  Where on your 
system are the static libm and libz?  For the static option to work, 
they need to be in one of the default search paths, one of the paths 
deduced from the HDF5 wrapper compilers, or somewhere in the path 
specified in the HDF5_ROOT environment variable.

My solution for this is somewhat suboptimal, but it appears to be the 
recommended solution for now.  For more details, take a look at 
http://www.cmake.org/Bug/view.php?id=1643.

> 
> 
> One other question: if one requests the "CXX" component for HDF5, the 
> hdf5_cpp library is linked in, but the hdf5 library is also required.  
> Adding "C" and "CXX" as components fixes this problem.  Perhaps the 
> FindHDF5.cmake file could automatically activate "C" if "CXX" is 
> requested?  That might be more robust...

You're right.  That was an oversight.  I checked a fix into CVS for that 
this morning.

> 
> Thanks again for the contribution!
> 
> James


-- 
Will Dicharry
Software Developer
Stellar Science Ltd Co
-------------- 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/20090831/d6d794e0/attachment.bin>


More information about the CMake mailing list