@@ -24,17 +24,39 @@ FIND_PACKAGE (GSL REQUIRED)
24
24
# Usage:
25
25
# _get_h5_lib_dir(CXX VARIABLE_STORE_PATH)
26
26
# in case of errors the output variable is set to "NOT-FOUND"
27
+ # Following, cmake recomendation, local variables/functions not to be
28
+ # used outside of the package have a name that starts with an underscore
29
+ # character.
30
+ # Usage:
31
+ # _get_h5_lib_dir( LANG OUTLIST)
32
+ # where LANG is the string of the language to be used e.g. CXX and
33
+ # OUTLIST is the output string variable that will contain the *list*
34
+ # of paths to be used
35
+ # The intent of this macro is to find the path to be passed to old
36
+ # configure style script to parameters like: --with-hdf5.
37
+ # Please note that dependening on how HDF5 is instlled on your system the
38
+ # number of elements of OUTLIST could be >1, in such a case client code
39
+ # should deal with this.
40
+ # In case of erros, OUTLIST will be set to "NOT-FOUND"
41
+ # Pre-requisite: find_package(HDF5 REQUIRED)
27
42
MACRO (_get_h5_lib_dir language output_value)
43
+ #First check that compiler executable for gien language exists
28
44
if (HDF5_${language} _COMPILER_EXECUTABLE)
45
+ #Call compiler with -show argument and capture output in
46
+ #_cmt_output
29
47
EXEC_PROGRAM ( ${HDF5_${language} _COMPILER_EXECUTABLE}
30
48
ARGS -show
31
49
OUTPUT_VARIABLE _cmp_output
32
50
RETURN_VALUE _cmp_ret_val
33
51
)
52
+ #If return code is zero, we can continue
34
53
IF ( ${_cmp_ret_val} EQUAL 0)
54
+ #Use reg-expr to search for the -L flags on the output
35
55
STRING ( REGEX MATCHALL "-L([^\" ]+|\" [^\" ]|\" )"
36
56
_lib_path_flags
37
57
"${_cmp_output} " )
58
+ #The output is a list of options, now for each one
59
+ #remove -L string and normalize paths
38
60
FOREACH ( LPATH ${_lib_path_flags} )
39
61
STRING (REGEX REPLACE "^-L" "" LPATH ${LPATH} )
40
62
STRING (REPLACE "//" "/" LPATH ${LPATH} )
@@ -55,9 +77,24 @@ MACRO(_get_h5_lib_dir language output_value)
55
77
ENDMACRO ()
56
78
57
79
80
+ #Retrieve installation path for both C++ and C, do we need both?
58
81
_get_h5_lib_dir(CXX MYHDF5_LIBRARY_DIRS)
59
82
_get_h5_lib_dir(C MYHDF5_LIBRARY_DIRS)
83
+ #Remove duplicates from list
60
84
LIST (REMOVE_DUPLICATES MYHDF5_LIBRARY_DIRS)
85
+ #Check how many paths have been identified, if more than one
86
+ #make a workaround
87
+ LIST (LENGTH MYHDF5_LIBRARY_DIRS _listlen)
88
+ IF (${_listlen} GREATER 1)
89
+ MESSAGE (WARNING "Retrieved more than one installation path for "
90
+ "HDF5, using only the first one. This may not be correct." )
91
+ FOREACH (_path ${MYHDF5_LIBRARY_DIRS} )
92
+ MESSAGE ("Candidate path: " ${_path} )
93
+ ENDFOREACH ()
94
+ #If more than one path is found, extract from the list the first and
95
+ #use that.
96
+ LIST (GET MYHDF5_LIBRARY_DIRS 0 MYHDF5_LIBRARY_DIRS)
97
+ ENDIF ()
61
98
# Add the project.
62
99
ExternalProject_Add( crystfel
63
100
URL http://www.desy.de/~twhite/crystfel/crystfel-0.6.3.tar.gz
0 commit comments