Commit 86979bb5 authored by Christian Pfeiffer's avatar Christian Pfeiffer

FindMPI: Add IMPORTED targets

parent 286e4f10
......@@ -29,6 +29,12 @@
# MPI_<lang>_LINK_FLAGS Linking flags for MPI programs
# MPI_<lang>_LIBRARIES All libraries to link MPI programs against
#
# Additionally, the following :prop_tgt:`IMPORTED` targets are defined:
#
# ::
#
# MPI::MPI_<lang> Target for using MPI from <lang>
#
# Additionally, FindMPI sets the following variables for running MPI
# programs from the command line:
#
......@@ -621,6 +627,29 @@ foreach (lang C CXX Fortran)
else()
find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_LIBRARIES MPI_${lang}_INCLUDE_PATH)
endif()
if(MPI_${lang}_FOUND)
if(NOT TARGET MPI::MPI_${lang})
add_library(MPI::MPI_${lang} INTERFACE IMPORTED)
endif()
if(MPI_${lang}_COMPILE_FLAGS)
set(_MPI_${lang}_COMPILE_OPTIONS "${MPI_${lang}_COMPILE_FLAGS}")
separate_arguments(_MPI_${lang}_COMPILE_OPTIONS)
set_property(TARGET MPI::MPI_${lang} PROPERTY
INTERFACE_COMPILE_OPTIONS "${_MPI_${lang}_COMPILE_OPTIONS}")
endif()
unset(_MPI_${lang}_LINK_LINE)
if(MPI_${lang}_LINK_FLAGS)
list(APPEND _MPI_${lang}_LINK_LINE "${MPI_${lang}_LINK_FLAGS}")
endif()
list(APPEND _MPI_${lang}_LINK_LINE "${MPI_${lang}_LIBRARIES}")
set_property(TARGET MPI::MPI_${lang} PROPERTY
INTERFACE_LINK_LIBRARIES "${_MPI_${lang}_LINK_LINE}")
set_property(TARGET MPI::MPI_${lang} PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${MPI_${lang}_INCLUDE_PATH}")
endif()
endif()
endforeach()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment