diff options
author | Christian Pfeiffer <cpfeiffer@live.de> | 2017-04-15 23:12:55 (GMT) |
---|---|---|
committer | Christian Pfeiffer <cpfeiffer@live.de> | 2017-04-15 23:12:55 (GMT) |
commit | 86979bb533a7835fc20f87b1f9d74590ebec4915 (patch) | |
tree | ae9abdb3930f7534a16f098857baba5f56eef7ab /Modules/FindMPI.cmake | |
parent | 286e4f1087fab8adc43a4da361e95dbababaead0 (diff) | |
download | CMake-86979bb533a7835fc20f87b1f9d74590ebec4915.zip CMake-86979bb533a7835fc20f87b1f9d74590ebec4915.tar.gz CMake-86979bb533a7835fc20f87b1f9d74590ebec4915.tar.bz2 |
FindMPI: Add IMPORTED targets
Diffstat (limited to 'Modules/FindMPI.cmake')
-rw-r--r-- | Modules/FindMPI.cmake | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index ff2c4de..32164a1 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -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() |