Skip to content

Commit

Permalink
try own FindMPI
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Dec 20, 2023
1 parent 9cebb0e commit 14a9552
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ enable_testing()

message(STATUS "CMake ${CMAKE_VERSION} Generator ${CMAKE_GENERATOR}")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)

# this has checks that can be reused in other projects as well
include(cmake/mpi.cmake)

Expand Down
15 changes: 5 additions & 10 deletions cmake/Modules/mpi/FindMPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
FindMPI
-------
by Michael Hirsch www.scivision.dev
SciVision www.scivision.dev
Finds compiler flags or library necessary to use MPI library (MPICH, OpenMPI, MS-MPI, Intel MPI, ...)
Expand All @@ -30,12 +30,6 @@ Result Variables
``MPI_FOUND``
indicates MPI library found
``MPI_LIBRARIES``
MPI library path
``MPI_INCLUDE_DIRS``
MPI include path
``MPI_<LANG>_LIBRARIES``
libraries for <LANG>
Expand Down Expand Up @@ -257,6 +251,7 @@ list(APPEND MPI_C_LIBRARY ${MPI_C_LIBRARY_fullpath})
find_path(MPI_C_INCLUDE_DIR
NAMES mpi.h
HINTS ${inc_dirs} ${mpi_root} ${pc_mpi_c_INCLUDE_DIRS} ${_hints} ${_hints_inc}
DOC "MPI C include directory"
)
if(NOT (MPI_C_LIBRARY AND MPI_C_INCLUDE_DIR))
return()
Expand Down Expand Up @@ -397,6 +392,7 @@ foreach(n ${mpi_libname})
NAMES ${n}
HINTS ${mpi_libdirs} ${mpi_root} ${pc_mpi_cxx_LIBRARY_DIRS} ${pc_mpi_cxx_LIBDIR} ${_hints}
PATH_SUFFIXES ${mpi_libsuf}
DOC "MPI C++ library"
)
if(MPI_CXX_${n}_LIBRARY)
list(APPEND MPI_CXX_LIBRARY ${MPI_CXX_${n}_LIBRARY})
Expand All @@ -406,6 +402,7 @@ endforeach()
find_path(MPI_CXX_INCLUDE_DIR
NAMES mpi.h
HINTS ${inc_dirs} ${mpi_root} ${pc_mpi_cxx_INCLUDE_DIRS} ${_hints} ${_hints_inc}
DOC "MPI C++ include directory"
)
if(NOT (MPI_CXX_LIBRARY AND MPI_CXX_INCLUDE_DIR))
return()
Expand Down Expand Up @@ -521,6 +518,7 @@ if(WIN32 AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
NAMES mpifptr.h
HINTS ${inc_dirs} ${mpi_root} ${pc_mpi_f_INCLUDE_DIRS} ${_hints} ${_hints_inc}
PATH_SUFFIXES x64
DOC "MPI Fortran include directory"
)

if(MPI_Fortran_INCLUDE_EXTRA AND NOT MPI_Fortran_INCLUDE_EXTRA STREQUAL ${MPI_Fortran_INCLUDE_DIR})
Expand Down Expand Up @@ -684,9 +682,6 @@ if(MPI_Fortran_FOUND)
endif(MPI_Fortran_FOUND)

if(MPI_FOUND)
set(MPI_LIBRARIES ${MPI_Fortran_LIBRARIES} ${MPI_C_LIBRARIES})
set(MPI_INCLUDE_DIRS ${MPI_Fortran_INCLUDE_DIRS} ${MPI_C_INCLUDE_DIRS})

set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.")
cmake_host_system_information(RESULT _n QUERY NUMBER_OF_PHYSICAL_CORES)
set(MPIEXEC_MAX_NUMPROCS "${_n}" CACHE STRING "Maximum number of processors available to run MPI applications.")
Expand Down

0 comments on commit 14a9552

Please # to comment.