FindMPI works with CMake 3.8's separate_arguments

CMake 3.8 separate_arguments command doesn't support NATIVE_COMMAND
so we have to do that logic for it.
This commit is contained in:
Robert Maynard 2019-08-21 09:55:15 -04:00
parent 1f99fbc357
commit 978650b063

@ -306,6 +306,19 @@ set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95
mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r
mpixlf mpixlf_r mpxlf mpxlf_r)
# Allow CMake 3.8.0 to use OS specific `separate_arguments` signature.
# Otherwise use the 3.9 NATIVE_COMMAND feature that does this for us
# automatically
if (CMAKE_VERSION VERSION_LESS "3.9.0")
if (WIN32 AND NOT CYGWIN)
set(_MPI_parse_kind WINDOWS_COMMAND)
else ()
set(_MPI_parse_kind UNIX_COMMAND)
endif ()
else ()
set(_MPI_parse_kind NATIVE_COMMAND)
endif ()
# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler,
# attempt all of them.
# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper
@ -340,9 +353,9 @@ unset(_MPIEXEC_NAMES_BASE)
function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE)
if(DEFINED MPI_${LANG}_COMPILER_FLAGS)
separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}")
separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS ${_MPI_parse_kind} "${MPI_${LANG}_COMPILER_FLAGS}")
else()
separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}")
separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS ${_MPI_parse_kind} "${MPI_COMPILER_FLAGS}")
endif()
execute_process(
COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG}
@ -630,7 +643,7 @@ function (_MPI_interrogate_compiler LANG)
if (NOT MPI_ALL_INCLUDE_PATHS)
_MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN)
if(MPI_INCDIRS_COMPILER_RETURN)
separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}")
separate_arguments(MPI_ALL_INCLUDE_PATHS ${_MPI_parse_kind} "${MPI_INCDIRS_CMDLINE}")
endif()
endif()
@ -698,7 +711,7 @@ function (_MPI_interrogate_compiler LANG)
if (NOT MPI_ALL_LINK_PATHS)
_MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN)
if(MPI_LIBDIRS_COMPILER_RETURN)
separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}")
separate_arguments(MPI_ALL_LINK_PATHS ${_MPI_parse_kind} "${MPI_LIBDIRS_CMDLINE}")
endif()
endif()
@ -1157,7 +1170,7 @@ macro(_MPI_create_imported_target LANG)
set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "")
if(MPI_${LANG}_LINK_FLAGS)
separate_arguments(_MPI_${LANG}_LINK_FLAGS NATIVE_COMMAND "${MPI_${LANG}_LINK_FLAGS}")
separate_arguments(_MPI_${LANG}_LINK_FLAGS ${_MPI_parse_kind} "${MPI_${LANG}_LINK_FLAGS}")
if(CMAKE_VERSION VERSION_LESS 3.13)
set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${_MPI_${LANG}_LINK_FLAGS}")
else()
@ -1349,7 +1362,7 @@ if(NOT MPI_IGNORE_LEGACY_VARIABLES)
unset(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS)
unset(MPI_${LANG}_EXTRA_COMPILE_OPTIONS)
if(MPI_${LANG}_COMPILE_FLAGS)
separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}")
separate_arguments(MPI_SEPARATE_FLAGS ${_MPI_parse_kind} "${MPI_${LANG}_COMPILE_FLAGS}")
foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS)
if("${_MPI_FLAG}" MATCHES "^ *-D([^ ]+)")
list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}")