Findmpi4py.cmake
Go to the documentation of this file.
1 include(CMakeFindDependencyMacro)
2 find_dependency("Python${VTK_PYTHON_VERSION}" COMPONENTS Interpreter)
3 execute_process(
4  COMMAND "${Python${VTK_PYTHON_VERSION}_EXECUTABLE}" -c
5  "import mpi4py"
6  OUTPUT_VARIABLE _mpi4py_out
7  ERROR_VARIABLE _mpi4py_out
8  RESULT_VARIABLE _mpi4py_res)
9 if (_mpi4py_res)
10  set(mpi4py_FOUND 0)
11 endif ()
12 
13 if (NOT mpi4py_INCLUDE_DIR OR NOT EXISTS "${mpi4py_INCLUDE_DIR}")
14  execute_process(
15  COMMAND "${Python${VTK_PYTHON_VERSION}_EXECUTABLE}" -c
16  "import mpi4py; print(mpi4py.get_include())"
17  OUTPUT_VARIABLE _mpi4py_INCLUDE_DIR
18  RESULT_VARIABLE _mpi4py_include_dir_res
19  OUTPUT_STRIP_TRAILING_WHITESPACE)
20  if (_mpi4py_include_dir_res)
21  set(mpi4py_FOUND 0)
22  endif ()
23  set(mpi4py_INCLUDE_DIR "${_mpi4py_INCLUDE_DIR}"
24  CACHE INTERNAL "Path of the MPI4Py include directory")
25 endif ()
26 
27 include(FindPackageHandleStandardArgs)
28 find_package_handle_standard_args(mpi4py
29  REQUIRED_VARS mpi4py_INCLUDE_DIR)
30 
31 if (mpi4py_FOUND AND NOT TARGET mpi4py::mpi4py)
32  add_library(mpi4py::mpi4py INTERFACE IMPORTED)
33  set_target_properties(mpi4py::mpi4py
34  PROPERTIES
35  INTERFACE_INCLUDE_DIRECTORIES "${mpi4py_INCLUDE_DIR}")
36 endif ()