summaryrefslogtreecommitdiffstats
path: root/Modules/FindMPI.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-04-19 14:43:24 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-04-19 14:45:03 (GMT)
commitc79e7e09a83cb6cd8bfde600ce492f0429236a02 (patch)
tree18cd8428ac8f9ef5141c6111dc4ea266d83b0c7a /Modules/FindMPI.cmake
parent89310b0b2025c0ceee7a3e6c50da88b6e2cf92ca (diff)
parent3ed9f63551c2b51af60088b85625c4ce71512aa8 (diff)
downloadCMake-c79e7e09a83cb6cd8bfde600ce492f0429236a02.zip
CMake-c79e7e09a83cb6cd8bfde600ce492f0429236a02.tar.gz
CMake-c79e7e09a83cb6cd8bfde600ce492f0429236a02.tar.bz2
Merge topic 'findmpi-add-imported-targets'
3ed9f635 FindMPI: Add test case 86979bb5 FindMPI: Add IMPORTED targets Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !707
Diffstat (limited to 'Modules/FindMPI.cmake')
-rw-r--r--Modules/FindMPI.cmake29
1 files changed, 29 insertions, 0 deletions
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index b24b5ef..3e8be5b 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()