Thanks for the suggestions, Brad. Here is a set of three patches that
breaks out the changes. For the HDF5_PREFER_PARALLEL implementation, I now
use a list to set the names for find_program which does look much cleaner.
I agree that having a NAMES_PER_DIR for find_program would be simpler from
the user's end. However, as I'm unfamiliar with the C++ source, it would
take me much longer to figure out how to add the necessary changes, so I'll
leave you with the module patches for now.

Best,
Paul

On Tue, Sep 1, 2015 at 1:53 AM, Brad King <brad.k...@kitware.com> wrote:

> On 08/31/2015 04:47 AM, Paul Romano wrote:
> > I'd like to offer the attached patch for consideration
>
> Thanks for working on these changes.
>
> Please split each independent fix out into its own commit with
> corresponding commit message explaining the change.
>
> For the HDF5_PREFER_PARALLEL implementation, please re-use
> the existing find_program calls but simply prepare a variable
> ahead of time that lists the preferred order of names.  OTOH,
> there is another approach to solve this.  The find_library
> command has a NAMES_PER_DIR option that says to consider all
> the given names in each directory before moving on to the next
> directory.  If find_program had this too then one would be able
> to choose a preference simply by having one come first in PATH.
>
> -Brad
>
>
From c6feaa82b0b9fc8a2877cec04b3619adfeea15d7 Mon Sep 17 00:00:00 2001
From: Paul Romano <paul.k.rom...@gmail.com>
Date: Tue, 1 Sep 2015 09:18:51 +0700
Subject: [PATCH 1/3] FindHDF5: Bring patch from debian cmake-data package
 upstream

Define HDF5_{Fortran_,}HL_COMPILE_LINE so that HDF5_{Fortran_,}HL_INCLUDE_DIR
and HDF5_{Fortran_,}HL_LIBRARIES are found when the macro is invoked for HL and
Fortran_HL components.
---
 Modules/FindHDF5.cmake | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index 3bd6f1e..47d85f7 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -225,6 +225,8 @@ if( NOT HDF5_FOUND )
     _HDF5_invoke_compiler( C HDF5_C_COMPILE_LINE HDF5_C_RETURN_VALUE )
     _HDF5_invoke_compiler( CXX HDF5_CXX_COMPILE_LINE HDF5_CXX_RETURN_VALUE )
     _HDF5_invoke_compiler( Fortran HDF5_Fortran_COMPILE_LINE HDF5_Fortran_RETURN_VALUE )
+    set(HDF5_HL_COMPILE_LINE ${HDF5_C_COMPILE_LINE})
+    set(HDF5_Fortran_HL_COMPILE_LINE ${HDF5_Fortran_COMPILE_LINE})
 
     # seed the initial lists of libraries to find with items we know we need
     set( HDF5_C_LIBRARY_NAMES_INIT hdf5 )
-- 
2.1.4

From 7e613004df9d107fbae34300d258385d229052cb Mon Sep 17 00:00:00 2001
From: Paul Romano <paul.k.rom...@gmail.com>
Date: Tue, 1 Sep 2015 09:20:25 +0700
Subject: [PATCH 2/3] FindHDF5: Add hdf5_hl to list of libraries to search for
 Fortran_HL

When the Fortran_HL component is specified, the hdf5_hl library is not included
in HDF5_LIBRARIES which causes a bunch of undefined references at link
time. This commit adds hdf5_hl to the list of libraries to search for when the
Fortran_HL component is specified.
---
 Modules/FindHDF5.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index 47d85f7..a449132 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -234,7 +234,7 @@ if( NOT HDF5_FOUND )
     set( HDF5_CXX_LIBRARY_NAMES_INIT hdf5_cpp ${HDF5_C_LIBRARY_NAMES_INIT} )
     set( HDF5_Fortran_LIBRARY_NAMES_INIT hdf5_fortran
         ${HDF5_C_LIBRARY_NAMES_INIT} )
