From 13113ca82000fa6ad86b5980424dc9e4d28e5f39 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 14 Sep 2015 10:48:19 +0700 Subject: [PATCH] Fixes in FindHDF5.cmake for Intel Xeon Phi. Before, -lz -ldl -lm -lrt would be turned into absolute paths. This doesn't work for the Xeon Phi where we need to cross-compile. The Intel compiler automatically adds the libraries with the correct architecture as long as -l arguments are passed as is. --- cmake/Modules/FindHDF5.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/FindHDF5.cmake b/cmake/Modules/FindHDF5.cmake index 287e10e5bf..7492ea750a 100644 --- a/cmake/Modules/FindHDF5.cmake +++ b/cmake/Modules/FindHDF5.cmake @@ -292,12 +292,8 @@ if( NOT HDF5_FOUND ) mark_as_advanced( HDF5_${LANGUAGE}_INCLUDE_DIR ) list( APPEND HDF5_INCLUDE_DIRS ${HDF5_${LANGUAGE}_INCLUDE_DIR} ) - set( HDF5_${LANGUAGE}_LIBRARY_NAMES - ${HDF5_${LANGUAGE}_LIBRARY_NAMES_INIT} - ${HDF5_${LANGUAGE}_LIBRARY_NAMES} ) - # find the HDF5 libraries - foreach( LIB ${HDF5_${LANGUAGE}_LIBRARY_NAMES} ) + foreach( LIB ${HDF5_${LANGUAGE}_LIBRARY_NAMES_INIT} ) if( UNIX AND HDF5_USE_STATIC_LIBRARIES ) # According to bug 1643 on the CMake bug tracker, this is the # preferred method for searching for a static library. @@ -325,6 +321,14 @@ if( NOT HDF5_FOUND ) endforeach() list( APPEND HDF5_LIBRARY_DIRS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} ) + # When the wrapper lists a library with -l, e.g. -lz, simply use it as + # is. If find_library is called for these libraries, you end up with + # local libraries that will not be suitable when cross-compiling for the + # Intel Xeon Phi. + foreach(LIBNAME ${HDF5_${LANGUAGE}_LIBRARY_NAMES}) + list(APPEND HDF5_${LANGUAGE}_LIBRARIES "-l${LIBNAME}") + endforeach() + # Append the libraries for this language binding to the list of all # required libraries. list(APPEND HDF5_LIBRARIES ${HDF5_${LANGUAGE}_LIBRARIES})