FindHDF5: Fix Windows compile-line parsing

We modify the signature of _HDF5_parse_compile_line to pass the command
line variable name rather than the command line itself.  Otherwise the
CMake language MACRO implementation tries to parse the command line as
CMake syntax, which does not like backslashes.
This commit is contained in:
Brad King 2009-12-18 10:13:01 -05:00
parent bdcce34435
commit 4ce7ffbfc5

View File

@ -107,7 +107,7 @@ endmacro()
# Parse a compile line for definitions, includes, library paths, and libraries. # Parse a compile line for definitions, includes, library paths, and libraries.
macro( _HDF5_parse_compile_line macro( _HDF5_parse_compile_line
compile_line compile_line_var
include_paths include_paths
definitions definitions
library_paths library_paths
@ -115,7 +115,7 @@ macro( _HDF5_parse_compile_line
# Match the include paths # Match the include paths
string( REGEX MATCHALL "-I([^\" ]+)" include_path_flags string( REGEX MATCHALL "-I([^\" ]+)" include_path_flags
"${compile_line}" "${${compile_line_var}}"
) )
foreach( IPATH ${include_path_flags} ) foreach( IPATH ${include_path_flags} )
string( REGEX REPLACE "^-I" "" IPATH ${IPATH} ) string( REGEX REPLACE "^-I" "" IPATH ${IPATH} )
@ -124,14 +124,14 @@ macro( _HDF5_parse_compile_line
endforeach() endforeach()
# Match the definitions # Match the definitions
string( REGEX MATCHALL "-D[^ ]*" definition_flags "${compile_line}" ) string( REGEX MATCHALL "-D[^ ]*" definition_flags "${${compile_line_var}}" )
foreach( DEF ${definition_flags} ) foreach( DEF ${definition_flags} )
list( APPEND ${definitions} ${DEF} ) list( APPEND ${definitions} ${DEF} )
endforeach() endforeach()
# Match the library paths # Match the library paths
string( REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" library_path_flags string( REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" library_path_flags
"${compile_line}" "${${compile_line_var}}"
) )
foreach( LPATH ${library_path_flags} ) foreach( LPATH ${library_path_flags} )
@ -144,7 +144,7 @@ macro( _HDF5_parse_compile_line
# match only -l's preceded by a space or comma # match only -l's preceded by a space or comma
# this is to exclude directory names like xxx-linux/ # this is to exclude directory names like xxx-linux/
string( REGEX MATCHALL "[, ]-l([^\", ]+)" library_name_flags string( REGEX MATCHALL "[, ]-l([^\", ]+)" library_name_flags
"${compile_line}" ) "${${compile_line_var}}" )
# strip the -l from all of the library flags and add to the search list # strip the -l from all of the library flags and add to the search list
foreach( LIB ${library_name_flags} ) foreach( LIB ${library_name_flags} )
string( REGEX REPLACE "^[, ]-l" "" LIB ${LIB} ) string( REGEX REPLACE "^[, ]-l" "" LIB ${LIB} )
@ -180,7 +180,7 @@ else()
foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} ) foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} )
if( HDF5_${LANGUAGE}_COMPILE_LINE ) if( HDF5_${LANGUAGE}_COMPILE_LINE )
_HDF5_parse_compile_line( ${HDF5_${LANGUAGE}_COMPILE_LINE} _HDF5_parse_compile_line( HDF5_${LANGUAGE}_COMPILE_LINE
HDF5_${LANGUAGE}_INCLUDE_FLAGS HDF5_${LANGUAGE}_INCLUDE_FLAGS
HDF5_${LANGUAGE}_DEFINITIONS HDF5_${LANGUAGE}_DEFINITIONS
HDF5_${LANGUAGE}_LIBRARY_DIRS HDF5_${LANGUAGE}_LIBRARY_DIRS