-    set( HDF5_Fortran_HL_LIBRARY_NAMES_INIT hdf5hl_fortran
+    set( HDF5_Fortran_HL_LIBRARY_NAMES_INIT hdf5hl_fortran hdf5_hl
         ${HDF5_Fortran_LIBRARY_NAMES_INIT} )
 
     foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} )
-- 
2.1.4

From c35a7766ec7dc07adf54c0d5b504f07a9c35f3ab Mon Sep 17 00:00:00 2001
From: Paul Romano <paul.k.rom...@gmail.com>
Date: Tue, 1 Sep 2015 09:21:52 +0700
Subject: [PATCH 3/3] FindHDF5: Introduce HDF5_PREFER_PARALLEL option to
 address #15527

When a serial and parallel installation of HDF5 are installed alongside one
another, the serial version is always preferred due to the ordering of
h5cc/h5pcc in find_program. This commit introduces a variable
HDF5_PREFER_PARALLEL which swaps the order of the programs and therefore allows
a parallel HDF5 version to be found.
---
 Modules/FindHDF5.cmake | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index a449132..4e740c8 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -103,26 +103,37 @@ else()
     endforeach()
 endif()
 
+# Determine whether to search for serial or parallel executable first
+if(HDF5_PREFER_PARALLEL)
+  set(HDF5_C_COMPILER_NAMES h5pcc h5cc)
+  set(HDF5_CXX_COMPILER_NAMES h5pc++ h5c++)
+  set(HDF5_Fortran_COMPILER_NAMES h5pfc h5fc)
+else()
+  set(HDF5_C_COMPILER_NAMES h5cc h5pcc)
+  set(HDF5_CXX_COMPILER_NAMES h5c++ h5pc++)
+  set(HDF5_Fortran_COMPILER_NAMES h5fc h5pfc)
+endif()
+
 # try to find the HDF5 wrapper compilers
 find_program( HDF5_C_COMPILER_EXECUTABLE
-    NAMES h5cc h5pcc
-    HINTS ENV HDF5_ROOT
-    PATH_SUFFIXES bin Bin
-    DOC "HDF5 Wrapper compiler.  Used only to detect HDF5 compile flags." )
+  NAMES ${HDF5_C_COMPILER_NAMES}
+  HINTS ENV HDF5_ROOT
+  PATH_SUFFIXES bin Bin
+  DOC "HDF5 Wrapper compiler.  Used only to detect HDF5 compile flags." )
 mark_as_advanced( HDF5_C_COMPILER_EXECUTABLE )
 
 find_program( HDF5_CXX_COMPILER_EXECUTABLE
-    NAMES h5c++ h5pc++
-    HINTS ENV HDF5_ROOT
-    PATH_SUFFIXES bin Bin
-    DOC "HDF5 C++ Wrapper compiler.  Used only to detect HDF5 compile flags." )
+  NAMES ${HDF5_CXX_COMPILER_NAMES}
+  HINTS ENV HDF5_ROOT
+  PATH_SUFFIXES bin Bin
+  DOC "HDF5 C++ Wrapper compiler.  Used only to detect HDF5 compile flags." )
 mark_as_advanced( HDF5_CXX_COMPILER_EXECUTABLE )
 
 find_program( HDF5_Fortran_COMPILER_EXECUTABLE
-    NAMES h5fc h5pfc
-    HINTS ENV HDF5_ROOT
-    PATH_SUFFIXES bin Bin
-    DOC "HDF5 Fortran Wrapper compiler.  Used only to detect HDF5 compile flags." )
+  NAMES ${HDF5_Fortran_COMPILER_NAMES}
+  HINTS ENV HDF5_ROOT
+  PATH_SUFFIXES bin Bin
+  DOC "HDF5 Fortran Wrapper compiler.  Used only to detect HDF5 compile flags." )
 mark_as_advanced( HDF5_Fortran_COMPILER_EXECUTABLE )
 
 find_program( HDF5_DIFF_EXECUTABLE
@@ -378,4 +389,3 @@ find_package_handle_standard_args( HDF5
     REQUIRED_VARS HDF5_LIBRARIES HDF5_INCLUDE_DIRS
     VERSION_VAR   HDF5_VERSION
 )
-
-- 
2.1.4

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to