From e2ab61627a2989b9c7e4c8062d681a8084bf5280 Mon Sep 17 00:00:00 2001 From: paugier Date: Wed, 4 Sep 2024 23:15:56 +0200 Subject: [PATCH] MPI detection: mpicc/mpiicc before pkg-config The standard way to compile MPI applications (recommanded by all MPI implementations) is to use the commands mpicc/mpiicc (and friends). Therefore, it is standard to just set PATH such that mpicc points towards a wrapper of the MPI implementation that one wants to use. In contrast, pkg-config is supported only by OpenMPI. Therefore, Meson has first to take into account the mpicc command to get chance to use mpicc of MPICH or IntelMPI in the case OpenMPI is installed (so that pkg-config would find it). --- mesonbuild/dependencies/mpi.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/mesonbuild/dependencies/mpi.py b/mesonbuild/dependencies/mpi.py index f9c911c29..f97bb3311 100644 --- a/mesonbuild/dependencies/mpi.py +++ b/mesonbuild/dependencies/mpi.py @@ -37,18 +37,6 @@ def mpi_factory(env: 'Environment', return [] compiler_is_intel = compiler.get_id() in {'intel', 'intel-cl'} - # Only OpenMPI has pkg-config, and it doesn't work with the intel compilers - if DependencyMethods.PKGCONFIG in methods and not compiler_is_intel: - pkg_name = None - if language == 'c': - pkg_name = 'ompi-c' - elif language == 'cpp': - pkg_name = 'ompi-cxx' - elif language == 'fortran': - pkg_name = 'ompi-fort' - candidates.append(functools.partial( - PkgConfigDependency, pkg_name, env, kwargs, language=language)) - if DependencyMethods.CONFIG_TOOL in methods: nwargs = kwargs.copy() @@ -90,6 +78,19 @@ def mpi_factory(env: 'Environment', candidates.append(functools.partial( MSMPIDependency, 'msmpi', env, kwargs, language=language)) + # Only OpenMPI has pkg-config, and it doesn't work with the intel compilers + # for MPI, environment variables and commands like mpicc should have priority + if DependencyMethods.PKGCONFIG in methods and not compiler_is_intel: + pkg_name = None + if language == 'c': + pkg_name = 'ompi-c' + elif language == 'cpp': + pkg_name = 'ompi-cxx' + elif language == 'fortran': + pkg_name = 'ompi-fort' + candidates.append(functools.partial( + PkgConfigDependency, pkg_name, env, kwargs, language=language)) + return candidates packages['mpi'] = mpi_factory