Thank you for your contribution, we are always looking for ways to improve the 
CMake code.
I have just recently updated the target_link_libraries calls to use the 
interface keywords and have now added this suggestion to that change.

Thank you for sharing!
Allen


On Monday, December 4, 2017 11:06:07 AM CST Roger Leigh wrote:
> Not all Unix platforms have a libdl.  FreeBSD, for example, has the
> libdl symbols as part of libc.  CMake provides ${CMAKE_DL_LIBS} which
> contains the library to link with, which should be preferred over
> linking explicitly with libdl.  With this patch applied (against
> 1.10.1), it's possible to build on FreeBSD and other Unix systems
> without libdl.
> 
> Incidentally, this should really be using
> 
>    "target_link_libraries(${target} PRIVATE ${CMAKE_DL_LIBS})"
> 
> because it's not part of the exported link interface, and is only used
> as an implementation detail of a single source file.  However, this
> would require making all your uses of target_link_libraries use
> PUBLIC|PRIVATE|INTERFACE, which is a bigger change.  However, it's
> something you could consider doing as a followup step.
> 
> By the way, is there a public git/svn/other repo for tracking
> development rather than producing diffs against the last release?
> 
> 
> Regards,
> Roger
> 
> 
> Patch follows:
> 
> diff -urN hdf5-1.10.1.orig/src/CMakeLists.txt hdf5-1.10.1/src/CMakeLists.txt
> --- hdf5-1.10.1.orig/src/CMakeLists.txt 2017-04-13 18:26:11.000000000 +0100
> +++ hdf5-1.10.1/src/CMakeLists.txt      2017-12-04 16:39:11.428808794 +0000
> @@ -880,7 +880,7 @@
>   TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC " " " ")
>   target_link_libraries (${HDF5_LIB_TARGET} ${LINK_LIBS})
>   if (NOT WIN32)
> -  target_link_libraries (${HDF5_LIB_TARGET} dl)
> +  target_link_libraries (${HDF5_LIB_TARGET} ${CMAKE_DL_LIBS})
>   endif ()
>   if (H5_HAVE_PARALLEL AND MPI_C_FOUND)
>     target_link_libraries (${HDF5_LIB_TARGET} ${MPI_C_LIBRARIES})
> @@ -924,7 +924,7 @@
>     TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED " " " ")
>     target_link_libraries (${HDF5_LIBSH_TARGET} ${LINK_SHARED_LIBS})
>     if (NOT WIN32)
> -    target_link_libraries (${HDF5_LIBSH_TARGET} dl)
> +    target_link_libraries (${HDF5_LIBSH_TARGET} ${CMAKE_DL_LIBS})
>     endif ()
>     if (H5_HAVE_PARALLEL AND MPI_C_FOUND)
>       target_link_libraries (${HDF5_LIBSH_TARGET} ${MPI_C_LIBRARIES})
> 
> 
> --
> Dr Roger Leigh -- Open Microscopy Environment
> Wellcome Trust Centre for Gene Regulation and Expression,
> College of Life Sciences, University of Dundee, Dow Street,
> Dundee DD1 5EH Scotland UK   Tel: (01382) 386364
> 
> The University of Dundee is a registered Scottish Charity, No: SC015096
> 
> _______________________________________________
> Hdf-forum is for HDF software users discussion.
> [email protected]
> http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
> Twitter: https://twitter.com/hdf5
> 



_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Reply via email to