[Cmake-commits] CMake branch, next, updated. v3.8.0-787-g94d540e
Kitware Robot
kwrobot at kitware.com
Tue Apr 18 11:55:04 EDT 2017
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 94d540e50f8beaa7cb8e6c43be0fa8c00dc58d25 (commit)
via 3ed9f63551c2b51af60088b85625c4ce71512aa8 (commit)
via 86979bb533a7835fc20f87b1f9d74590ebec4915 (commit)
from 6d0c471b875eb9684eef20061deb0c2f0b6f2e1b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=94d540e50f8beaa7cb8e6c43be0fa8c00dc58d25
commit 94d540e50f8beaa7cb8e6c43be0fa8c00dc58d25
Merge: 6d0c471 3ed9f63
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Apr 18 15:51:52 2017 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Apr 18 11:51:56 2017 -0400
Stage topic 'findmpi-add-imported-targets'
Topic-id: 23696
Topic-url: https://gitlab.kitware.com/cmake/cmake/merge_requests/707
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3ed9f63551c2b51af60088b85625c4ce71512aa8
commit 3ed9f63551c2b51af60088b85625c4ce71512aa8
Author: Christian Pfeiffer <cpfeiffer at live.de>
AuthorDate: Tue Apr 18 17:43:25 2017 +0200
Commit: Christian Pfeiffer <cpfeiffer at live.de>
CommitDate: Tue Apr 18 17:43:25 2017 +0200
FindMPI: Add test case
diff --git a/Help/release/dev/FindMPI-add-imported-targets.rst b/Help/release/dev/FindMPI-add-imported-targets.rst
new file mode 100644
index 0000000..c0a7bfc
--- /dev/null
+++ b/Help/release/dev/FindMPI-add-imported-targets.rst
@@ -0,0 +1,4 @@
+FindMPI-add-imported-targets
+------------------------------
+
+* The :module:`FindMPI` module now provides imported targets.
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 910ff39..491d974 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1411,6 +1411,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
add_subdirectory(FindOpenSSL)
endif()
+ if(CMake_TEST_FindMPI)
+ add_subdirectory(FindMPI)
+ endif()
+
if(CMake_TEST_FindPNG)
add_subdirectory(FindPNG)
endif()
diff --git a/Tests/FindMPI/CMakeLists.txt b/Tests/FindMPI/CMakeLists.txt
new file mode 100644
index 0000000..121d978
--- /dev/null
+++ b/Tests/FindMPI/CMakeLists.txt
@@ -0,0 +1,21 @@
+foreach(c C CXX Fortran)
+ if(CMake_TEST_FindMPI_${c})
+ set(CMake_TEST_FindMPI_FLAG_${c} 1)
+ else()
+ set(CMake_TEST_FindMPI_FLAG_${c} 0)
+ endif()
+endforeach()
+
+add_test(NAME FindMPI.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindMPI/Test"
+ "${CMake_BINARY_DIR}/Tests/FindMPI/Test"
+ ${build_generator_args}
+ --build-project TestFindMPI
+ --build-options ${build_options}
+ -DMPI_TEST_C=${CMake_TEST_FindMPI_FLAG_C}
+ -DMPI_TEST_CXX=${CMake_TEST_FindMPI_FLAG_CXX}
+ -DMPI_TEST_Fortran=${CMake_TEST_FindMPI_FLAG_Fortran}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindMPI/Test/CMakeLists.txt b/Tests/FindMPI/Test/CMakeLists.txt
new file mode 100644
index 0000000..6f177f9
--- /dev/null
+++ b/Tests/FindMPI/Test/CMakeLists.txt
@@ -0,0 +1,41 @@
+cmake_minimum_required(VERSION 3.8)
+project(TestFindMPI)
+include(CTest)
+
+macro(source_code_mapper_helper LANG_NAME)
+ if("${LANG_NAME}" STREQUAL "C")
+ set(MPITEST_SOURCE_FILE "main.c")
+ elseif("${LANG_NAME}" STREQUAL "CXX")
+ configure_file("main.c" "main.cxx" COPYONLY)
+ set(MPITEST_SOURCE_FILE "main.cxx")
+ elseif("${LANG_NAME}" STREQUAL "Fortran")
+ set(MPITEST_SOURCE_FILE "main.f90")
+ endif()
+endmacro()
+
+foreach(c C CXX Fortran)
+ if("${MPI_TEST_${c}}")
+ message("Testing ${c}")
+ enable_language(${c})
+ endif()
+endforeach()
+
+find_package(MPI REQUIRED)
+
+foreach(c C CXX Fortran)
+ if(NOT "${MPI_TEST_${c}}")
+ continue()
+ endif()
+ source_code_mapper_helper(${c})
+ add_executable(test_tgt_${c} ${MPITEST_SOURCE_FILE})
+ target_link_libraries(test_tgt_${c} MPI::MPI_${c})
+ add_test(NAME test_tgt_${c} COMMAND test_tgt_${c})
+
+ add_executable(test_var_${c} ${MPITEST_SOURCE_FILE})
+ target_include_directories(test_var_${c} PRIVATE "${MPI_${c}_INCLUDE_PATH}")
+ target_link_libraries(test_var_${c} PRIVATE "${MPI_${c}_LINK_FLAGS}" "${MPI_${c}_LIBRARIES}")
+ set(copied_MPI_${c}_OPTIONS "${MPI_${c}_COMPILE_FLAGS}")
+ separate_arguments(copied_MPI_${c}_OPTIONS)
+ target_compile_options(test_var_${c} PRIVATE "${copied_MPI_${c}_OPTIONS}")
+ add_test(NAME test_var_${c} COMMAND test_var_${c})
+endforeach()
diff --git a/Tests/FindMPI/Test/main.c b/Tests/FindMPI/Test/main.c
new file mode 100644
index 0000000..7b7f175
--- /dev/null
+++ b/Tests/FindMPI/Test/main.c
@@ -0,0 +1,7 @@
+#include <mpi.h>
+
+int main(int argc, char** argv)
+{
+ MPI_Init(&argc, &argv);
+ MPI_Finalize();
+}
diff --git a/Tests/FindMPI/Test/main.f90 b/Tests/FindMPI/Test/main.f90
new file mode 100644
index 0000000..6fb6fd3
--- /dev/null
+++ b/Tests/FindMPI/Test/main.f90
@@ -0,0 +1,7 @@
+program mpi_test
+ include 'mpif.h'
+ integer ierror
+
+ call MPI_INIT(ierror)
+ call MPI_FINALIZE(ierror)
+end program mpi_test
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=86979bb533a7835fc20f87b1f9d74590ebec4915
commit 86979bb533a7835fc20f87b1f9d74590ebec4915
Author: Christian Pfeiffer <cpfeiffer at live.de>
AuthorDate: Sun Apr 16 01:12:55 2017 +0200
Commit: Christian Pfeiffer <cpfeiffer at live.de>
CommitDate: Sun Apr 16 01:12:55 2017 +0200
FindMPI: Add IMPORTED targets
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()
-----------------------------------------------------------------------
Summary of changes:
Help/release/dev/FindMPI-add-imported-targets.rst | 4 ++
Modules/FindMPI.cmake | 29 +++++++++++++++
Tests/CMakeLists.txt | 4 ++
Tests/FindMPI/CMakeLists.txt | 21 +++++++++++
Tests/FindMPI/Test/CMakeLists.txt | 41 +++++++++++++++++++++
Tests/FindMPI/Test/main.c | 7 ++++
Tests/FindMPI/Test/main.f90 | 7 ++++
7 files changed, 113 insertions(+)
create mode 100644 Help/release/dev/FindMPI-add-imported-targets.rst
create mode 100644 Tests/FindMPI/CMakeLists.txt
create mode 100644 Tests/FindMPI/Test/CMakeLists.txt
create mode 100644 Tests/FindMPI/Test/main.c
create mode 100644 Tests/FindMPI/Test/main.f90
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list